MainPage.js 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084
  1. /**
  2. * Sample React Native App
  3. * https://github.com/facebook/react-native
  4. *
  5. * @format
  6. * @flow
  7. */
  8. import React, { Component } from "react";
  9. import {
  10. Platform,
  11. StyleSheet,
  12. Text,
  13. View,
  14. Image,
  15. FlatList,
  16. TouchableOpacity,
  17. ImageBackground,
  18. Button,
  19. ViewPagerAndroid,
  20. DeviceEventEmitter
  21. } from "react-native";
  22. import Swiper from "react-native-swiper";
  23. import AndroidUtil from "../../util/AndroidUtil";
  24. import BasePage from "../BasePage";
  25. const instructions = Platform.select({
  26. ios: "Press Cmd+R to reload,\n" + "Cmd+D or shake for dev menu",
  27. android:
  28. "Double tap R on your keyboard to reload,\n" +
  29. "Shake or press menu button for dev menu"
  30. });
  31. type Props = {};
  32. export default class MainPage extends BasePage {
  33. render() {
  34. return (
  35. <View style={{ flex: 1 }}>
  36. <FlatList
  37. style={{ flex: 1 }}
  38. ref="_flatlist"
  39. horizontal={false}
  40. removeClippedSubviews={false}
  41. ListHeaderComponent={() => this.headerorfooterComponent()}
  42. keyExtractor={(item, index) => item.key.toString()}
  43. renderItem={({ item }) => {
  44. return this.loadFlatItem(item);
  45. }}
  46. data={[
  47. {
  48. //轮播
  49. key: 111,
  50. typea: 1,
  51. text: "第一种类型"
  52. },
  53. {
  54. //标题类型
  55. key: 333,
  56. typea: 0,
  57. title: "全部课程全部课程全部课程全部课程全部课程全部课程"
  58. },
  59. {
  60. //只有一个标题下面两个图片
  61. key: 222,
  62. typea: 2,
  63. item: {
  64. item_type: 1,
  65. title: "课程表:第一周",
  66. icon_item: [
  67. {
  68. icon:
  69. "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
  70. name: "第一张图片文字"
  71. },
  72. {
  73. icon:
  74. "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
  75. name: "第二张图片文字"
  76. }
  77. ]
  78. }
  79. },
  80. {
  81. //一个标题,大长图
  82. key: 444,
  83. typea: 3,
  84. title: "五月主题:五一启程,去看看不同世界",
  85. text: "每天30分钟,玩学两不误",
  86. icon_item: [
  87. {
  88. icon:
  89. "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
  90. name: "第一张图片文字"
  91. },
  92. {
  93. icon:
  94. "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
  95. name: "第二张图片文字"
  96. },
  97. {
  98. icon:
  99. "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
  100. name: "第三张图片文字"
  101. },
  102. {
  103. icon:
  104. "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
  105. name: "第四张图片文字"
  106. },
  107. {
  108. icon:
  109. "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
  110. name: "第五张图片文字"
  111. }
  112. ]
  113. },
  114. {
  115. key: 555,
  116. typea: 4,
  117. title: "热门课程",
  118. text: "text",
  119. mask: false,
  120. icon_item: [
  121. {
  122. icon:
  123. "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
  124. name: "第一张图片文字"
  125. },
  126. {
  127. icon:
  128. "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
  129. name: "第二张图片文字"
  130. },
  131. {
  132. icon:
  133. "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
  134. name: "第三张图片文字"
  135. },
  136. {
  137. icon:
  138. "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
  139. name: "第四张图片文字"
  140. },
  141. {
  142. icon:
  143. "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
  144. name: "第五张图片文字"
  145. }
  146. ]
  147. },
  148. {
  149. //标题类型
  150. key: 0,
  151. typea: 0,
  152. title: "全部课程"
  153. },
  154. {
  155. //一个标题,icon下有文字
  156. key: 666,
  157. typea: 4,
  158. title: "测试text为空的时候",
  159. text: "",
  160. mask: false,
  161. icon_item: [
  162. {
  163. icon:
  164. "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
  165. name: "第一张图片文字"
  166. },
  167. {
  168. icon:
  169. "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
  170. name: "第二张图片文字"
  171. },
  172. {
  173. icon:
  174. "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
  175. name: "第三张图片文字"
  176. },
  177. {
  178. icon:
  179. "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
  180. name: "第四张图片文字"
  181. },
  182. {
  183. icon:
  184. "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
  185. name: "第五张图片文字"
  186. }
  187. ]
  188. },
  189. {
  190. key: 777,
  191. typea: 4,
  192. title: "测试观看记录",
  193. text: "",
  194. mask: true,
  195. icon_item: [
  196. {
  197. last_time: "2小时前",
  198. icon:
  199. "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
  200. name: "第一张图片文字",
  201. curriculum_name: "课件名字"
  202. },
  203. {
  204. last_time: "3小时前",
  205. icon:
  206. "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
  207. name: "第二张图片文字",
  208. curriculum_name: "课件名字1"
  209. },
  210. {
  211. last_time: "4小时前",
  212. icon:
  213. "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
  214. name: "第三张图片文字",
  215. curriculum_name: "课件名字2"
  216. },
  217. {
  218. last_time: "1天前",
  219. icon:
  220. "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
  221. name: "第四张图片文字",
  222. curriculum_name: "课件名字3"
  223. },
  224. {
  225. last_time: "2天前",
  226. icon:
  227. "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
  228. name: "第五张图片文字",
  229. curriculum_name: "课件名字4"
  230. }
  231. ]
  232. }
  233. ]}
  234. />
  235. </View>
  236. );
  237. }
  238. headerorfooterComponent() {
  239. return (
  240. <ImageBackground
  241. style={{
  242. width: "100%",
  243. height: 130
  244. }}
  245. >
  246. <View
  247. style={{
  248. flex: 2,
  249. width: "90%",
  250. flexDirection: "column",
  251. justifyContent: "center",
  252. alignItems: "stretch"
  253. }}
  254. >
  255. <View
  256. style={{
  257. flex: 1,
  258. flexDirection: "row",
  259. alignItems: "stretch",
  260. justifyContent: "center",
  261. backgroundColor: "#FFFFFF"
  262. }}
  263. >
  264. <View
  265. style={{
  266. flex: 1
  267. }}
  268. />
  269. <TouchableOpacity
  270. activeOpacity={1}
  271. style={{
  272. flex: 1,
  273. justifyContent: "center",
  274. height: "100%"
  275. }}
  276. onPress={() => this.toNextPage("MainActivity")}
  277. >
  278. <Image
  279. // source={{
  280. // uri:
  281. // "https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=532481250,2026274152&fm=15&gp=0.jpg"
  282. // }}
  283. style={{
  284. width: 56,
  285. justifyContent: "center",
  286. height: 56,
  287. borderRadius: 50,
  288. backgroundColor: "#828282"
  289. }}
  290. />
  291. </TouchableOpacity>
  292. <View
  293. style={{
  294. flex: 0.5
  295. }}
  296. />
  297. <View
  298. style={{
  299. flex: 9,
  300. marginLeft: 20,
  301. flexDirection: "column",
  302. alignItems: "center",
  303. justifyContent: "center",
  304. height: "100%"
  305. }}
  306. >
  307. <View
  308. style={{
  309. flex: 1,
  310. alignItems: "center",
  311. justifyContent: "center",
  312. height: "100%",
  313. justifyContent: "center",
  314. width: "100%"
  315. }}
  316. >
  317. <Text
  318. style={{
  319. textAlign: "left",
  320. height: 20,
  321. justifyContent: "center",
  322. width: "100%",
  323. fontSize: 18
  324. }}
  325. >
  326. 用户昵称
  327. </Text>
  328. </View>
  329. <View
  330. style={{
  331. flex: 1,
  332. alignItems: "center",
  333. flexDirection: "row",
  334. justifyContent: "center",
  335. width: "100%"
  336. }}
  337. >
  338. <Image
  339. source={{
  340. uri:
  341. "https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=532481250,2026274152&fm=15&gp=0.jpg"
  342. }}
  343. style={{
  344. width: 22,
  345. justifyContent: "center",
  346. alignItems: "center",
  347. height: 22
  348. }}
  349. />
  350. <View
  351. style={{
  352. flex: 9,
  353. alignItems: "center",
  354. justifyContent: "center",
  355. height: "100%",
  356. width: "100%"
  357. }}
  358. >
  359. <Text
  360. style={{
  361. textAlign: "left",
  362. justifyContent: "center",
  363. width: "100%",
  364. fontSize: 18
  365. }}
  366. >
  367. 6548
  368. </Text>
  369. </View>
  370. </View>
  371. </View>
  372. <View
  373. style={{
  374. flex: 3,
  375. flexDirection: "row",
  376. alignItems: "center",
  377. justifyContent: "center"
  378. }}
  379. >
  380. <TouchableOpacity
  381. activeOpacity={1}
  382. onPress={() => this.toNextPage("MainActivity")}
  383. >
  384. <View
  385. style={{
  386. flexDirection: "row",
  387. alignItems: "center",
  388. justifyContent: "center",
  389. height: "80%",
  390. width: "100%"
  391. }}
  392. >
  393. <Image
  394. source={{
  395. uri:
  396. "https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=532481250,2026274152&fm=15&gp=0.jpg"
  397. }}
  398. style={{
  399. width: 16,
  400. justifyContent: "center",
  401. alignItems: "center",
  402. marginRight: 5,
  403. height: 15
  404. }}
  405. />
  406. <View>
  407. <Text style={{}}>我的课程</Text>
  408. </View>
  409. </View>
  410. </TouchableOpacity>
  411. </View>
  412. <View
  413. style={{
  414. flex: 0.5
  415. }}
  416. />
  417. </View>
  418. <View
  419. style={{
  420. flex: 0.1,
  421. backgroundColor: "#F8F8F8"
  422. }}
  423. />
  424. <View
  425. //这里要改成活的
  426. style={{
  427. flex: 1,
  428. flexDirection: "column",
  429. alignItems: "center",
  430. justifyContent: "center",
  431. width: "100%"
  432. }}
  433. >
  434. <View
  435. style={{
  436. flexDirection: "row",
  437. flex: 1,
  438. width: "90%",
  439. backgroundColor: "#FFFFFF",
  440. alignItems: "center"
  441. }}
  442. >
  443. <Text
  444. style={{
  445. flex: 1.5,
  446. fontSize: 18,
  447. fontWeight: "bold",
  448. color: "black"
  449. }}
  450. >
  451. 学前
  452. </Text>
  453. <View
  454. style={{
  455. flex: 9
  456. }}
  457. />
  458. <View
  459. style={{
  460. flex: 2,
  461. alignItems: "center",
  462. justifyContent: "center",
  463. flexDirection: "row"
  464. }}
  465. >
  466. <Image
  467. source={{
  468. uri:
  469. "https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=532481250,2026274152&fm=15&gp=0.jpg"
  470. }}
  471. style={{
  472. width: 14,
  473. justifyContent: "center",
  474. alignItems: "center",
  475. height: 13,
  476. marginRight: 5
  477. }}
  478. />
  479. <Text style={{}}>切换学龄</Text>
  480. </View>
  481. </View>
  482. <View
  483. style={{
  484. flex: 0.1,
  485. width: "90%",
  486. backgroundColor: "#F8F8F8"
  487. }}
  488. />
  489. </View>
  490. </View>
  491. </ImageBackground>
  492. );
  493. }
  494. loadFlatItem(data) {
  495. switch (data.typea) {
  496. case 0:
  497. return (
  498. <View
  499. style={{
  500. height: 50,
  501. width: "100%",
  502. justifyContent: "center",
  503. alignItems: "center",
  504. backgroundColor: "#F8F8F8"
  505. }}
  506. >
  507. <View
  508. style={{
  509. height: "60%",
  510. justifyContent: "center",
  511. alignItems: "center",
  512. width: "90%",
  513. backgroundColor: "#ffffffff",
  514. borderRadius: 20,
  515. flexDirection: "row"
  516. }}
  517. >
  518. <View style={{ flex: 0.2 }} />
  519. <Text
  520. numberOfLines={1}
  521. style={{
  522. flex: 12,
  523. justifyContent: "center",
  524. alignItems: "center",
  525. fontSize: 18,
  526. fontWeight: "bold",
  527. color: "#3E455B"
  528. }}
  529. >
  530. {data.title}
  531. </Text>
  532. <View
  533. style={{
  534. flex: 1,
  535. height: "100%",
  536. justifyContent: "center",
  537. alignItems: "center"
  538. }}
  539. >
  540. <Image
  541. source={{
  542. uri:
  543. "https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1295208965,3056573814&fm=26&gp=0.jpg"
  544. }}
  545. style={{
  546. width: "50%",
  547. height: "50%",
  548. justifyContent: "center",
  549. alignItems: "center",
  550. borderRadius: 30
  551. }}
  552. />
  553. </View>
  554. </View>
  555. </View>
  556. );
  557. break;
  558. case 1:
  559. return (
  560. <View
  561. style={{
  562. marginTop: 10,
  563. flex: 1,
  564. justifyContent: "center",
  565. alignItems: "center",
  566. flexDirection: "row"
  567. }}
  568. >
  569. <View
  570. style={{
  571. width: "90%",
  572. overflow: "hidden",
  573. height: 150
  574. }}
  575. >
  576. <Swiper
  577. style={{ flex: 1 }}
  578. horizontal={true}
  579. autoplayTimeout={3}
  580. autoplay={true}
  581. activeDotColor="#fff"
  582. >
  583. <View key="1" style={{ flex: 1 }}>
  584. <Image
  585. source={{
  586. uri:
  587. "https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1295208965,3056573814&fm=26&gp=0.jpg"
  588. }}
  589. style={{
  590. width: "100%",
  591. height: "100%",
  592. justifyContent: "center",
  593. alignItems: "center",
  594. borderRadius: 10
  595. }}
  596. />
  597. </View>
  598. <View key="2" style={{ flex: 1 }}>
  599. <TouchableOpacity
  600. activeOpacity={1}
  601. onPress={() => this.toNextPage("MainActivity")}
  602. >
  603. <Image
  604. source={{
  605. uri:
  606. "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg"
  607. }}
  608. style={{
  609. width: "100%",
  610. height: "100%",
  611. justifyContent: "center",
  612. alignItems: "center",
  613. borderRadius: 10
  614. }}
  615. />
  616. </TouchableOpacity>
  617. </View>
  618. </Swiper>
  619. </View>
  620. </View>
  621. );
  622. break;
  623. case 2:
  624. let arr = [];
  625. let index = 0;
  626. for (let item of data.item.icon_item) {
  627. arr.push(
  628. <TouchableOpacity
  629. style={{ flex: 2 }}
  630. onPress={() => {
  631. alert(item.name);
  632. }}
  633. key={index}
  634. activeOpacity={1}
  635. >
  636. <Image
  637. source={{
  638. uri: item.icon
  639. }}
  640. key={index}
  641. style={{
  642. width: "100%",
  643. height: "100%",
  644. justifyContent: "center",
  645. alignItems: "center",
  646. borderRadius: 10
  647. }}
  648. />
  649. </TouchableOpacity>
  650. );
  651. if (index < data.item.icon_item.length - 1) {
  652. arr.push(
  653. <View
  654. key={item.name}
  655. style={{
  656. flex: 0.1
  657. }}
  658. />
  659. );
  660. }
  661. index++;
  662. }
  663. return (
  664. <View
  665. style={{
  666. marginTop: 20,
  667. flex: 1,
  668. justifyContent: "center",
  669. alignItems: "center"
  670. }}
  671. >
  672. <View
  673. style={{
  674. flex: 1,
  675. flexDirection: "column",
  676. width: "90%",
  677. height: 150
  678. }}
  679. >
  680. <Text
  681. style={{
  682. flex: 0.5,
  683. fontSize: 18,
  684. fontWeight: "bold",
  685. color: "#3E455B"
  686. }}
  687. >
  688. {data.item.title}
  689. </Text>
  690. <View
  691. style={{
  692. flex: 2,
  693. flexDirection: "row",
  694. justifyContent: "space-between"
  695. }}
  696. >
  697. {arr}
  698. </View>
  699. </View>
  700. </View>
  701. );
  702. break;
  703. case 3:
  704. return (
  705. <View
  706. style={{
  707. marginTop: 20,
  708. flex: 1,
  709. justifyContent: "center",
  710. alignItems: "center"
  711. }}
  712. >
  713. <View
  714. style={{
  715. width: "90%",
  716. height: 200,
  717. flexDirection: "column"
  718. }}
  719. >
  720. <View
  721. style={{
  722. flex: 0.5,
  723. justifyContent: "center",
  724. alignItems: "center",
  725. flexDirection: "row"
  726. }}
  727. >
  728. <View
  729. style={{
  730. flex: 0.1,
  731. height: 14,
  732. justifyContent: "flex-start",
  733. alignItems: "center",
  734. backgroundColor: "#01AFFE",
  735. borderRadius: 20
  736. }}
  737. />
  738. <View
  739. style={{
  740. flex: 0.1
  741. }}
  742. />
  743. <Text
  744. numberOfLines={1}
  745. style={{
  746. flex: 11,
  747. fontSize: 18,
  748. fontWeight: "bold",
  749. color: "#3E455B"
  750. }}
  751. >
  752. {data.title}
  753. </Text>
  754. </View>
  755. {text_z}
  756. <View
  757. style={{
  758. flex: 3
  759. }}
  760. >
  761. <FlatList
  762. style={{
  763. flex: 1
  764. }}
  765. ItemSeparatorComponent={() => (
  766. <View
  767. style={{
  768. width: 10
  769. }}
  770. />
  771. )}
  772. showsHorizontalScrollIndicator={false}
  773. keyExtractor={(item, index) => item.name.toString()}
  774. data={data.icon_item}
  775. horizontal={true}
  776. renderItem={({ item }) => {
  777. return (
  778. <TouchableOpacity
  779. style={{
  780. flex: 1,
  781. height: "100%",
  782. width: this.getWindowWidth() * 0.9
  783. }}
  784. onPress={() => {
  785. alert(item.name);
  786. }}
  787. activeOpacity={1}
  788. >
  789. <Image
  790. source={{
  791. uri: item.icon
  792. }}
  793. style={{
  794. height: "100%",
  795. width: "100%",
  796. justifyContent: "center",
  797. alignItems: "center",
  798. borderRadius: 20
  799. }}
  800. />
  801. </TouchableOpacity>
  802. );
  803. }}
  804. />
  805. </View>
  806. </View>
  807. </View>
  808. );
  809. break;
  810. case 4:
  811. let text_z = [];
  812. let zhezhao = [];
  813. let view_height = 190;
  814. //判断是否需要text
  815. if (data.text != "") {
  816. view_height = 217;
  817. text_z.push(
  818. <View
  819. key={data.text}
  820. style={{
  821. flex: 0.5,
  822. justifyContent: "center",
  823. alignItems: "center",
  824. flexDirection: "row"
  825. }}
  826. >
  827. <View
  828. style={{
  829. flex: 1,
  830. flexDirection: "row"
  831. }}
  832. >
  833. <View
  834. style={{
  835. flex: 0.2
  836. }}
  837. />
  838. <Text
  839. style={{
  840. flex: 11,
  841. color: "#8F94AA"
  842. }}
  843. >
  844. {data.text}
  845. </Text>
  846. </View>
  847. </View>
  848. );
  849. }
  850. return (
  851. <View
  852. style={{
  853. marginTop: 20,
  854. flex: 1,
  855. justifyContent: "center",
  856. alignItems: "center"
  857. }}
  858. >
  859. <View
  860. style={{
  861. width: "90%",
  862. height: view_height,
  863. flexDirection: "column"
  864. }}
  865. >
  866. <View
  867. style={{
  868. flex: 0.5,
  869. justifyContent: "center",
  870. alignItems: "center",
  871. flexDirection: "row"
  872. }}
  873. >
  874. <View
  875. style={{
  876. flex: 0.1,
  877. height: 14,
  878. justifyContent: "flex-start",
  879. alignItems: "center",
  880. backgroundColor: "#01AFFE",
  881. borderRadius: 15
  882. }}
  883. />
  884. <View
  885. style={{
  886. flex: 0.1
  887. }}
  888. />
  889. <Text
  890. style={{
  891. flex: 11,
  892. fontSize: 18,
  893. fontWeight: "bold",
  894. color: "#3E455B"
  895. }}
  896. >
  897. {data.title}
  898. </Text>
  899. </View>
  900. {text_z}
  901. <View
  902. style={{
  903. flex: 3
  904. }}
  905. >
  906. <FlatList
  907. style={{
  908. flex: 1
  909. }}
  910. ItemSeparatorComponent={() => (
  911. <View
  912. style={{
  913. width: 10
  914. }}
  915. />
  916. )}
  917. showsHorizontalScrollIndicator={false}
  918. keyExtractor={(item, index) => item.name.toString()}
  919. data={data.icon_item}
  920. horizontal={true}
  921. renderItem={({ item }) => {
  922. //判断是否需要遮盖层(观看记录)
  923. if (data.mask) {
  924. zhezhao = [];
  925. zhezhao.push(
  926. <View
  927. key={item.name}
  928. style={{
  929. flex: 1,
  930. width: "100%",
  931. flexDirection: "column"
  932. }}
  933. >
  934. <View
  935. style={{
  936. flex: 2
  937. }}
  938. />
  939. <View
  940. style={{
  941. flex: 1,
  942. backgroundColor: "#344563",
  943. width: "100%",
  944. borderBottomLeftRadius: 15,
  945. borderBottomRightRadius: 15,
  946. flexDirection: "row"
  947. }}
  948. >
  949. <View
  950. style={{
  951. flex: 0.1
  952. }}
  953. />
  954. <View
  955. style={{
  956. flex: 1
  957. }}
  958. >
  959. <Text
  960. style={{
  961. flex: 1,
  962. color: "red",
  963. textAlign: "left"
  964. }}
  965. >
  966. {item.last_time + ":"}
  967. </Text>
  968. <Text
  969. style={{
  970. flex: 1,
  971. color: "red",
  972. textAlign: "left"
  973. }}
  974. >
  975. {item.curriculum_name}
  976. </Text>
  977. </View>
  978. </View>
  979. </View>
  980. );
  981. }
  982. return (
  983. <TouchableOpacity
  984. style={{
  985. flex: 1,
  986. height: "100%",
  987. width: this.getWindowWidth() * 0.22
  988. }}
  989. onPress={() => {
  990. alert(item.name);
  991. }}
  992. activeOpacity={1}
  993. >
  994. <View
  995. style={{
  996. flex: 1,
  997. height: "100%",
  998. width: "100%",
  999. justifyContent: "center",
  1000. alignItems: "center"
  1001. }}
  1002. >
  1003. <View
  1004. style={{
  1005. flex: 5,
  1006. height: "100%",
  1007. width: "100%",
  1008. justifyContent: "center",
  1009. alignItems: "center"
  1010. }}
  1011. >
  1012. <ImageBackground
  1013. source={{
  1014. uri: item.icon
  1015. }}
  1016. style={{
  1017. height: "100%",
  1018. width: "100%",
  1019. justifyContent: "center",
  1020. alignItems: "center"
  1021. }}
  1022. imageStyle={{
  1023. borderRadius: 20
  1024. }}
  1025. >
  1026. {zhezhao}
  1027. </ImageBackground>
  1028. </View>
  1029. <Text
  1030. style={{
  1031. justifyContent: "center",
  1032. alignItems: "center",
  1033. flex: 1,
  1034. fontSize: 12
  1035. }}
  1036. >
  1037. {item.name}
  1038. </Text>
  1039. </View>
  1040. </TouchableOpacity>
  1041. );
  1042. }}
  1043. />
  1044. </View>
  1045. </View>
  1046. </View>
  1047. );
  1048. break;
  1049. case 5:
  1050. break;
  1051. case 6:
  1052. break;
  1053. case 7:
  1054. break;
  1055. case 8:
  1056. break;
  1057. }
  1058. }
  1059. }
  1060. const styles = StyleSheet.create({
  1061. title_text: {
  1062. justifyContent: "center",
  1063. alignItems: "center",
  1064. color: "red",
  1065. fontSize: 30,
  1066. textAlign: "center",
  1067. marginTop: 30,
  1068. marginBottom: 50
  1069. }
  1070. });