userCenter.js 8.3 KB

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