Преглед изворни кода

开发联调朗读比赛页面

bayi пре 2 година
родитељ
комит
7191aedc84
11 измењених фајлова са 292 додато и 263 уклоњено
  1. 6 4
      api/global.js
  2. 4 0
      api/user.js
  3. 1 1
      app.json
  4. 5 0
      components/banner/index.js
  5. 2 2
      components/readingTips/index.js
  6. 1 1
      pages/index/index.js
  7. 58 25
      pages/match/index.js
  8. 14 21
      pages/match/index.less
  9. 13 16
      pages/match/index.wxml
  10. 14 19
      pages/match/index.wxss
  11. 174 174
      pages/my/index.js

+ 6 - 4
api/global.js

@@ -4,10 +4,6 @@ import {
 module.exports = {
   //获取充值配置信息
   getProducts: data => request('/v3/product', 'get', data),
-  // 购买vip
-  buyVip: data => request('/order', 'post', data, true),
-  // 购买次数
-  buyNum: data => request('/v3/pay', 'post', data),
   // 获取任务配置
   getTasks: data => request('/v3/task', 'get', data),
   // 提交任务
@@ -18,4 +14,10 @@ module.exports = {
   getActivities: data => request('/v3/activity', 'get', data),
   // 获取排行榜详情
   getRankingData: data => request(`/v3/activity/${data}`, 'get', data),
+  // 获取朗读赛范文
+  getModelTexts: data => request('/activityRead', 'get', data),
+  // 获取朗读赛排行榜
+  getReadRanking: data => request('/activityJoinUser/hotAmountTop', 'get', data),
+  // 获取朗读赛排行榜参赛作品
+  getSelfReadRanking: data => request('/activityJoinUser/activityRead', 'get', data),
 }

+ 4 - 0
api/user.js

@@ -11,6 +11,10 @@ module.exports = {
   getMyInfo: data => request('/v3/user/my', 'get', data),
   // 设置用户信息
   setUserInfo: (data, method = 'post') => request('/user', method, data),
+  // 购买vip
+  buyVip: data => request('/order', 'post', data, true),
+  // 购买次数
+  buyNum: data => request('/v3/pay', 'post', data),
   //获取是否vip及过期时间
   getVipInfo: data => request('/auth', 'get', data),
   //获取自己朗读的作品

+ 1 - 1
app.json

@@ -1,8 +1,8 @@
 {
   "pages": [
+    "pages/match/index",
     "pages/index/index",
     "pages/pkResult/index",
-    "pages/match/index",
     "pages/medalStore/index",
     "pages/my/index",
     "pages/score/index",

+ 5 - 0
components/banner/index.js

@@ -48,6 +48,11 @@ Component({
             url: '/pages/ranking/index?type=4&title=挑战榜',
           })
           break;
+        case 5:
+          wx.navigateTo({
+            url: 'pages/match/index',
+          })
+          break;
         default:
       }
     },

+ 2 - 2
components/readingTips/index.js

@@ -1,11 +1,11 @@
 import {
   getProducts,
   getTasks,
-  buyVip,
-  buyNum,
   submitTask
 } from '~/api/global'
 import {
+  buyNum,
+  buyVip,
   getMyInfo,
   getVipInfo
 } from '~/api/user'

+ 1 - 1
pages/index/index.js

@@ -20,7 +20,7 @@ Page({
   data: {
     navBarHeight: app.globalData.navBarHeight,
     background: ['demo-text-1', 'demo-text-2', 'demo-text-3'],
-    currentType: '3',
+    currentType: '1',
     // 控制一级分类是否固定
     isFixed: false,
     desktopTips: false,

+ 58 - 25
pages/match/index.js

@@ -1,10 +1,18 @@
 import {
   getSelfRead
 } from '~/api/user'
-import reachBottom from '~/mixins/reachBottom'
+import {
+  getModelTexts,
+  getReadRanking,
+  getSelfReadRanking
+} from '~/api/global'
+import {
+  store
+} from '~/store/index'
+import {
+  createStoreBindings
+} from 'mobx-miniprogram-bindings'
 Page({
-  behaviors: [reachBottom],
-
   /**
    * 页面的初始数据
    */
@@ -12,44 +20,69 @@ Page({
     list: [],
     // true是人气榜,false是参赛作品
     currentType: true,
-    bannerList: [{
-      id: 1,
-      url: "https://efunimgs.ai160.com/xyyf/banner/voucher.png"
-    }, {
-      id: 2,
-      url: "https://efunimgs.ai160.com/xyyf/banner/course.png"
-    }, {
-      id: 3,
-      url: "https://efunimgs.ai160.com/xyyf/banner/video.png"
-    }, {
-      id: 4,
-      url: "https://efunimgs.ai160.com/xyyf/banner/topic.png"
-    }]
+    rankingList: [],
+    bannerList: []
   },
 
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad(options) {
-    this.loadMore()
+    // 手工绑定 
+    this.storeBindings = createStoreBindings(this, {
+      store,
+      fields: {
+        userInfo: 'userInfo'
+      },
+      actions: {
+        setUser: 'setUser'
+      }
+    })
+    // 立刻更新
+    this.storeBindings.updateStoreBindings()
+    this.getModelTexts()
+    this.getReadRanking()
+  },
+  // 获取范文
+  async getModelTexts() {
+    let bannerList = await getModelTexts({
+      grade: 'PRIMARY_FIRST_GRADE' || this.data.userInfo.grade
+    })
+    this.setData({
+      bannerList
+    })
+  },
+  async getReadRanking() {
+    let rankingList = await getReadRanking()
+    this.setData({
+      rankingList
+    })
+  },
+  async getSelfReadRanking() {
+    let res = await getSelfReadRanking()
+    console.log(res);
   },
   bannelEvent() {},
+  jumpUserInfo({
+    currentTarget
+  }) {
+    wx.navigateTo({
+      url: `/pages/personal/index?uid=${currentTarget.dataset.uid}`,
+    })
+  },
   selectType({
     target
   }) {
     if (target.dataset.type) {
+      let currentType = JSON.parse(target.dataset.type)
+      if (!currentType) {
+        this.getSelfReadRanking()
+      }
       this.setData({
-        currentType: JSON.parse(target.dataset.type)
+        currentType
       })
-
     }
   },
-  loadMore() {
-    this.getData(getSelfRead)
-  },
-  onReachBottom() {
-    this.loadMore()
-  },
   onShareAppMessage() {
 
   }

+ 14 - 21
pages/match/index.less

@@ -1,4 +1,5 @@
 .matchBox {
+  min-height: 100vh;
   background-color: F2F6FC;
 
   .headerImg {
@@ -40,22 +41,14 @@
       }
     }
 
-    .tips {
-      margin: 42rpx auto;
-      width: 580rpx;
-      padding: 6rpx 0rpx;
-      text-align: center;
-      letter-spacing: 2rpx;
-      border-radius: 20rpx;
-      font-size: 30rpx;
-      color: #858585;
-      background-color: #F8F6FF;
-    }
-
     .swiper {
+      margin-top: 40rpx;
+      width: 100%;
+      height: 372rpx;
+
       .swiper-item {
-        width: 580rpx;
-        height: 238rpx;
+        width: 562rpx;
+        height: 316rpx;
         border-radius: 10rpx;
         overflow: hidden;
         object-fit: cover;
@@ -110,7 +103,7 @@
       }
 
       .contentBox {
-        margin-top: 22rpx;
+        margin-top: 24rpx;
         display: flex;
         justify-content: space-between;
         align-items: center;
@@ -118,11 +111,11 @@
         .firstCol {
           width: 70rpx;
           text-align: center;
-          font-size: 38rpx;
+          font-size: 34rpx;
 
           .rankingImg {
-            width: 52rpx;
-            height: 60rpx;
+            width: 44rpx;
+            height: 48rpx;
           }
         }
 
@@ -133,8 +126,8 @@
           align-items: center;
 
           .avatar {
-            width: 80rpx;
-            height: 80rpx;
+            width: 66rpx;
+            height: 66rpx;
             border-radius: 50%;
           }
 
@@ -142,7 +135,7 @@
             margin-left: 20rpx;
 
             .nickName {
-              font-size: 34rpx;
+              font-size: 28rpx;
               margin-bottom: 6rpx;
             }
 

+ 13 - 16
pages/match/index.wxml

@@ -4,16 +4,13 @@
   <view class="modelText">
     <view class="header">
       <image src="/static/modelBg.png" class="bg" />
-      <view class="text">一年级 朗读范文素材</view>
+      <view class="text">选择下面范文进行朗读</view>
     </view>
-    <view class="tips">
-      选择下面范文进行朗读
-    </view>
-    <swiper class="swiper" autoplay circular indicator-dots previous-margin='36px' next-margin='20px'
+    <swiper class="swiper" autoplay circular indicator-dots previous-margin='40px' next-margin='20px'
       indicator-active-color="#7ACAFF" indicator-color='#BABABA'>
       <block wx:for="{{bannerList}}" wx:key="id">
         <swiper-item bindtap='bannelEvent'>
-          <image src="{{item.url}}" class="swiper-item" mode="" />
+          <image src="{{item.coverImg}}" class="swiper-item" mode="" />
         </swiper-item>
       </block>
     </swiper>
@@ -26,37 +23,37 @@
     <view class="table" wx:if="{{currentType}}">
       <view class="titleLine">
         <view class="colTitle">排名</view>
-        <view class="colTitle">名称</view>
         <view class="colTitle">人气值</view>
       </view>
-      <view class="contentBox" wx:for="{{20}}" wx:key="index">
+      <view class="contentBox" wx:for="{{rankingList}}" wx:key="id">
         <view class="firstCol">
-          <image src="/static/1-1.png" class="rankingImg" wx:if="{{index<3}}" />
+          <image src="/static/{{index+1}}-1.png" class="rankingImg" wx:if="{{index<3}}" />
           <text wx:else>{{index+1}}</text>
         </view>
         <view class="secondCol">
-          <image src="https://p3-passport.byteimg.com/img/mosaic-legacy/3793/3131589739~100x100.awebp" class="avatar" />
+          <image lazy-load src="{{item.user.avatar}}" class="avatar" bindtap="jumpUserInfo"
+            data-uid='{{item.user.uid}}' />
           <view class="userInfo">
-            <view class="nickName">尼赫鲁吧唧布</view>
+            <view class="nickName">{{item.user.nickName||item.user.eid}}</view>
             <view class="date">
               <view>
                 <image src="/static/f.png" class="icon" />
-                <view class="num">{{filters.numFilter(10)}}</view>
+                <view class="num">{{filters.numFilter(item.activityJoinUser.shareAmount)}}</view>
               </view>
               <view>
                 <image src="/static/p.png" class="icon" />
-                <view class="num">{{filters.numFilter(10)}}</view>
+                <view class="num">{{filters.numFilter(item.activityJoinUser.commentAmount)}}</view>
               </view>
               <view>
                 <image src="/static/d.png" class="icon" />
-                <view class="num">{{filters.numFilter(10130)}}</view>
+                <view class="num">{{filters.numFilter(item.activityJoinUser.likeAmount)}}</view>
               </view>
             </view>
           </view>
         </view>
         <view class="threeCol">
           <image src="/static/hot.png" class="icon" />
-          <view class="num">{{filters.numFilter(12310)}}</view>
+          <view class="num">{{filters.numFilter(item.activityJoinUser.hotAmount)}}</view>
         </view>
       </view>
       <view class="contentBox selfRank">
@@ -89,6 +86,6 @@
         </view>
       </view>
     </view>
-    <worksList id="worksList" videoType='my' worksList="{{list}}" />
+    <worksList class="worksList" videoType='my' worksList="{{list}}" />
   </view>
 </view>

+ 14 - 19
pages/match/index.wxss

@@ -1,4 +1,5 @@
 .matchBox {
+  min-height: 100vh;
   background-color: F2F6FC;
 }
 .matchBox .headerImg {
@@ -36,20 +37,14 @@
   font-size: 34rpx;
   color: white;
 }
-.matchBox .modelText .tips {
-  margin: 42rpx auto;
-  width: 580rpx;
-  padding: 6rpx 0rpx;
-  text-align: center;
-  letter-spacing: 2rpx;
-  border-radius: 20rpx;
-  font-size: 30rpx;
-  color: #858585;
-  background-color: #F8F6FF;
+.matchBox .modelText .swiper {
+  margin-top: 40rpx;
+  width: 100%;
+  height: 372rpx;
 }
 .matchBox .modelText .swiper .swiper-item {
-  width: 580rpx;
-  height: 238rpx;
+  width: 562rpx;
+  height: 316rpx;
   border-radius: 10rpx;
   overflow: hidden;
   object-fit: cover;
@@ -95,7 +90,7 @@
   font-size: 36rpx;
 }
 .matchBox .rankList .table .contentBox {
-  margin-top: 22rpx;
+  margin-top: 24rpx;
   display: flex;
   justify-content: space-between;
   align-items: center;
@@ -103,11 +98,11 @@
 .matchBox .rankList .table .contentBox .firstCol {
   width: 70rpx;
   text-align: center;
-  font-size: 38rpx;
+  font-size: 34rpx;
 }
 .matchBox .rankList .table .contentBox .firstCol .rankingImg {
-  width: 52rpx;
-  height: 60rpx;
+  width: 44rpx;
+  height: 48rpx;
 }
 .matchBox .rankList .table .contentBox .secondCol {
   flex: 1;
@@ -116,15 +111,15 @@
   align-items: center;
 }
 .matchBox .rankList .table .contentBox .secondCol .avatar {
-  width: 80rpx;
-  height: 80rpx;
+  width: 66rpx;
+  height: 66rpx;
   border-radius: 50%;
 }
 .matchBox .rankList .table .contentBox .secondCol .userInfo {
   margin-left: 20rpx;
 }
 .matchBox .rankList .table .contentBox .secondCol .userInfo .nickName {
-  font-size: 34rpx;
+  font-size: 28rpx;
   margin-bottom: 6rpx;
 }
 .matchBox .rankList .table .contentBox .secondCol .userInfo .date {

+ 174 - 174
pages/my/index.js

@@ -1,185 +1,185 @@
 import {
+  getProducts,
+  getTasks,
+  submitTask
+} from '~/api/global'
+import {
+  buyVip,
+  buyNum,
   getMyInfo,
-    getVipInfo
+  getVipInfo
 } from '~/api/user'
-import {
-    getProducts,
-    getTasks,
-    buyVip,
-    buyNum,
-    submitTask
-} from '~/api/global'
 const app = getApp()
 Page({
-    data: {
-        userInfo: {},
-        vipTime: '',
-        tasks: [],
-        isIos: app.globalData.isIOS,
-        productNum: {},
-        productVip: {}
-    },
-    onLoad() {
-        this.getProducts()
-    },
-    async onShow() {
-        if (typeof this.getTabBar === 'function') {
-            this.getTabBar().setData({
-                selected: 0
-            })
-        }
-        let uid = wx.getStorageSync('uid') || ''
-        if (!uid) {
-            getApp().callBack = (res) => {
-                this.setUserInfo()
-            }
-        } else {
-            this.setUserInfo()
-        }
-    },
-    // 设置用户信息及vip状态和任务完成情况
-    async setUserInfo() {
-        let userInfo = await getMyInfo()
-        let vipTime = await getVipInfo()
-        this.getTasks()
-        this.setData({
-            userInfo,
-            vipTime,
-        })
-    },
-    async getTasks() {
-        let tasks = await getTasks()
-        this.setData({
-            tasks
-        })
-    },
-    async getProducts() {
-        let products = await getProducts()
-        let productVip = products.find(item => {
-            return item.type == 1
-        })
-        let productNum = products.find(item => {
-            return item.type == 2
-        })
-        this.setData({
-            productNum,
-            productVip
-        })
-    },
-    //购买vip和购买次数不是一个接口 type 1001是vip,1010是次数
-    async toBuy({
-        currentTarget
-    }) {
-        let productId = currentTarget.dataset.type
-        wx.showLoading({
-            title: '提交中',
-            mask: true
+  data: {
+    userInfo: {},
+    vipTime: '',
+    tasks: [],
+    isIos: app.globalData.isIOS,
+    productNum: {},
+    productVip: {}
+  },
+  onLoad() {
+    this.getProducts()
+  },
+  async onShow() {
+    if (typeof this.getTabBar === 'function') {
+      this.getTabBar().setData({
+        selected: 0
+      })
+    }
+    let uid = wx.getStorageSync('uid') || ''
+    if (!uid) {
+      getApp().callBack = (res) => {
+        this.setUserInfo()
+      }
+    } else {
+      this.setUserInfo()
+    }
+  },
+  // 设置用户信息及vip状态和任务完成情况
+  async setUserInfo() {
+    let userInfo = await getMyInfo()
+    let vipTime = await getVipInfo()
+    this.getTasks()
+    this.setData({
+      userInfo,
+      vipTime,
+    })
+  },
+  async getTasks() {
+    let tasks = await getTasks()
+    this.setData({
+      tasks
+    })
+  },
+  async getProducts() {
+    let products = await getProducts()
+    let productVip = products.find(item => {
+      return item.type == 1
+    })
+    let productNum = products.find(item => {
+      return item.type == 2
+    })
+    this.setData({
+      productNum,
+      productVip
+    })
+  },
+  //购买vip和购买次数不是一个接口 type 1001是vip,1010是次数
+  async toBuy({
+    currentTarget
+  }) {
+    let productId = currentTarget.dataset.type
+    wx.showLoading({
+      title: '提交中',
+      mask: true
+    })
+    let res = ''
+    if (productId == '1001') {
+      res = await buyVip({
+        productId
+      }).finally(() => {
+        wx.hideLoading()
+      })
+    } else if (productId == '1010') {
+      res = await buyNum({
+        productId
+      }).finally(() => {
+        wx.hideLoading()
+      })
+    } else {
+      wx.hideLoading()
+      wx.showToast({
+        title: "支付失败,请重试",
+        icon: "none"
+      })
+    }
+    let {
+      timeStamp,
+      nonceStr,
+      signType,
+      paySign
+    } = res
+    // package保留字
+    wx.requestPayment({
+      timeStamp,
+      nonceStr,
+      package: res.package,
+      signType,
+      paySign,
+      success(res) {
+        wx.showToast({
+          title: "支付成功",
+          duration: 2500
         })
-        let res = ''
-        if (productId == '1001') {
-            res = await buyVip({
-                productId
-            }).finally(() => {
-                wx.hideLoading()
-            })
-        } else if (productId == '1010') {
-            res = await buyNum({
-                productId
-            }).finally(() => {
-                wx.hideLoading()
-            })
-        } else {
-            wx.hideLoading()
-            wx.showToast({
-                title: "支付失败,请重试",
-                icon: "none"
-            })
-        }
-        let {
-            timeStamp,
-            nonceStr,
-            signType,
-            paySign
-        } = res
-        // package保留字
-        wx.requestPayment({
-            timeStamp,
-            nonceStr,
-            package: res.package,
-            signType,
-            paySign,
-            success(res) {
-                wx.showToast({
-                    title: "支付成功",
-                    duration: 2500
-                })
-                setTimeout(() => {
-                    this.setUserInfo()
-                }, 1500)
+        setTimeout(() => {
+          this.setUserInfo()
+        }, 1500)
 
-            },
-            fail(res) {
-                wx.showToast({
-                    title: "支付失败",
-                    icon: "none"
-                })
-            }
-        })
-    },
-    // 提交任务
-    async submitTask({
-        currentTarget
-    }) {
-        let id = currentTarget.dataset.type
-        await submitTask({
-            id
-        })
+      },
+      fail(res) {
         wx.showToast({
-            title: id == '1' ? '签到成功!' : id == 3 ? "观看成功!" : "",
-            icon: "none"
+          title: "支付失败",
+          icon: "none"
         })
-        this.setUserInfo()
-    },
-    jump({
-        currentTarget
-    }) {
-        let url = currentTarget.dataset.url
-        wx.navigateTo({
-            url: url
-        });
-    },
-    // 调起广告
-    rewardedVideo() {
-        if (this.data.tasks.length != 3 || this.data.tasks[2].completed) {
-            return
-        }
-        this.selectComponent('#advert').rewardedVideo();
-    },
-    clipboar() {
-        wx.setClipboardData({
-            data: this.data.userInfo.user.eid,
-            success: function (res) { //成功回调函数
-                wx.showToast({
-                    title: '已复制',
-                    icon: "none"
-                })
-            }
+      }
+    })
+  },
+  // 提交任务
+  async submitTask({
+    currentTarget
+  }) {
+    let id = currentTarget.dataset.type
+    await submitTask({
+      id
+    })
+    wx.showToast({
+      title: id == '1' ? '签到成功!' : id == 3 ? "观看成功!" : "",
+      icon: "none"
+    })
+    this.setUserInfo()
+  },
+  jump({
+    currentTarget
+  }) {
+    let url = currentTarget.dataset.url
+    wx.navigateTo({
+      url: url
+    });
+  },
+  // 调起广告
+  rewardedVideo() {
+    if (this.data.tasks.length != 3 || this.data.tasks[2].completed) {
+      return
+    }
+    this.selectComponent('#advert').rewardedVideo();
+  },
+  clipboar() {
+    wx.setClipboardData({
+      data: this.data.userInfo.user.eid,
+      success: function (res) { //成功回调函数
+        wx.showToast({
+          title: '已复制',
+          icon: "none"
         })
-    },
-    // 分享配置
-    onShareAppMessage: function (res) {
-        const user = wx.getStorageSync('user');
-        return {
-            title: '课文朗读,从未如此有趣。',
-            path: `/pages/index/index?uid=${user.uid}`,
-            imageUrl: 'http://reader-wx.ai160.com/images/reader/v3/shareContent.png'
-        }
-    },
-    onShareTimeline: function () {
-        return {
-            title: '终于找到适合孩子的朗读神器了!动画配音,边玩边学!',
-            query: `uid=${wx.getStorageSync('uid')}`,
-            imageUrl: 'http://reader-wx.ai160.com/images/reader/v3/yuwen.jpg'
-        }
-    },
+      }
+    })
+  },
+  // 分享配置
+  onShareAppMessage: function (res) {
+    const user = wx.getStorageSync('user');
+    return {
+      title: '课文朗读,从未如此有趣。',
+      path: `/pages/index/index?uid=${user.uid}`,
+      imageUrl: 'http://reader-wx.ai160.com/images/reader/v3/shareContent.png'
+    }
+  },
+  onShareTimeline: function () {
+    return {
+      title: '终于找到适合孩子的朗读神器了!动画配音,边玩边学!',
+      query: `uid=${wx.getStorageSync('uid')}`,
+      imageUrl: 'http://reader-wx.ai160.com/images/reader/v3/yuwen.jpg'
+    }
+  },
 })