userCenter.js 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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. <Image style={styles.userAvatar} source={{ uri: this.state.user.avatar }} />
  93. <View style={styles.userRight}>
  94. <View style={styles.userName}>
  95. <Text style={styles.userNameText}>{this.state.user.nickName}</Text>
  96. <Image style={styles.vipTag} source={require('./images/common/vip.png')}></Image>
  97. </View>
  98. <View style={styles.userName}>
  99. <Text style={styles.vipSologan}>开通vip</Text>
  100. </View>
  101. </View>
  102. </View>
  103. <View style={styles.btnBoxWrapper}>
  104. <View style={styles.btnBox}>
  105. {this.state.btnArr.map((item, index) => this.renderBtn(item, index))}
  106. </View>
  107. </View>
  108. </ImageBackground>
  109. </View>
  110. <View style={styles.discountSection}>
  111. <ShopBox data={this.state.shopData} discount={this.state.discount} />
  112. </View>
  113. <View style={styles.recordSection}>
  114. <TopicTitle title={'观看记录'} ifTubeShow={true} />
  115. <ScrollRow itemWidth={106} itemHeight={153} data={this.state.courseSroll} />
  116. </View>
  117. <View style={styles.collectSection}>
  118. <TopicTitle title={'我的课程'} ifTubeShow={true} />
  119. <ScrollRow itemWidth={106} itemHeight={153} data={this.state.courseSroll} />
  120. </View>
  121. </ScrollView>
  122. )
  123. }
  124. goTo(index){
  125. this.toNextPage(index)
  126. }
  127. }
  128. const styles = StyleSheet.create({
  129. topSection: {
  130. height: 250,
  131. width: Dimensions.width,
  132. // backgroundColor: 'red'
  133. },
  134. userInfo: {
  135. width: Dimensions.width,
  136. height: 70,
  137. flexDirection: 'row',
  138. justifyContent: 'flex-start',
  139. alignItems: 'center',
  140. },
  141. userAvatar: {
  142. width: 67,
  143. height: 67,
  144. borderRadius: 55,
  145. marginHorizontal: 12
  146. },
  147. userRight: {
  148. flexDirection: 'column',
  149. },
  150. userName: {
  151. flexDirection: 'row',
  152. alignItems: 'center',
  153. },
  154. userNameText: {
  155. fontSize: 18,
  156. color: '#fff',
  157. fontWeight: '500',
  158. marginRight: 9
  159. },
  160. vipSologan: {
  161. fontSize: 14,
  162. color: '#fff',
  163. },
  164. btnBoxWrapper: {
  165. width: Dimensions.width,
  166. alignItems: 'center',
  167. marginTop: 16
  168. },
  169. btnBox: {
  170. width: Dimensions.width * 343 / 375,
  171. height: 100,
  172. borderRadius: 10,
  173. shadowColor: '#000',
  174. // shadowOffset: 1,
  175. shadowOpacity: 2,
  176. shadowRadius: 5,
  177. elevation: 4,
  178. backgroundColor: '#fff',
  179. justifyContent: 'space-around',
  180. flexDirection: 'row',
  181. },
  182. btnItem: {
  183. width: 48,
  184. height: '100%',
  185. flexDirection: 'column',
  186. justifyContent: 'center',
  187. alignItems: 'center'
  188. },
  189. btnIcon: {
  190. width: 36,
  191. height: 24,
  192. marginBottom: 7
  193. },
  194. btnTitle: {
  195. color: '#3f3f3f',
  196. fontSize: 16,
  197. },
  198. discountSection: {
  199. width: Dimensions.width,
  200. // height: 242,
  201. // backgroundColor: 'green'
  202. },
  203. recordSection: {
  204. width: Dimensions.width,
  205. height: 235,
  206. // backgroundColor: 'blue'
  207. },
  208. collectSection: {
  209. width: Dimensions.width,
  210. height: 235,
  211. // backgroundColor: 'yellow'
  212. },
  213. })