Browse Source

优化联调

bayi 2 years ago
parent
commit
4b284bc49a

+ 84 - 96
components/activityList/index.js

@@ -1,103 +1,91 @@
 import {
-  getActivities
+    getActivities
 } from '~/api/global'
 Component({
-  properties: {},
-  /**
-   * 组件的初始数据
-   */
-  data: {
-    //,2:邀新榜,3:热播榜,4:挑战pk榜,5,朗读赛
-    type: '4',
-    activityList: [],
-    dsqList: []
-  },
-  lifetimes: {
-    attached() {
-      this.getActivities()
+    properties: {},
+    /**
+     * 组件的初始数据
+     */
+    data: {
+        //,2:邀新榜,3:热播榜,4:挑战pk榜,5,朗读赛
+        type: '4',
+        activityList: [],
+        dsqList: []
     },
-    detached() {
-      this.data.dsqList.forEach(item => {
-        clearInterval(item)
-      })
-    }
-  },
-  /**
-   * 组件的方法列表
-   */
-  methods: {
-    async getActivities() {
-      let activityList = await getActivities()
-      console.log(activityList);
-      this.setData({
-        activityList
-      })
-      // 下面这个处理限时活动的,第一版先不上
-      /*  res.forEach((item, index) => {
-         this.activityTimeOut(item.closing, index)
-       }) */
-    },
-    activityTimeOut(oTime, index) {
-      let inputTime = new Date(oTime)
-      let dsq = setInterval(() => {
-        var nowTime = new Date();
-        //把剩余时间毫秒数转化为秒
-        var times = (inputTime - nowTime) / 1000;
-        if (times <= 0) {
-          this.setData({
-            [`activityList[${index}].hour`]: '00',
-            [`activityList[${index}].minute`]: '00',
-            [`activityList[${index}].second`]: '00',
-          })
-          return clearInterval(dsq)
+    lifetimes: {
+        attached() {
+            this.getActivities()
+        },
+        detached() {
+            this.data.dsqList.forEach(item => {
+                clearInterval(item)
+            })
         }
-        //计算小时数 转化为整数
-        var h = parseInt(times / 60 / 60 % 24);
-        //如果小时数小于 10,要变成 0 + 数字的形式 赋值给盒子
-        let hour = h < 10 ? "0" + h : h;
-        //计算分钟数 转化为整数
-        var m = parseInt(times / 60 % 60);
-        //如果分钟数小于 10,要变成 0 + 数字的形式 赋值给盒子
-        let minute = m < 10 ? "0" + m : m;
-        //计算描述 转化为整数
-        var s = parseInt(times % 60);
-        //如果秒钟数小于 10,要变成 0 + 数字的形式 赋值给盒子
-        let second = s < 10 ? "0" + s : s;
-        this.setData({
-          [`activityList[${index}].hour`]: hour,
-          [`activityList[${index}].minute`]: minute,
-          [`activityList[${index}].second`]: second,
-        })
-        times = --times;
-      }, 1000);
-      this.setData({
-        dsqList: [...this.data.dsqList, dsq]
-      })
     },
-    activityEvent({
-      currentTarget
-    }) {
-      //1:图片,2:邀新榜,3:热播榜,4:挑战pk榜,5,朗读赛,6,领取勋章
-      switch (currentTarget.dataset.type) {
-        case 1:
-          break;
-        case 2:
-          wx.navigateTo({
-            url: '/pages/ranking/index?type=2&title=邀新榜',
-          })
-          break;
-        case 3:
-          wx.navigateTo({
-            url: '/pages/ranking/index?type=3&title=热播榜',
-          })
-          break;
-        case 4:
-          wx.navigateTo({
-            url: '/pages/ranking/index?type=4&title=挑战榜',
-          })
-          break;
-        default:
-      }
-    },
-  }
+    /**
+     * 组件的方法列表
+     */
+    methods: {
+        async getActivities() {
+            let activityList = await getActivities()
+            this.setData({
+                activityList
+            })
+            // 下面这个处理限时活动的,第一版先不上
+            /*  res.forEach((item, index) => {
+               this.activityTimeOut(item.closing, index)
+             }) */
+        },
+        activityTimeOut(oTime, index) {
+            let inputTime = new Date(oTime)
+            let dsq = setInterval(() => {
+                var nowTime = new Date();
+                //把剩余时间毫秒数转化为秒
+                var times = (inputTime - nowTime) / 1000;
+                if (times <= 0) {
+                    this.setData({
+                        [`activityList[${index}].hour`]: '00',
+                        [`activityList[${index}].minute`]: '00',
+                        [`activityList[${index}].second`]: '00',
+                    })
+                    return clearInterval(dsq)
+                }
+                //计算小时数 转化为整数
+                var h = parseInt(times / 60 / 60 % 24);
+                //如果小时数小于 10,要变成 0 + 数字的形式 赋值给盒子
+                let hour = h < 10 ? "0" + h : h;
+                //计算分钟数 转化为整数
+                var m = parseInt(times / 60 % 60);
+                //如果分钟数小于 10,要变成 0 + 数字的形式 赋值给盒子
+                let minute = m < 10 ? "0" + m : m;
+                //计算描述 转化为整数
+                var s = parseInt(times % 60);
+                //如果秒钟数小于 10,要变成 0 + 数字的形式 赋值给盒子
+                let second = s < 10 ? "0" + s : s;
+                this.setData({
+                    [`activityList[${index}].hour`]: hour,
+                    [`activityList[${index}].minute`]: minute,
+                    [`activityList[${index}].second`]: second,
+                })
+                times = --times;
+            }, 1000);
+            this.setData({
+                dsqList: [...this.data.dsqList, dsq]
+            })
+        },
+        activityEvent({
+            currentTarget
+        }) {
+            //1:图片,2:邀新榜,3:热播榜,4:挑战pk榜,5,朗读赛,6,领取勋章
+            let {
+                type,
+                id
+            } = currentTarget.dataset
+            if ([2, 3, 4].includes(type)) {
+                wx.navigateTo({
+                    url: `/pages/ranking/index?id=${id}&type=${type}`,
+                })
+            }
+        },
+    }
 })

+ 77 - 73
components/activityList/index.wxml

@@ -1,6 +1,6 @@
 <wxs src="../../utils/filter.wxs" module="filters" />
 <view class="activityList">
-  <!--  <view class="activityBox" wx:for="{{activityList}}" wx:key="id">
+    <!--  <view class="activityBox" wx:for="{{activityList}}" wx:key="id">
     <image src="" class="cover" />
     <view class="footer">
       <view class="info">
@@ -16,80 +16,84 @@
       <view class="btn {{item.second=='00'?'closingBtn':''}}">立即参与</view>
     </view>
   </view> -->
-  <block wx:for="{{activityList}}" wx:key="id">
-    <view class="activityBox" wx:if="{{item.bannerType==1}}">
-      <image src="{{item.icon}}" class="cover" />
-      <view class="footer">
-        <view class="info">
-          <view class="title">{{item.title}}</view>
-          <view class="time">{{filters.formatDate(item.startTime,2)}}—{{filters.formatDate(item.endTime,2)}}</view>
-        </view>
-        <view class="btn" bindtap="activityEvent" data-type='{{item.type}}'>立即参与</view>
-      </view>
-    </view>
-    <view class="ranking-class-1" wx:if="{{item.bannerType==2}}">
-      <view class="header">
-        <view class="title">{{item.title}}</view>
-        <view class="toAll" bindtap="activityEvent" data-type='{{item.type}}'>查看全部
-          <image src="/static/black.png" class="backIcon" />
+    <block wx:for="{{activityList}}" wx:key="id">
+        <view class="activityBox" wx:if="{{item.bannerType==1}}">
+            <image src="{{item.icon}}" class="cover" />
+            <view class="footer">
+                <view class="info">
+                    <view class="title">{{item.title}}</view>
+                    <view class="time">{{filters.formatDate(item.startTime,2)}}—{{filters.formatDate(item.endTime,2)}}
+                    </view>
+                </view>
+                <view class="btn" bindtap="activityEvent" data-type='{{item.type}}' data-id="{{item.id}}">立即参与</view>
+            </view>
         </view>
-      </view>
-      <view class="body">
-        <view class="top">
-          <view class="userBox">
-            <view class="secondUser">
-              <image src="{{item.userList[1].avatar}}" class="avatar" />
+        <view class="ranking-class-1" wx:if="{{item.bannerType==2}}">
+            <view class="header">
+                <view class="title">{{item.title}}</view>
+                <view class="toAll" bindtap="activityEvent" data-type='{{item.type}}' data-id="{{item.id}}">查看全部
+                    <image src="/static/black.png" class="backIcon" />
+                </view>
             </view>
-            <view class="nickName textOver">{{item.userList[1].nickName||item.userList[1].eid}}</view>
-          </view>
-          <view class="userBox">
-            <view class="firstUser">
-              <image src="{{item.userList[0].avatar}}" class="avatar" />
+            <view class="body">
+                <view class="top">
+                    <view class="userBox">
+                        <view class="secondUser">
+                            <image src="{{item.userList[1].avatar}}" class="avatar" />
+                        </view>
+                        <view class="nickName textOver">{{item.userList[1].nickName||item.userList[1].eid}}</view>
+                    </view>
+                    <view class="userBox">
+                        <view class="firstUser">
+                            <image src="{{item.userList[0].avatar}}" class="avatar" />
+                        </view>
+                        <view class="nickName textOver">{{item.userList[0].nickName||item.userList[0].eid}}</view>
+                    </view>
+                    <view class="userBox">
+                        <view class="thirdUser">
+                            <image src="{{item.userList[2].avatar}}" class="avatar" />
+                        </view>
+                        <view class="nickName textOver">{{item.userList[2].nickName||item.userList[2].eid}}</view>
+                    </view>
+                </view>
+                <view class="btm">
+                    <view class="userBox" wx:for="{{5}}" wx:key="index" wx:for-item="items">
+                        <image src="{{item.userList[index+3].avatar}}" class="avatar" />
+                        <view class="nickName textOver">
+                            {{item.userList[index+3].nickName||item.userList[index+3].eid||'请你来挑战'}}
+                        </view>
+                    </view>
+                </view>
             </view>
-            <view class="nickName textOver">{{item.userList[0].nickName||item.userList[0].eid}}</view>
-          </view>
-          <view class="userBox">
-            <view class="thirdUser">
-              <image src="{{item.userList[2].avatar}}" class="avatar" />
-            </view>
-            <view class="nickName textOver">{{item.userList[2].nickName||item.userList[2].eid}}</view>
-          </view>
         </view>
-        <view class="btm">
-          <view class="userBox" wx:for="{{5}}" wx:key="index" wx:for-item="items">
-            <image src="{{item.userList[index+3].avatar}}" class="avatar" />
-            <view class="nickName textOver">{{item.userList[index+3].nickName||item.userList[index+3].eid||'请你来挑战'}}
+        <view class="ranking-class-2 {{item.type=='1'?'yxb':item.type=='3'?'rbb':'pkb'}}"
+            wx:if="{{item.bannerType==3}}">
+            <view class="header">
+                <view class="left">
+                    <image src="{{item.type=='1'?'/static/yxb.png':item.type=='3'?'/static/rbb.png':'/static/pkb.png'}}"
+                        class="icon" />
+                    <view class="title">{{item.title}}</view>
+                </view>
+                <view class="toAll" bindtap="activityEvent" data-type='{{item.type}}' data-id="{{item.id}}">查看全部
+                    <image src="/static/rBtn.png" class="backIcon" />
+                </view>
             </view>
-          </view>
-        </view>
-      </view>
-    </view>
-    <view class="ranking-class-2 {{item.type=='1'?'yxb':item.type=='3'?'rbb':'pkb'}}" wx:if="{{item.bannerType==3}}">
-      <view class="header">
-        <view class="left">
-          <image src="{{item.type=='1'?'/static/yxb.png':item.type=='3'?'/static/rbb.png':'/static/pkb.png'}}"
-            class="icon" />
-          <view class="title">{{item.title}}</view>
-          <!-- <view class="title">{{type=='2'?'邀新榜':type=='3'?'热播榜':'PK榜'}}</view><text>TOP100</text> -->
-        </view>
-        <view class="toAll" bindtap="activityEvent" data-type='{{item.type}}'>查看全部
-          <image src="/static/rBtn.png" class="backIcon" />
-        </view>
-      </view>
-      <view class="body">
-        <view class="row" wx:for="{{3}}" wx:key="index" wx:for-item='items'>
-          <view class="left">
-            <image src="/static/{{index+1}}-1.png" class="stand" />
-            <image src="{{item.userList[index].avatar}}" class="avatar" />
-            <view class="nickName textOver">{{item.userList[index].nickName||item.userList[index].eid}}</view>
-          </view>
-          <view class="right">
-            <image src="{{item.type=='1'?'/static/yx.png':item.type=='3'?'/static/play.png':'/static/win.png'}}"
-              class="playIcon" />
-            <view class="num">{{item.userList[index].count}}</view>
-          </view>
-        </view>
-        <!--  <view class="row">
+            <view class="body">
+                <view class="row" wx:for="{{3}}" wx:key="index" wx:for-item='items'>
+                    <view class="left">
+                        <image src="/static/{{index+1}}-1.png" class="stand" />
+                        <image src="{{item.userList[index].avatar}}" class="avatar" />
+                        <view class="nickName textOver">{{item.userList[index].nickName||item.userList[index].eid}}
+                        </view>
+                    </view>
+                    <view class="right">
+                        <image
+                            src="{{item.type=='1'?'/static/yx.png':item.type=='3'?'/static/play.png':'/static/win.png'}}"
+                            class="playIcon" />
+                        <view class="num">{{item.userList[index].count}}</view>
+                    </view>
+                </view>
+                <!--  <view class="row">
           <view class="left">
             <image src="/static/2-1.png" class="stand" />
             <image src="/static/play-big.png" class="avatar" />
@@ -113,7 +117,7 @@
             <view class="num">186</view>
           </view>
         </view> -->
-      </view>
-    </view>
-  </block>
+            </view>
+        </view>
+    </block>
 </view>

+ 42 - 53
components/banner/index.js

@@ -1,60 +1,49 @@
 import {
-  getBannerList
+    getBannerList
 } from '~/api/global'
 Component({
-  properties: {
-    classify: {
-      type: Number,
-      value: 1
-    }
-  },
-  data: {
-    bannerList: []
-  },
-  lifetimes: {
-    attached() {
-      this.getBannerList()
+    properties: {
+        classify: {
+            type: Number,
+            value: 1
+        }
     },
-  },
-  /**
-   * 组件的方法列表
-   */
-  methods: {
-    async getBannerList() {
-      let bannerList = await getBannerList(this.properties.classify)
-      this.setData({
-        bannerList
-      })
+    data: {
+        bannerList: []
     },
-    bannelEvent({
-      currentTarget
-    }) {
-      //1:图片,2:邀新榜,3:热播榜,4:挑战pk榜,5,朗读赛,6,领取勋章
-      switch (currentTarget.dataset.type) {
-        case 1:
-          break;
-        case 2:
-          wx.navigateTo({
-            url: '/pages/ranking/index?type=2&title=邀新榜',
-          })
-          break;
-        case 3:
-          wx.navigateTo({
-            url: '/pages/ranking/index?type=3&title=热播榜',
-          })
-          break;
-        case 4:
-          wx.navigateTo({
-            url: '/pages/ranking/index?type=4&title=挑战榜',
-          })
-          break;
-        case 5:
-          wx.navigateTo({
-            url: '/pages/match/index',
-          })
-          break;
-        default:
-      }
+    lifetimes: {
+        attached() {
+            this.getBannerList()
+        },
     },
-  }
+    /**
+     * 组件的方法列表
+     */
+    methods: {
+        async getBannerList() {
+            let bannerList = await getBannerList(this.properties.classify)
+            this.setData({
+                bannerList
+            })
+        },
+        bannelEvent({
+            currentTarget
+        }) {
+            //1:图片,2:邀新榜,3:热播榜,4:挑战pk榜,5,朗读赛,6,领取勋章
+            let {
+                type,
+                id
+            } = currentTarget.dataset
+            if ([2, 3, 4].includes(type)) {
+                wx.navigateTo({
+                    url: `/pages/ranking/index?id=${id}&type=${type}`,
+                })
+            }
+            if (type == 5) {
+                wx.navigateTo({
+                    url: '/pages/match/index',
+                })
+            }
+        },
+    }
 })

+ 8 - 8
components/banner/index.wxml

@@ -1,10 +1,10 @@
 <view class="header">
-  <view class="headerBg"></view>
-  <swiper class="swiper" autoplay circular indicator-dots indicator-active-color="#fff" indicator-color='#ecececa1'>
-    <block wx:for="{{bannerList}}" wx:key="id">
-      <swiper-item bindtap='bannelEvent' data-type='{{item.type}}'>
-        <image src="{{item.icon}}" class="swiper-item" mode="" />
-      </swiper-item>
-    </block>
-  </swiper>
+    <view class="headerBg"></view>
+    <swiper class="swiper" autoplay circular indicator-dots indicator-active-color="#fff" indicator-color='#ecececa1'>
+        <block wx:for="{{bannerList}}" wx:key="id">
+            <swiper-item bindtap='bannelEvent' data-type='{{item.type}}' data-id="{{item.content}}">
+                <image src="{{item.icon}}" class="swiper-item" mode="" />
+            </swiper-item>
+        </block>
+    </swiper>
 </view>

+ 0 - 1
components/readingTips/index.js

@@ -45,7 +45,6 @@ Component({
     },
     async getProducts() {
       let products = await getProducts()
-      console.log(products);
       let productVip = products.find(item => {
         return item.type == 1
       })

+ 94 - 87
components/uploadFile/index.js

@@ -1,100 +1,107 @@
 import {
-  storeBindingsBehavior
+    storeBindingsBehavior
 } from 'mobx-miniprogram-bindings'
 import {
-  store
+    store
 } from '~/store/index'
 import {
-  publishWorks,
-  publishRankWorks
+    publishWorks,
+    postWorksScore,
+    publishRankWorks
 } from '~/api/works'
 Component({
-  behaviors: [storeBindingsBehavior],
-  storeBindings: {
-    store,
-    fields: {
-      readDetail: 'readDetail'
-    },
-    actions: {
-      setReadDetail: 'setReadDetail'
-    }
-  },
-  /**
-   * 组件的属性列表
-   */
-  properties: {
-    readingType: ''
-  },
-  /**
-   * 组件的初始数据
-   */
-  data: {
-    tempFilePath: '',
-    uploadFlag: false,
-    uploadSuccess: false,
-    // 是否上传过
-    uploadState: false,
-    percent: 0,
-  },
-  /**
-   * 组件的方法列表
-   */
-  methods: {
-    upload() {
-      if (this.data.uploadState) {
-        return
-      }
-      this.setData({
-        uploadFlag: true,
-        uploadState: true
-      })
-      const uploadTask = wx.uploadFile({
-        url: 'https://reader-api.ai160.com//file/upload',
-        filePath: this.data.readDetail.tempFilePath,
-        name: '朗读录音',
-        header: {
-          uid: wx.getStorageSync('uid')
-        },
-        success: (res) => {
-          const formateRes = JSON.parse(res.data);
-          let audioPath = formateRes.data;
-          this.uploadWorks(audioPath);
-          this.setData({
-            uploadSuccess: true,
-          })
+    behaviors: [storeBindingsBehavior],
+    storeBindings: {
+        store,
+        fields: {
+            readDetail: 'readDetail'
         },
-        complete: () => {
-          this.setData({
-            uploadFlag: false
-          })
+        actions: {
+            setReadDetail: 'setReadDetail'
         }
-      })
-      uploadTask.onProgressUpdate((res) => {
-        this.setData({
-          percent: res.progress
-        })
-      })
     },
-    cancelMask() {
-      this.setData({
-        uploadSuccess: false
-      })
+    /**
+     * 组件的属性列表
+     */
+    properties: {
+        readingType: ''
+    },
+    /**
+     * 组件的初始数据
+     */
+    data: {
+        tempFilePath: '',
+        uploadFlag: false,
+        uploadSuccess: false,
+        // 是否上传过
+        uploadState: false,
+        percent: 0,
     },
-    async uploadWorks(audio) {
-      console.log(this.data);
-      const data = {
-        "exampleId": this.data.readDetail.id,
-        "audioPath": audio,
-        "originVideo": this.data.readDetail.originVideo,
-      };
-      console.log(data, '嘎嘎嘎嘎');
-      let res
-      if (!this.properties.readingType) {
-        res = await publishWorks(data)
-      } else {
-        res = await publishRankWorks(data)
-      }
-      console.log(res, '嘎2');
+    /**
+     * 组件的方法列表
+     */
+    methods: {
+        upload() {
+            if (this.data.uploadState) {
+                return
+            }
+            this.setData({
+                uploadFlag: true,
+                uploadState: true
+            })
+            const uploadTask = wx.uploadFile({
+                url: 'https://reader-api.ai160.com//file/upload',
+                filePath: this.data.readDetail.tempFilePath,
+                name: '朗读录音',
+                header: {
+                    uid: wx.getStorageSync('uid')
+                },
+                success: (res) => {
+                    const formateRes = JSON.parse(res.data);
+                    let audioPath = formateRes.data;
+                    this.uploadWorks(audioPath);
+                    this.setData({
+                        uploadSuccess: true,
+                    })
+                },
+                complete: () => {
+                    this.setData({
+                        uploadFlag: false
+                    })
+                }
+            })
+            uploadTask.onProgressUpdate((res) => {
+                this.setData({
+                    percent: res.progress
+                })
+            })
+        },
+        cancelMask() {
+            this.setData({
+                uploadSuccess: false
+            })
+        },
+        async uploadWorks(audio) {
+            const data = {
+                "exampleId": this.data.readDetail.id,
+                "audioPath": audio,
+                "originVideo": this.data.readDetail.originVideo,
+            };
+            let res
+            if (!this.properties.readingType) {
+                res = await publishWorks(data)
+            } else {
+                res = await publishRankWorks(data)
+            }
+            let _data = this.data.readDetail
+            await postWorksScore({
+                "userReadId": res.id,
+                "complete": _data.integrity,
+                "accuracy": _data.accuracy,
+                "speed": _data.fluency,
+                "intonation": _data.tone,
+                "score": _data.myOverall
+            })
+        },
     },
-  },
 })

+ 0 - 1
components/worksList/index.js

@@ -20,7 +20,6 @@ Component({
                             let intersectionRatio = res.intersectionRatio
                             if (intersectionRatio > 0) {
                                 if (res.dataset.type == 0) {
-                                    console.log(res);
                                     this.resetAudio();
                                     this.setData({
                                         currentId: res.dataset.id

+ 0 - 3
mixins/video.js

@@ -22,7 +22,6 @@ module.exports = Behavior({
             currentTarget
         }) {
             if (this.data.currentId == currentTarget.dataset.id) {
-                console.log('相同');
                 return this.resetAudio()
             }
             if (this.innerAudioContext) {
@@ -32,8 +31,6 @@ module.exports = Behavior({
                 this.innerAudioContext.onEnded(res => {
                     this.resetAudio()
                 })
-                /* this.innerAudioContext.onStop((res) => {
-                }); */
             }
             this.innerAudioContext.src = currentTarget.dataset.audio
             this.innerAudioContext.play();

+ 50 - 50
pages/pkPage/index.js

@@ -1,58 +1,58 @@
 import behavior from '~/mixins/video'
 import share from '~/mixins/share'
 import {
-  getreadInfo
+    getreadInfo
 } from '~/api/video'
 import {
-  getPkRecord
+    getPkRecord
 } from '~/api/works'
 Page({
-  behaviors: [behavior, share, ],
-  data: {
-    videoInfo: {},
-    videoId: '',
-    recordList: []
-  },
-  /**
-   * 生命周期函数--监听页面加载
-   */
-  onLoad(options) {
-    console.log(options);
-    let videoId = options.videoId
-    this.setData({
-      videoId
-    })
-    this.getreadInfo(videoId)
-    this.getPkRecord()
-  },
-  async getreadInfo(videoId) {
-    let videoInfo = await getreadInfo(videoId)
-    wx.setNavigationBarTitle({
-      title: videoInfo.userRead.title
-    })
-    this.setData({
-      videoInfo
-    })
-  },
-  async getPkRecord() {
-    let recordList = await getPkRecord({
-      userReadId: this.data.videoId
-    })
-    this.setData({
-      recordList
-    })
-    console.log(recordList);
-  },
-  jumpUserInfo({
-    currentTarget
-  }) {
-    wx.navigateTo({
-      url: `/pages/personal/index?uid=${currentTarget.dataset.uid}&type=user`,
-    })
-  },
-  onHide() {
-    this.setData({
-      currentId: ''
-    })
-  }
+    behaviors: [behavior, share, ],
+    data: {
+        videoInfo: {},
+        videoId: '',
+        recordList: []
+    },
+    /**
+     * 生命周期函数--监听页面加载
+     */
+    onLoad(options) {
+        let videoId = options.videoId
+        this.setData({
+            videoId
+        })
+        this.getreadInfo(videoId)
+        this.getPkRecord()
+    },
+    async getreadInfo(videoId) {
+        let videoInfo = await getreadInfo(videoId)
+        wx.setNavigationBarTitle({
+            title: videoInfo.userRead.title
+        })
+        this.setData({
+            videoInfo
+        })
+    },
+    async getPkRecord() {
+        let recordList = await getPkRecord({
+            userReadId: this.data.videoId
+        })
+        this.setData({
+            recordList
+        })
+        console.log(recordList);
+    },
+    jumpUserInfo({
+        currentTarget
+    }) {
+        wx.navigateTo({
+            url: `/pages/personal/index?uid=${currentTarget.dataset.uid}&type=user`,
+        })
+    },
+    onUnload() {
+        this.resetAudio()
+        this.setData({
+            currentId: ''
+        })
+    }
 })

+ 8 - 6
pages/ranking/index.js

@@ -25,21 +25,23 @@ Page({
             icon: options.type == '2' ? '/static/yx.png' : options.type == '3' ? '/static/play.png' : '/static/win.png',
             podiumBoxBg: options.type == '2' ? 'invitation' : options.type == '3' ? 'hot' : 'pk',
         })
-        wx.setNavigationBarTitle({
-            title: options.title
-        })
+
         wx.setNavigationBarColor({
             frontColor: '#ffffff',
             backgroundColor: options.type == '2' ? '#ff7f6c' : options.type == '3' ? '#6D9FFE' : '#967DFF',
         })
-        this.getRankingData()
+        this.getRankingData(options.id)
     },
-    async getRankingData() {
+    async getRankingData(id) {
         let {
             ranking,
             userList,
+            title,
             explain
-        } = await getRankingData(this.data.rankingType)
+        } = await getRankingData(id)
+        wx.setNavigationBarTitle({
+            title
+        })
         this.setData({
             ranking,
             userList,

+ 2 - 1
pages/ranking/index.json

@@ -1,3 +1,4 @@
 {
-  "usingComponents": {}
+  "usingComponents": {},
+  "navigationBarTitleText": "排行榜"
 }

+ 42 - 42
utils/request.js

@@ -2,53 +2,53 @@ let baseUrl = null
 let oldUrl = null
 
 const {
-  miniProgram: {
-    envVersion
-  }
+    miniProgram: {
+        envVersion
+    }
 } = wx.getAccountInfoSync();
-if (envVersion == 'develop') {
-  baseUrl = 'https://reader-api.efunbox.cn/wx'
-  oldUrl = 'https://reader-api.efunbox.cn'
-} else {
-  baseUrl = 'https://reader-api.ai160.com/wx'
-  oldUrl = 'https://reader-api.ai160.com'
-}
+// if (envVersion == 'develop') {
+baseUrl = 'https://reader-api.efunbox.cn/wx'
+oldUrl = 'https://reader-api.efunbox.cn'
+// } else {
+//   baseUrl = 'https://reader-api.ai160.com/wx'
+//   oldUrl = 'https://reader-api.ai160.com'
+// }
 
 function request(url, method, data, oldBaseUrl = false) {
-  let header = {
-    'uid': wx.getStorageSync('uid') || ''
-  }
+    let header = {
+        'uid': wx.getStorageSync('uid') || ''
+    }
 
-  return new Promise((reslove, reject) => {
-    wx.request({
-      url: oldBaseUrl ? oldUrl + url : baseUrl + url,
-      method: method,
-      data: data,
-      header: header,
-      success: (result) => {
-        let {
-          data: {
-            code,
-            data = {},
-            message
-          }
-        } = result
-        if (code == '200') {
-          reslove(data)
-        } else if (code == '1102' || code == '1204') {
-          wx.clearStorage()
-        } else {
-          console.log(message);
-          // reject(message)
-        }
-      },
-      fail: (res) => {
-        console.error(res)
-        reject(res)
-      },
+    return new Promise((reslove, reject) => {
+        wx.request({
+            url: oldBaseUrl ? oldUrl + url : baseUrl + url,
+            method: method,
+            data: data,
+            header: header,
+            success: (result) => {
+                let {
+                    data: {
+                        code,
+                        data = {},
+                        message
+                    }
+                } = result
+                if (code == '200') {
+                    reslove(data)
+                } else if (code == '1102' || code == '1204') {
+                    wx.clearStorage()
+                } else {
+                    console.log(message);
+                    // reject(message)
+                }
+            },
+            fail: (res) => {
+                console.error(res)
+                reject(res)
+            },
+        })
     })
-  })
 }
 module.exports = {
-  request,
+    request,
 }