userCenter.js 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. /*
  2. * 个人中心页面
  3. */
  4. import React, { Component } from "react";
  5. import {
  6. Platform,
  7. StyleSheet,
  8. Text,
  9. View,
  10. Image,
  11. TouchableOpacity,
  12. ImageBackground,
  13. Button,
  14. StatusBar,
  15. Modal,
  16. TouchableHighlight,
  17. DeviceEventEmitter,
  18. ScrollView
  19. } from "react-native";
  20. import BasePage from "./BasePage";
  21. import Dimensions from './utils/dimensions';
  22. import ShopBox from "./components/ShopBox";
  23. import TopicTitle from './components/TopicTitle';
  24. import ScrollRow from './components/ScrollRow';
  25. import CourseTitle from "./components/CourseTitle";
  26. export default class userCenter extends BasePage {
  27. state = {
  28. nickName: "初始昵称",
  29. user: {
  30. nickName: '啊啊啊',
  31. avatar: 'https://gss2.bdstatic.com/-fo3dSag_xI4khGkpoWK1HF6hhy/baike/w%3D268%3Bg%3D0/sign=043fea1806f431adbcd2443f730dcb92/f636afc379310a550591d17ebd4543a983261086.jpg'
  32. },
  33. ifDiscount: true,
  34. isVIP: false,
  35. btnArr: [
  36. { title: '订单', icon: require('./images/userCenter/order.png'), goTo: 'Order' },
  37. { title: '抵用券', icon: require('./images/userCenter/discount.png'), goTo: 'Ticket' },
  38. { title: '客服', icon: require('./images/userCenter/service.png'), goTo: 'Order' },
  39. ],
  40. shopData: [
  41. { title: '1个月', originPrice: '199', price: '49', background: require('./images/shopBox/left.png') },
  42. { title: '12个月', originPrice: '499', price: '199', background: require('./images/shopBox/right.png') }
  43. ],
  44. discount: { title: '限时秒杀', icon: require('./images/shopBox/discount.png') },
  45. courseSroll: [{
  46. summary: 'Title Text', key: 'item1', icon:
  47. "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",
  48. }, {
  49. summary: 'Title Text', key: 'item2', icon:
  50. "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",
  51. }, {
  52. summary: 'Title Text', key: 'item3', icon:
  53. "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",
  54. }, {
  55. summary: 'Title Text', key: 'item4', icon:
  56. "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",
  57. }, {
  58. title: 'Title Text', key: 'item5', icon:
  59. "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",
  60. }, {
  61. summary: 'Title Text', key: 'item6', icon:
  62. "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",
  63. }]
  64. };
  65. renderBtn = (item, index) => {
  66. return (
  67. <TouchableOpacity key={index} onPress={() => this.goTo(`${item.goTo}`)}>
  68. <View style={styles.btnItem}>
  69. <Image
  70. source={item.icon}
  71. style={styles.btnIcon}
  72. />
  73. <Text
  74. style={styles.btnTitle}
  75. >
  76. {item.title}
  77. </Text>
  78. </View>
  79. </TouchableOpacity>
  80. )
  81. }
  82. goBack() {
  83. //返回上一页
  84. this.props.navigation.goBack();
  85. }
  86. render() {
  87. return (
  88. <ScrollView style={{ height: 1100, overflow: 'scroll', backgroundColor: '#fff' }}>
  89. <View style={styles.topSection}>
  90. <ImageBackground
  91. source={
  92. require('./images/userCenter/top-bg.png')
  93. }
  94. style={{ width: '100%', height: 203 }}
  95. >
  96. <StatusBar
  97. backgroundColor={"transparent"}
  98. barStyle={"dark-content"}
  99. // backgroundColor={"white"}
  100. translucent={true}
  101. hidden={false}
  102. />
  103. <View
  104. style={{
  105. height: 30,
  106. // backgroundColor: "white"
  107. marginTop: 20
  108. }}
  109. >
  110. <CourseTitle
  111. width={this.getWindowWidth()}
  112. title="个人中心"
  113. lefttype={2}
  114. righttype={2}
  115. textcolor={"#fff"}
  116. backPress={() => this.goBack()}
  117. // backgroundColor={"transparent"}
  118. // rightPress={this.showSharedDialog.bind(this)}
  119. />
  120. </View>
  121. <View style={styles.userInfo}>
  122. <TouchableOpacity onPress={() => this.goTo(`PersonalInfo`)}>
  123. <Image style={styles.userAvatar} source={{ uri: this.state.user.avatar }} />
  124. </TouchableOpacity>
  125. <View style={styles.userRight}>
  126. <View style={styles.userName}>
  127. <Text style={styles.userNameText}>{this.state.user.nickName}</Text>
  128. <Image style={styles.vipTag} source={require('./images/common/vip.png')}></Image>
  129. </View>
  130. <View style={styles.userName}>
  131. <Text style={styles.vipSologan}>开通vip</Text>
  132. </View>
  133. </View>
  134. </View>
  135. <View style={styles.btnBoxWrapper}>
  136. <View style={styles.btnBox}>
  137. {this.state.btnArr.map((item, index) => this.renderBtn(item, index))}
  138. </View>
  139. </View>
  140. </ImageBackground>
  141. </View>
  142. <View style={styles.discountSection}>
  143. <ShopBox data={this.state.shopData} discount={this.state.discount} nav={this.props.navigation.navigate} />
  144. </View>
  145. <View style={styles.recordSection}>
  146. <TopicTitle title={'观看记录'} ifTubeShow={true} />
  147. <ScrollRow itemWidth={106} itemHeight={153} data={this.state.courseSroll} />
  148. </View>
  149. <View style={styles.collectSection}>
  150. <TopicTitle title={'我的课程'} ifTubeShow={true} />
  151. <ScrollRow itemWidth={106} itemHeight={153} data={this.state.courseSroll} />
  152. </View>
  153. </ScrollView>
  154. )
  155. }
  156. goTo(index) {
  157. this.toNextPage(index)
  158. }
  159. }
  160. const styles = StyleSheet.create({
  161. topSection: {
  162. height: 250,
  163. width: Dimensions.width,
  164. // backgroundColor: 'red'
  165. },
  166. userInfo: {
  167. width: Dimensions.width,
  168. height: 70,
  169. flexDirection: 'row',
  170. justifyContent: 'flex-start',
  171. alignItems: 'center',
  172. },
  173. userAvatar: {
  174. width: 67,
  175. height: 67,
  176. borderRadius: 55,
  177. marginHorizontal: 12
  178. },
  179. userRight: {
  180. flexDirection: 'column',
  181. },
  182. userName: {
  183. flexDirection: 'row',
  184. alignItems: 'center',
  185. },
  186. userNameText: {
  187. fontSize: 18,
  188. color: '#fff',
  189. fontWeight: '500',
  190. marginRight: 9
  191. },
  192. vipSologan: {
  193. fontSize: 14,
  194. color: '#fff',
  195. },
  196. btnBoxWrapper: {
  197. width: Dimensions.width,
  198. alignItems: 'center',
  199. marginTop: 16
  200. },
  201. btnBox: {
  202. width: Dimensions.width * 343 / 375,
  203. height: 100,
  204. borderRadius: 10,
  205. shadowColor: '#000',
  206. // shadowOffset: 1,
  207. shadowOpacity: 2,
  208. shadowRadius: 5,
  209. elevation: 4,
  210. backgroundColor: '#fff',
  211. justifyContent: 'space-around',
  212. flexDirection: 'row',
  213. },
  214. btnItem: {
  215. width: 48,
  216. height: '100%',
  217. flexDirection: 'column',
  218. justifyContent: 'center',
  219. alignItems: 'center'
  220. },
  221. btnIcon: {
  222. width: 36,
  223. height: 24,
  224. marginBottom: 7
  225. },
  226. btnTitle: {
  227. color: '#3f3f3f',
  228. fontSize: 16,
  229. },
  230. discountSection: {
  231. width: Dimensions.width,
  232. // height: 242,
  233. // backgroundColor: 'green'
  234. },
  235. recordSection: {
  236. width: Dimensions.width,
  237. height: 235,
  238. // backgroundColor: 'blue'
  239. },
  240. collectSection: {
  241. width: Dimensions.width,
  242. height: 235,
  243. // backgroundColor: 'yellow'
  244. },
  245. })