소스 검색

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

zhangmengjie 5 년 전
부모
커밋
b5ae675659

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 73 - 73
android/app/src/main/assets/index.android.bundle


BIN
android/app/src/main/res/drawable-mdpi/pages_images_userinfo_default_photo.png


+ 4 - 4
package-lock.json

@@ -6281,7 +6281,7 @@
     },
     "opencollective": {
       "version": "1.0.3",
-      "resolved": "https://registry.npm.taobao.org/opencollective/download/opencollective-1.0.3.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fopencollective%2Fdownload%2Fopencollective-1.0.3.tgz",
+      "resolved": "https://registry.npm.taobao.org/opencollective/download/opencollective-1.0.3.tgz",
       "integrity": "sha1-ruY3K8KBRFg2kMPKja7PwSDdDvE=",
       "requires": {
         "babel-polyfill": "6.23.0",
@@ -6299,12 +6299,12 @@
         },
         "ansi-styles": {
           "version": "2.2.1",
-          "resolved": "https://registry.npm.taobao.org/ansi-styles/download/ansi-styles-2.2.1.tgz",
+          "resolved": "https://registry.npm.taobao.org/ansi-styles/download/ansi-styles-2.2.1.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fansi-styles%2Fdownload%2Fansi-styles-2.2.1.tgz",
           "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4="
         },
         "chalk": {
           "version": "1.1.3",
-          "resolved": "https://registry.npm.taobao.org/chalk/download/chalk-1.1.3.tgz",
+          "resolved": "https://registry.npm.taobao.org/chalk/download/chalk-1.1.3.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fchalk%2Fdownload%2Fchalk-1.1.3.tgz",
           "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=",
           "requires": {
             "ansi-styles": "^2.2.1",
@@ -6316,7 +6316,7 @@
         },
         "inquirer": {
           "version": "3.0.6",
-          "resolved": "https://registry.npm.taobao.org/inquirer/download/inquirer-3.0.6.tgz",
+          "resolved": "https://registry.npm.taobao.org/inquirer/download/inquirer-3.0.6.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Finquirer%2Fdownload%2Finquirer-3.0.6.tgz",
           "integrity": "sha1-4EqqnQW3o8ubD0B9BDdfBEcZA0c=",
           "requires": {
             "ansi-escapes": "^1.1.0",

+ 3 - 14
pages/CourseDetails.js

@@ -26,8 +26,8 @@ import courseDetails from './services/courseDetails'
 export default class CourseDetails extends Component {
   componentDidMount() {
     const { courseId } = this.props.navigation.state.params;
-    console.log(courseId)
-    courseDetails.getCourseDetails(courseId).success(res => {
+    console.log('id',courseId)
+    courseDetails.getCourseDetails(courseId).then(res => {
       console.log('列表',res.data)
       const courseList = res.data.course;
       const wareList = res.data.wareList;
@@ -36,23 +36,12 @@ export default class CourseDetails extends Component {
         wareList
       })
     });
-    courseDetails.getPostsList(courseId).success(res => {
-      console.log('评论列表', res.data)
-      const postsList = res.data.list;
-      console.log(postsList)
-      this.setState({
-        postsList,
-      })
-    }).fail(error => {
-      console.log('失败', error)
-    })
   }
   state = {
     fullStyle: {},
     lefts: 0,
     courseList: {},
-    wareList: {},
-    postsList: [],
+    wareList: [],
     uri: 'http://chimee.org/vod/1.mp4'
   }
   render() {

+ 22 - 10
pages/components/Comment.js

@@ -20,17 +20,27 @@ export default class Comment extends Component {
     };
   }
   componentWillReceiveProps(nextProps) {
-    console.log('--------', nextProps)
+    console.log('id--------', nextProps.courseId)
     // this.setState({
     //   postsList: nextProps.postsList
     // })
-    courseDetails.getPostsList(nextProps.columnId).success(res => {
+    // courseDetails.getPostsList(nextProps.columnId).success(res => {
+    //   const postsList = res.data.list;
+    //   console.log('==========', postsList)
+    //   this.setState({
+    //     postsList,
+    //   })
+    // }).fail(error => {
+    //   console.log('失败', error)
+    // })
+    courseDetails.getPostsList(nextProps.courseId).then(res => {
+      console.log('评论列表', res)
       const postsList = res.data.list;
-      console.log('==========', postsList)
+      console.log(postsList)
       this.setState({
         postsList,
       })
-    }).fail(error => {
+    }).catch(error => {
       console.log('失败', error)
     })
   }
@@ -135,14 +145,14 @@ export default class Comment extends Component {
       }).then(res => {
         console.log(res)
         if ( res.code == 200) {
-          courseDetails.getPostsList(columnId).success(res => {
+          courseDetails.getPostsList(columnId).then(res => {
             const postsList = res.data.list;
             this.setState({
               input: false,
               postsList,
               text: ''
             })
-          }).fail(error => {
+          }).catch(error => {
             console.log('失败', error)
           })
         }
@@ -154,7 +164,7 @@ export default class Comment extends Component {
       }).then(res => {
         console.log(res)
         if ( res.code == 200) {
-          courseDetails.getPostsList(columnId).success(res => {
+          courseDetails.getPostsList(columnId).then(res => {
             const postsList = res.data.list;
             console.log('==========', postsList)
             this.setState({
@@ -162,7 +172,7 @@ export default class Comment extends Component {
               postsList,
               text: ''
             })
-          }).fail(error => {
+          }).catch(error => {
             console.log('失败', error)
           })
         }
@@ -191,7 +201,7 @@ const styles = StyleSheet.create({
     alignItems: 'center',
   },
   font: {
-    fontSize: 24,
+    fontSize: 18,
     color: 'black',
     fontWeight: 'bold',
   },
@@ -233,7 +243,9 @@ const styles = StyleSheet.create({
   column: {
     display: 'flex',
     flexDirection: 'column',
-    backgroundColor: '#F3F6FF'
+    backgroundColor: '#F3F6FF',
+    borderColor: '#D8D8D8', 
+    borderBottomWidth: 1
   },
   color: {
     color: '#518AD1'

+ 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})
         }

+ 82 - 61
pages/services/courseDetails.js

@@ -1,87 +1,108 @@
 import APIConfig from './api.js';
-import efunRequest from '../utils/efunRequest'
+// import efunRequest from '../utils/efunRequest'
+import request from '../utils/request'
 
 export default class CourseDetails {
   // 获取课程详细信息
   static getCourseDetails(courseId) {
-    return efunRequest.getHttpRequest().url(`http://ott80testlibrary.yifangjiaoyu.cn/mobile/course/${courseId}`).get();
+    // return efunRequest.getHttpRequest().url(`http://ott80testlibrary.yifangjiaoyu.cn/mobile/course/${courseId}`).get();
+    return request(`http://ott80testlibrary.yifangjiaoyu.cn/mobile/course/${courseId}`)
   }
   // 获取评论列表
   static getPostsList(columnId) {
     console.log(columnId)
-    return efunRequest.getHttpRequest().url(`http://ott80test-base.yifangjiaoyu.cn/mobile/posts`).header({
-      uid: ''
-    }).params({
-      columnId,
-      pageNo: '',
-      pageSize: ''
-    }).get();
+    // return efunRequest.getHttpRequest().url(`http://ott80test-base.yifangjiaoyu.cn/mobile/posts`).header({
+    //   uid: ''
+    // }).params({
+    //   columnId,
+    //   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": "c2e13090a563447c8744a8c03171d1db"
+    //   }
+    // })
+    // .then((response)=>response.json())
   }
   // 收藏
   static setFavorites(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 efunRequest.getHttpRequest().url(`http://ott80test-base.yifangjiaoyu.cn/mobile/favorites`).header({
-    //   "Accept" : "application/json",
-    //   "Content-Type" : "application/json",
-    //   "uid": ""
-    // }).data(data).post();
+    // 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 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 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 efunRequest.getHttpRequest().url(`http://ott80test-base.yifangjiaoyu.cn/mobile/posts`).header({
-    //   "Accept" : "application/json",
-    //   "Content-Type" : "application/json",
-    //   "uid": ""
-    // }).data(data).post();
+    // 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 fetch(`http://ott80test-base.yifangjiaoyu.cn/mobile/posts/reply`,{
-      method:"POST",
-      headers:{
-        "Accept": "application/json",
-        "Content-Type": "application/json",
-        "uid": ""
-      },
-      body: JSON.stringify(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),
+    // })
+    // .then((response)=>response.json())
+  }
+  static playLog(data) {
+    return request(`http://ott80test-base.yifangjiaoyu.cn/mobile/playLog`, {
+      method:"post",
+      body: data,
     })
-    .then((response)=>response.json())
-    // return efunRequest.getHttpRequest().url(`http://ott80test-base.yifangjiaoyu.cn/mobile/posts`).header({
-    //   "Accept" : "application/json",
-    //   "Content-Type" : "application/json",
-    //   "uid": ""
-    // }).data(data).post();
   }
 }

+ 10 - 0
pages/services/user.js

@@ -3,6 +3,16 @@ import efunRequest from '../utils/efunRequest';
 import request from '../utils/request';
 
 export default class user {
+  static update_UserInfo(opts) {
+    console.log('opts',opts);
+    return request(APIConfig.getUserUrl(``), opts);
+  }
+  // 个人中心
+  static userMember() {
+    return request(`http://ott80test-base.yifangjiaoyu.cn/mobile/user/member`, {
+      method: 'get'
+    });
+  }
 	static update_UserInfo(opts) {
 		return request(APIConfig.getUserUrl(``), opts);
 	}

+ 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)