ソースを参照

调试个人中心

Limengbo 5 年 前
コミット
8892b92a2f

ファイルの差分が大きいため隠しています
+ 73 - 96
android/app/src/main/assets/index.android.bundle


+ 1 - 1
pages/CourseDetails.js

@@ -41,7 +41,7 @@ export default class CourseDetails extends Component {
     fullStyle: {},
     lefts: 0,
     courseList: {},
-    wareList: {},
+    wareList: [],
     uri: 'http://chimee.org/vod/1.mp4'
   }
   render() {

+ 1 - 1
pages/components/CourseListRow.js

@@ -27,7 +27,7 @@ export default class CourseListRow extends Component {
             flex: 1,
             height: 200,
           }}>
-            <ScrollRow itemWidth={106} itemHeight={150} data={this.props.wareList} type={ true } changeUri={ this.props.changeUri }/>
+            <ScrollRow itemWidth={106} itemHeight={150} data={this.props.wareList} type={ true } changeUri={ this.props.changeUri } courseId={ this.props.courseId }/>
           </View>
       </View>
     );

+ 13 - 2
pages/components/ScrollRow.js

@@ -17,6 +17,7 @@ import {
 } from "react-native";
 import BasePage from '../BasePage'
 import Dimensions from '../utils/dimensions'
+import courseDetails from '../services/courseDetails'
 
 export default class ScrollRow extends Component {
 
@@ -45,7 +46,7 @@ export default class ScrollRow extends Component {
                     alignItems: 'center',
                     marginLeft: 9,
                 }}
-                onPress={() => this.playOrGoback(courseId, item.playUrl)}
+                onPress={() => this.playOrGoback(courseId, item.playUrl, item)}
                 activeOpacity={1}
             >
                 <View style={{
@@ -87,9 +88,19 @@ export default class ScrollRow extends Component {
             </TouchableOpacity>
         )
     }
-    playOrGoback(courseId, playUrl) {
+    playOrGoback(courseId, playUrl, item) {
         if (this.props.type) {
             this.props.changeUri(playUrl)
+            courseDetails.playLog({
+                "title": item.title,
+                "url": item.playUrl,
+                courseId,
+                "courseWareId": item.id,
+                "playStopTime": "",
+                "type": "LIBRARY",
+                "platFormType": "MOBILE"
+            }).then( res => console.log('添加播放记录', res))
+            .catch( error => console.log(error))
         } else {
             this.props.nav('CourseDetails', {courseId})
         }

+ 69 - 63
pages/services/courseDetails.js

@@ -18,85 +18,91 @@ export default class CourseDetails {
     //   pageNo: '',
     //   pageSize: ''
     // }).get();
-    // return request(`http://ott80test-base.yifangjiaoyu.cn/mobile/posts?columnId=${columnId}`, {
-    //   method: "get"
-    // })
-    return fetch(`http://ott80test-base.yifangjiaoyu.cn/mobile/posts?columnId=${columnId}`,{
-      method:"GET",
-      headers:{
-        "Accept": "application/json",
-        "Content-Type": "application/json",
-        "uid": ""
-      }
+    return request(`http://ott80test-base.yifangjiaoyu.cn/mobile/posts?columnId=${columnId}`, {
+      method: "get",
     })
-    .then((response)=>response.json())
+    // return fetch(`http://ott80test-base.yifangjiaoyu.cn/mobile/posts?columnId=${columnId}`,{
+    //   method:"GET",
+    //   headers:{
+    //     "Accept": "application/json",
+    //     "Content-Type": "application/json",
+    //     "uid": "c2e13090a563447c8744a8c03171d1db"
+    //   }
+    // })
+    // .then((response)=>response.json())
   }
   // 收藏
   static setFavorites(data) {
-    // return request(`http://ott80test-base.yifangjiaoyu.cn/mobile/favorites`, {
-    //   method:"post",
-    //   body: data,
-    // })
-    return fetch(`http://ott80test-base.yifangjiaoyu.cn/mobile/favorites`,{
-      method:"POST",
-      headers:{
-        "Accept": "application/json",
-        "Content-Type": "application/json",
-        "uid": ""
-      },
-      body: JSON.stringify(data),
+    return request(`http://ott80test-base.yifangjiaoyu.cn/mobile/favorites`, {
+      method:"post",
+      body: data,
     })
-    .then((response)=>response.json())
+    // return fetch(`http://ott80test-base.yifangjiaoyu.cn/mobile/favorites`,{
+    //   method:"POST",
+    //   headers:{
+    //     "Accept": "application/json",
+    //     "Content-Type": "application/json",
+    //     "uid": "c2e13090a563447c8744a8c03171d1db"
+    //   },
+    //   body: JSON.stringify(data),
+    // })
+    // .then((response)=>response.json())
   }
   // 获取是否收藏
   static getisFavorites(data) {
-    // return request(`http://ott80test-base.yifangjiaoyu.cn/mobile/favorites/isFavorites`, {
-    //   method:"post",
-    //   body: data,
-    // })
-    return fetch(`http://ott80test-base.yifangjiaoyu.cn/mobile/favorites/isFavorites`,{
-      method:"POST",
-      headers:{
-        "Accept": "application/json",
-        "Content-Type": "application/json",
-        "uid": ""
-      },
-      body: JSON.stringify(data),
+    return request(`http://ott80test-base.yifangjiaoyu.cn/mobile/favorites/isFavorites`, {
+      method:"post",
+      body: data,
     })
-    .then((response)=>response.json())
+    // return fetch(`http://ott80test-base.yifangjiaoyu.cn/mobile/favorites/isFavorites`,{
+    //   method:"POST",
+    //   headers:{
+    //     "Accept": "application/json",
+    //     "Content-Type": "application/json",
+    //     "uid": "c2e13090a563447c8744a8c03171d1db"
+    //   },
+    //   body: JSON.stringify(data),
+    // })
+    // .then((response)=>response.json())
   }
   // 写评论 
   static addCommentList(data) {
-    // return request(`http://ott80test-base.yifangjiaoyu.cn/mobile/posts`, {
-    //   method:"post",
-    //   body: data,
-    // })
-    return fetch(`http://ott80test-base.yifangjiaoyu.cn/mobile/posts`,{
-      method:"POST",
-      headers:{
-        "Accept": "application/json",
-        "Content-Type": "application/json",
-        "uid": ""
-      },
-      body: JSON.stringify(data),
+    return request(`http://ott80test-base.yifangjiaoyu.cn/mobile/posts`, {
+      method:"post",
+      body: data,
     })
-    .then((response)=>response.json())
+    // return fetch(`http://ott80test-base.yifangjiaoyu.cn/mobile/posts`,{
+    //   method:"POST",
+    //   headers:{
+    //     "Accept": "application/json",
+    //     "Content-Type": "application/json",
+    //     "uid": "c2e13090a563447c8744a8c03171d1db"
+    //   },
+    //   body: JSON.stringify(data),
+    // })
+    // .then((response)=>response.json())
   }
-  // 输入评论
+  // 输入回复
   static addReplyList(data) {
-    // return request(`http://ott80test-base.yifangjiaoyu.cn/mobile/posts/reply`, {
-    //   method:"post",
-    //   body: data,
+    return request(`http://ott80test-base.yifangjiaoyu.cn/mobile/posts/reply`, {
+      method:"post",
+      body: data,
+    })
+    // return fetch(`http://ott80test-base.yifangjiaoyu.cn/mobile/posts/reply`,{
+    //   method:"POST",
+    //   headers:{
+    //     "Accept": "application/json",
+    //     "Content-Type": "application/json",
+    //     "uid": "c2e13090a563447c8744a8c03171d1db"
+    //   },
+    //   body: JSON.stringify(data),
     // })
-    return fetch(`http://ott80test-base.yifangjiaoyu.cn/mobile/posts/reply`,{
-      method:"POST",
-      headers:{
-        "Accept": "application/json",
-        "Content-Type": "application/json",
-        "uid": ""
-      },
-      body: JSON.stringify(data),
+    // .then((response)=>response.json())
+  }
+  static playLog(data) {
+    return request(`http://ott80test-base.yifangjiaoyu.cn/mobile/playLog`, {
+      method:"post",
+      body: data,
     })
-    .then((response)=>response.json())
   }
 }

+ 6 - 0
pages/services/user.js

@@ -7,4 +7,10 @@ export default class user {
     console.log('opts',opts);
     return request(APIConfig.getUserUrl(``), opts);
   }
+  // 个人中心
+  static userMember() {
+    return request(`http://ott80test-base.yifangjiaoyu.cn/mobile/user/member`, {
+      method: 'get'
+    });
+  }
 }

+ 42 - 34
pages/userCenter.js

@@ -23,14 +23,31 @@ 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'
 
 export default class userCenter extends BasePage {
+    componentDidMount() {
+        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
+            })
+        });
+    }
     state = {
         nickName: "初始昵称",
-        user: {
-            nickName: '啊啊啊',
-            avatar: 'https://gss2.bdstatic.com/-fo3dSag_xI4khGkpoWK1HF6hhy/baike/w%3D268%3Bg%3D0/sign=043fea1806f431adbcd2443f730dcb92/f636afc379310a550591d17ebd4543a983261086.jpg'
-        },
+        user: {},
         ifDiscount: true,
         isVIP: false,
         btnArr: [
@@ -43,31 +60,14 @@ export default class userCenter extends BasePage {
             { title: '12个月', originPrice: '499', price: '199', background: require('./images/shopBox/right.png') }
         ],
         discount: { title: '限时秒杀', icon: require('./images/shopBox/discount.png') },
-        courseSroll: [{
-            summary: 'Title Text', key: 'item1', icon:
-                "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",
-        }, {
-            summary: 'Title Text', key: 'item2', icon:
-                "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",
-        }, {
-            summary: 'Title Text', key: 'item3', icon:
-                "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",
-        }, {
-            summary: 'Title Text', key: 'item4', icon:
-                "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",
-        }, {
-            title: 'Title Text', key: 'item5', icon:
-                "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",
-        }, {
-            summary: 'Title Text', key: 'item6', icon:
-                "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",
-        }]
-
+        favoritesList: [],
+        playLogList: [],
+        vip: false
 
     };
     renderBtn = (item, index) => {
         return (
-            <TouchableOpacity key={index} onPress={() => this.goTo(`${item.goTo}`)}>
+            <TouchableOpacity key={index} onPress={() => this.goTo(`${item.goTo}`)} style={{display: 'flex', justifyContent: 'space-between'}}>
                 <View style={styles.btnItem}>
                     <Image
                         source={item.icon}
@@ -130,11 +130,19 @@ export default class userCenter extends BasePage {
                             <View style={styles.userRight}>
                                 <View style={styles.userName}>
                                     <Text style={styles.userNameText}>{this.state.user.nickName}</Text>
-                                    <Image style={styles.vipTag} source={require('./images/common/vip.png')}></Image>
-                                </View>
-                                <View style={styles.userName}>
-                                    <Text style={styles.vipSologan}>开通vip</Text>
+                                    {
+                                        this.state.vip ? 
+                                        <Image style={styles.vipTag} source={require('./images/common/vip.png')}></Image>: 
+                                         null
+                                    }
                                 </View>
+                                {
+                                    this.state.vip ? 
+                                    null : 
+                                    <View style={styles.userName}>
+                                        <Text style={styles.vipSologan}>开通vip</Text>
+                                    </View>
+                                }
                             </View>
                         </View>
                         <View style={styles.btnBoxWrapper}>
@@ -151,11 +159,11 @@ export default class userCenter extends BasePage {
                 </View>
                 <View style={styles.recordSection}>
                     <TopicTitle title={'观看记录'} ifTubeShow={true} />
-                    <ScrollRow itemWidth={106} itemHeight={153} data={this.state.courseSroll} />
+                    <ScrollRow itemWidth={106} itemHeight={153} data={this.state.playLogList} />
                 </View>
                 <View style={styles.collectSection}>
-                    <TopicTitle title={'我的课程'} ifTubeShow={true} />
-                    <ScrollRow itemWidth={106} itemHeight={153} data={this.state.courseSroll} />
+                    <TopicTitle title={'我的收藏'} ifTubeShow={true} />
+                    <ScrollRow itemWidth={106} itemHeight={150} data={this.state.favoritesList} />
                 </View>
             </ScrollView>
         )
@@ -220,7 +228,6 @@ const styles = StyleSheet.create({
         flexDirection: 'row',
     },
     btnItem: {
-        width: 48,
         height: '100%',
         flexDirection: 'column',
         justifyContent: 'center',
@@ -247,7 +254,8 @@ const styles = StyleSheet.create({
     },
     collectSection: {
         width: Dimensions.width,
-        height: 235,
+        height: 255,
+        marginBottom: 20
         // backgroundColor: 'yellow'
     },
 

+ 14 - 13
pages/utils/request.js

@@ -87,26 +87,27 @@ const request = async (url, options) => {
     // const token = await storage.load({
     //     key: 'token'
     // });
+    options.headers = {
+      Accept: "application/json",
+      "Content-Type": "application/json",
+      uid: "c2e13090a563447c8744a8c03171d1db"
+      // 'token': token?  token : null
+    };
     if (
       method === "POST" ||
       method === "PATCH" ||
       method === "DELETE" ||
       method === "PUT"
     ) {
-      options.headers = {
-        Accept: "application/json",
-        "Content-Type": "application/json",
-        uid: "c2e13090a563447c8744a8c03171d1db"
-        // 'token': token?  token : null
-      };
       options.body = JSON.stringify(options.body);
-    } else {
-      options.headers = {
-        token: await storage.load({
-          key: "token"
-        })
-      };
-    }
+    } 
+    // else {
+    //   options.headers = {
+    //     // token: await storage.load({
+    //     //   key: "token"
+    //     // })
+    //   };
+    // }
   }
   console.log("options", options);
   return fetch(url, options)