/* * 个人中心页面 */ import React, { Component } from 'react'; import { Platform, StyleSheet, Text, View, Image, TouchableOpacity, ImageBackground, Button, StatusBar, Modal, TouchableHighlight, DeviceEventEmitter, ScrollView, BackHandler } from 'react-native'; import BasePage from './BasePage'; import Dimensions from './utils/dimensions'; import ShopBox from './components/ShopBox'; import TopicTitle from './components/TopicTitle'; import ScrollRow from './components/ScrollRow'; import CourseTitle from './components/CourseTitle'; import user from './services/user'; import commonUtil from './utils/commonutil'; import http_showcase from '../pages/services/showcase'; export default class userCenter extends BasePage { componentDidMount() { this.getUCENTER_RECOMMEND(); //触发更新 this.refreshSubScription = DeviceEventEmitter.addListener('infoback',() =>{ user.userMember().then((res) => { console.log('个人列表', res); // 收藏 const favoritesList = res.data.favoritesList; //观看记录 const playLogList = res.data.playLogList; // 用户消息 const user = res.data.user; // VIP const vip = res.data.vip; this.setState({ favoritesList, playLogList, user, vip }); }); }); BackHandler.addEventListener('hardwareBackPress', this.onBackAndroid); DeviceEventEmitter.emit('infoback'); } componentWillUnmount() { this.refreshSubScription.remove(); BackHandler.removeEventListener('hardwareBackPress', this.onBackAndroid); } state = { nickName: '初始昵称', user: {}, ifDiscount: true, isVIP: false, btnArr: [ { title: '订单', icon: require('./images/userCenter/order.png'), goTo: 'Order' }, { title: '抵用券', icon: require('./images/userCenter/discount.png'), goTo: 'Ticket' }, { title: '客服', icon: require('./images/userCenter/service.png'), goTo: 'Phone' } ], shopData: [ { title: '1个月', originPrice: '199', price: '49', background: require('./images/shopBox/left.png') }, { title: '12个月', originPrice: '499', price: '199', background: require('./images/shopBox/right.png') } ], discount: { title: '限时秒杀', icon: { uri: 'null' } }, favoritesList: [], playLogList: [], vip: false }; renderBtn = (item, index) => { return ( this.goTo(`${item.goTo}`)} style={{ display: 'flex', justifyContent: 'space-between' }} > {item.title} ); }; goBack() { DeviceEventEmitter.emit('indexInfo'); //返回上一页 this.props.navigation.goBack(); } getUCENTER_RECOMMEND() { http_showcase.getUCENTER_RECOMMEND().then((res) => { console.log('===================================='); console.log('res', res.data[0].boothContent); console.log('===================================='); this.setState({ discount: { title: res.data[0].title, icon: { uri: res.data[0].boothContent } } }); }); } render() { return ( ); } goTo(index) { if (index === 'Phone') { commonUtil.callPhone('.......'); } else { this.toNextPage(index); } } onBackAndroid = () => { this.goBack(); return true; }; } const styles = StyleSheet.create({ topSection: { height: 250, width: Dimensions.width // backgroundColor: 'red' }, userInfo: { width: Dimensions.width, height: 70, flexDirection: 'row', justifyContent: 'flex-start', alignItems: 'center' }, userAvatar: { width: 67, height: 67, borderRadius: 55, marginHorizontal: 12 }, userRight: { flexDirection: 'column' }, userName: { flexDirection: 'row', alignItems: 'center' }, userNameText: { fontSize: 18, color: '#fff', fontWeight: '500', marginRight: 9 }, vipSologan: { fontSize: 14, color: '#fff' }, btnBoxWrapper: { width: Dimensions.width, alignItems: 'center', marginTop: 16 }, btnBox: { width: Dimensions.width * 343 / 375, height: 100, borderRadius: 10, shadowColor: '#000', // shadowOffset: 1, shadowOpacity: 2, shadowRadius: 5, elevation: 4, backgroundColor: '#fff', justifyContent: 'space-around', flexDirection: 'row' }, btnItem: { height: '100%', flexDirection: 'column', justifyContent: 'center', alignItems: 'center' }, btnIcon: { width: 36, height: 24, marginBottom: 7 }, btnTitle: { color: '#3f3f3f', fontSize: 16 }, discountSection: { width: Dimensions.width // height: 242, // backgroundColor: 'green' }, recordSection: { width: Dimensions.width, height: 235 // backgroundColor: 'blue' }, collectSection: { width: Dimensions.width, height: 255, marginBottom: 20 // backgroundColor: 'yellow' } });