Browse Source

Merge branch 'master' of http://gogs.efunbox.cn/Rorschach/efunbox-mobile-8

zhangmengjie 5 năm trước cách đây
mục cha
commit
6938f186df

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 110 - 7
android/app/src/main/assets/index.android.bundle


+ 2 - 1
pages/CourseDetails.js

@@ -33,7 +33,8 @@ export default class CourseDetails extends Component {
       const wareList = res.data.wareList;
       this.setState({
         courseList,
-        wareList
+        wareList,
+        uri: wareList[0].playUrl
       })
     }).catch(err => {
       console.log(err)

+ 1 - 0
pages/MainActivity.js

@@ -30,6 +30,7 @@ const instructions = Platform.select({
 
 type Props = {};
 export default class MainActivity extends BasePage {
+
   render() {
     return (
       <View style={styles.container}>

+ 27 - 24
pages/PersonalInfo.js

@@ -8,26 +8,28 @@
 
 import React, { Component } from 'react';
 import {
-	StyleSheet,
-	Text,
-	View,
-	Image,
-	TouchableOpacity,
-	ImageBackground,
-	ToastAndroid,
-	BackHandler,
-	StatusBar
-} from 'react-native';
-import BasePage from './BasePage';
-import CourseTitle from '../pages/components/CourseTitle';
-import ChosePhoto from '../pages/components/ChosePhoto';
-import RegionModal from '../pages/components/RegionModal';
-import BirthdayModal from '../pages/components/BirthdayModal';
-import GradeSelectionModal from '../pages/components/GradeSelectionModal';
-import PersonalInfoDialog from '../pages/components/PersonalInfoDialog';
-import http_user from './services/user';
-import wechat from './utils/wechat';
-import commonutil from './utils/commonutil';
+  StyleSheet,
+  Text,
+  View,
+  Image,
+  TouchableOpacity,
+  ImageBackground,
+  ToastAndroid,
+  BackHandler,
+	StatusBar,
+	DeviceEventEmitter
+} from "react-native";
+import BasePage from "./BasePage";
+import CourseTitle from "../pages/components/CourseTitle";
+import ChosePhoto from "../pages/components/ChosePhoto";
+import RegionModal from "../pages/components/RegionModal";
+import BirthdayModal from "../pages/components/BirthdayModal";
+import GradeSelectionModal from "../pages/components/GradeSelectionModal";
+import PersonalInfoDialog from "../pages/components/PersonalInfoDialog";
+import http_user from "./services/user";
+import wechat from "./utils/wechat";
+import commonutil from "./utils/commonutil";
+
 type Props = {};
 
 export default class PersonalInfo extends BasePage {
@@ -955,11 +957,12 @@ export default class PersonalInfo extends BasePage {
 			// ToastAndroid.show('修改失败', ToastAndroid.SHORT);
 		}
 	}
+  personinfoback() {
+		// this.props.navigation.state.params.infoback();
+		DeviceEventEmitter.emit('infoback')
+    this.props.navigation.goBack();
+  }
 
-	personinfoback() {
-		this.props.navigation.state.params.infoback();
-		this.props.navigation.goBack();
-	}
 
 	formaterDate(date) {
 		var date = new Date(date);

+ 17 - 22
pages/components/Header.js

@@ -39,7 +39,6 @@ const styles = StyleSheet.create({
     flexDirection: "column"
   },
   userName:{
-    width: 320,
     fontSize: 18,
     fontWeight: "bold",
     textAlign: "left",
@@ -51,11 +50,11 @@ const styles = StyleSheet.create({
     alignItems: "center"
   },
   flowerIcon:{
+    marginLeft: 10,
     alignItems: "center",
     justifyContent: "center",
-    width: 12,
-    height: 12,
-    backgroundColor: "blue"
+    width: 27,
+    height: 14
   },
   flowerNumber:{
     textAlignVertical: "center",
@@ -71,34 +70,30 @@ export default class Header extends Component<Props> {
           style={styles.wrapper}
         >
           <Image
-            source={{
+            source={this.props.uri ? {
               uri: this.props.uri
-            }}
+            } : require('../images/userInfo/default_photo.png')}
             style={styles.avatar}
           />
           <View
             style={styles.leftBox}
           >
-            <Text
-              style={styles.userName}
-            >
-              {this.props.username}
-            </Text>
-            <View
-              style={styles.leftBottomRow}
-            >
-              <Image
-                // source={{
-                //   uri: this.props.uri
-                // }}
-                style={styles.flowerIcon}
-              />
+            <View style={styles.leftBottomRow}>
               <Text
-                style={styles.flowerNumber}
+                style={styles.userName}
               >
-                {this.props.flowerNumber}
+                {this.props.username}
               </Text>
+              <Image
+                source={require("../images/common/vip.png")}
+                style={styles.flowerIcon}
+              />
             </View>
+            <Text
+              style={styles.flowerNumber}
+            >
+              {this.props.isVip ? '' : '开通VIP'}
+            </Text>
           </View>
         </View>
       </TouchableOpacity>

+ 14 - 5
pages/components/MainPage.js

@@ -39,7 +39,7 @@ export default class MainPage extends BasePage {
 		}
 	}
 
-	updateRender(index) {
+	 updateRender(index) {
 		// LibraryUrl.getIndex(index).success(res => {
 
 		// }).fail(() => {
@@ -92,7 +92,10 @@ export default class MainPage extends BasePage {
 			{ title: '小学', param: 'PRIMARY_SCHOOL' },
 			{ title: '中学', param: 'MIDDLE_SCHOOL' }
 		],
-		scheduleWeek: '1'
+		scheduleWeek: '1',
+		username: '游客',
+		avatar: '',
+		isVip: false
 	};
 
 	renderBtn = (item, index) => {
@@ -183,11 +186,11 @@ export default class MainPage extends BasePage {
 		return (
 			<View>
 				<Header
-					uri="https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1295208965,3056573814&amp;fm=26&amp;gp=0.jpg"
+					uri={this.state.avatar}
 					width={400}
 					height={150}
-					username="卡通笨笨熊"
-					flowerNumber="123234"
+					username= {this.state.username}
+					isVip={this.state.isVip}
 					onPress={() => this.toNextPage('userCenter')}
 				/>
 				{/* 搜索区域 */}
@@ -471,6 +474,12 @@ export default class MainPage extends BasePage {
 				console.log('=====MainPage获取本地用户信息============');
 				console.log(commonutil.mapToJson(this.state.file_user_data));
 				var ageGroup = this.state.file_user_data.get('ageGroup');
+				const username = this.state.file_user_data.get('nickName');
+				const avatar =  this.state.file_user_data.get('avatar');
+				this.setState({
+					username,
+					avatar
+				})
 				var ageindex = 0;
 				if (ageGroup === 'PRESCHOOL') {
 					ageindex = 0;

+ 24 - 44
pages/userCenter.js

@@ -27,24 +27,30 @@ import user from "./services/user";
 
 export default class userCenter extends BasePage {
   componentDidMount() {
-    console.log(4444);
-    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
+    //触发更新
+    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
+        });
       });
-    });
+    })
+    DeviceEventEmitter.emit('infoback')
+  }
+  componentWillUnmount(){
+    this.refreshSubScription.remove();
   }
   state = {
     nickName: "初始昵称",
@@ -144,7 +150,7 @@ export default class userCenter extends BasePage {
               />
             </View>     
             <View style={styles.userInfo}>
-              <TouchableOpacity onPress={this.setInfo.bind(this)}>
+              <TouchableOpacity onPress={() => this.goTo(`PersonalInfo`)}>
                 <Image
                   style={styles.userAvatar}
                   source={{ uri: this.state.user.avatar }}
@@ -208,32 +214,6 @@ export default class userCenter extends BasePage {
   goTo(index) {
     this.toNextPage(index);
   }
-
-  setInfo() {
-    this.props.navigation.navigate("PersonalInfo", {
-      infoback: this.infoback.bind(this)
-    });
-  }
-
-  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
-        });
-    });
-  }
 }
 
 const styles = StyleSheet.create({