فهرست منبع

开发挑战结果

bayi 2 سال پیش
والد
کامیت
506b33f58b

+ 39 - 38
app.json

@@ -1,40 +1,41 @@
 {
-    "pages": [
-        "pages/index/index",
-        "pages/score/index",
-        "pages/reading/index",
-        "pages/pkPage/index",
-        "pages/userWorks/index",
-        "pages/my/index",
-        "pages/editUser/index",
-        "pages/notice/index",
-        "pages/collection/index",
-        "pages/follow/index",
-        "pages/logs/logs"
-    ],
-    "tabBar": {
-        "custom": true,
-        "list": [{
-            "pagePath": "pages/my/index",
-            "text": "我的"
-        }, {
-            "pagePath": "pages/index/index",
-            "text": "推荐"
-        }, {
-            "pagePath": "pages/logs/logs",
-            "text": "作品"
-        }]
-    },
-    "window": {
-        "backgroundTextStyle": "light",
-        "navigationBarBackgroundColor": "#F2F6FC",
-        "navigationBarTitleText": "小学语文朗读配音",
-        "navigationBarTextStyle": "black",
-        "onReachBottomDistance": 50,
-        "enablePullDownRefresh": false
-    },
-    "resolveAlias": {
-        "~/*": "/*"
-    },
-    "sitemapLocation": "sitemap.json"
+  "pages": [
+    "pages/pkResult/index",
+    "pages/index/index",
+    "pages/score/index",
+    "pages/reading/index",
+    "pages/pkPage/index",
+    "pages/userWorks/index",
+    "pages/my/index",
+    "pages/editUser/index",
+    "pages/notice/index",
+    "pages/collection/index",
+    "pages/follow/index",
+    "pages/logs/logs"
+  ],
+  "tabBar": {
+    "custom": true,
+    "list": [{
+      "pagePath": "pages/my/index",
+      "text": "我的"
+    }, {
+      "pagePath": "pages/index/index",
+      "text": "推荐"
+    }, {
+      "pagePath": "pages/logs/logs",
+      "text": "作品"
+    }]
+  },
+  "window": {
+    "backgroundTextStyle": "light",
+    "navigationBarBackgroundColor": "#F2F6FC",
+    "navigationBarTitleText": "小学语文朗读配音",
+    "navigationBarTextStyle": "black",
+    "onReachBottomDistance": 50,
+    "enablePullDownRefresh": false
+  },
+  "resolveAlias": {
+    "~/*": "/*"
+  },
+  "sitemapLocation": "sitemap.json"
 }

+ 29 - 2
components/videoPreview/index.js

@@ -1,4 +1,10 @@
 import {
+  storeBindingsBehavior
+} from 'mobx-miniprogram-bindings'
+import {
+  store
+} from '~/store/index'
+import {
   setVideoStatus,
   likeVideo,
   collectVideo,
@@ -6,7 +12,18 @@ import {
 import {
   setFans
 } from '~/api/user'
+
 Component({
+  behaviors: [storeBindingsBehavior],
+  storeBindings: {
+    store,
+    fields: {
+      pkData: 'pkData'
+    },
+    actions: {
+      setPkData: 'setPkData'
+    }
+  },
   /**
    * 组件的属性列表
    */
@@ -175,8 +192,18 @@ Component({
       this.triggerEvent('setListFans', this.properties.videoInfo.user.uid)
     },
     toPkPage() {
-      let readId = this.data.videoInfoCopy.userRead.id
-      let url = this.properties.videoType == 'public' ? `/pages/pkPage/index?videoId=${readId}` : `/pages/reading/index?videoId=${this.data.videoInfoCopy.userRead.exampleId}`
+      let videoInfo = this.data.videoInfoCopy
+      console.log(this.data.videoInfoCopy);
+      if (this.properties.videoType == 'pk') {
+        this.setPkData({
+          nickName: videoInfo.user.nickName || videoInfo.user.eid,
+          avatar: videoInfo.user.avatar,
+          score: videoInfo.userRead.score,
+          audioPath: videoInfo.userRead.audioPath
+        })
+      }
+      let readId = videoInfo.userRead.id
+      let url = this.properties.videoType == 'public' ? `/pages/pkPage/index?videoId=${readId}` : `/pages/reading/index?videoId=${videoInfo.userRead.exampleId}&readingType=pk`
       wx.navigateTo({
         url
       })

+ 88 - 0
pages/pkResult/index.js

@@ -0,0 +1,88 @@
+import {
+  createStoreBindings
+} from 'mobx-miniprogram-bindings'
+import {
+  store
+} from '~/store/index'
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    victory: {},
+    defeated: {},
+  },
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad(options) {
+    this.storeBindings = createStoreBindings(this, {
+      store,
+      fields: {
+        userInfo: 'userInfo',
+        readDetail: 'readDetail',
+        pkData: 'pkData'
+      },
+    })
+    this.storeBindings.updateStoreBindings()
+    this.compareScore()
+  },
+  compareScore() {
+    let pkData = {
+      audioPath: "https://reader-wx.ai160.com/reader/resource/20221222/1671682237419428.mp3",
+      avatar: "wxfile://,tmp_ba795553cc21cd941badc3ce06597c245f08fd6a674fe165.jpg",
+      nickName: "小舞",
+      score: 96,
+    }
+    let score = pkData.score
+    let myResult = {
+      audioPath: this.data.readDetail.tempFilePath,
+      nickName: this.data.userInfo.nickName || this.data.userInfo.uid,
+      avatar: this.data.userInfo.avatar,
+      score: this.data.readDetail.myOverall || 100
+    }
+    this.setData({
+      victory: myResult.score > score ? myResult : pkData,
+      defeated: myResult.score < score ? myResult : pkData,
+    })
+
+  },
+  result() {
+
+  },
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload() {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh() {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom() {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage() {
+
+  }
+})

+ 6 - 0
pages/pkResult/index.json

@@ -0,0 +1,6 @@
+{
+  "usingComponents": {
+    "uploadFile": "/components/uploadFile/index"
+  },
+  "navigationBarTitleText": "挑战结果"
+}

+ 90 - 0
pages/pkResult/index.less

@@ -0,0 +1,90 @@
+.pkResult {
+  width: 100vw;
+  height: 100vh;
+  background-color: #2B2859;
+  overflow: hidden;
+
+  .title {
+    margin: 85rpx 0rpx 34rpx;
+    color: white;
+    text-align: center;
+    font-size: 46rpx;
+  }
+
+  .time {
+    font-size: 34rpx;
+    text-align: center;
+    color: white;
+  }
+
+  .body {
+    position: relative;
+    width: 720rpx;
+    height: 640rpx;
+    margin: 60rpx auto;
+    background-image: radial-gradient(50% 102%, #5171BD 1%, #21287A 100%);
+    box-shadow: 0 4rpx 10rpx 0 rgba(0, 0, 0, 0.30), inset 0 -2rpx 3rpx 0 #052552, inset 0 2rpx 3rpx 0;
+    border-radius: 20rpx;
+
+    .left {
+      position: absolute;
+      top: 30rpx;
+      left: 30rpx;
+      height: 500rpx;
+      width: 328rpx;
+      background: url('http://reader-wx.ai160.com/images/reader/v3/victory.png')no-repeat;
+      background-size: 100% 100%;
+    }
+
+    .right {
+      position: absolute;
+      top: 70rpx;
+      right: 30rpx;
+      height: 500rpx;
+      width: 328rpx;
+      background: url('http://reader-wx.ai160.com/images/reader/v3/defeated.png')no-repeat;
+      background-size: 100% 100%;
+    }
+
+    .avatar {
+      position: absolute;
+      width: 110rpx;
+      height: 110rpx;
+      border-radius: 50%;
+    }
+
+    .avatarL {
+      top: 64rpx;
+      left: 110rpx;
+    }
+
+    .avatarR {
+      top: 57rpx;
+      left: 107rpx;
+    }
+  }
+
+  .footer {
+    position: fixed;
+    bottom: 0px;
+    left: 0px;
+    width: 100%;
+    padding: 20rpx 104rpx;
+    box-sizing: border-box;
+    background-color: white;
+    display: flex;
+    align-items: center;
+    justify-content: space-between;
+
+    .stBtn {
+      padding: 16rpx 0rpx;
+      text-align: center;
+      border-radius: 50rpx;
+      width: 220rpx;
+      font-size: 30rpx;
+      color: white;
+      background-color: #66C5FF;
+      box-shadow: 0 6px 14px 0 rgba(50, 197, 255, 0.65);
+    }
+  }
+}

+ 17 - 0
pages/pkResult/index.wxml

@@ -0,0 +1,17 @@
+<view class="pkResult">
+  <view class="title">秋天</view>
+  <view class="time">2023-01-12 13:13</view>
+  <view class="body">
+    <view class="left">
+      <image src="{{victory.avatar}}" class="avatar avatarL" mode="" />
+      <view class="victory-title">{{victory.nickName}}</view>
+    </view>
+    <view class="right">
+      <image src="{{defeated.avatar}}" class="avatar avatarR" mode="" />
+    </view>
+  </view>
+  <view class="footer">
+    <view class="stBtn" bindtap="result">重新挑战</view>
+    <uploadFile />
+  </view>
+</view>

+ 80 - 0
pages/pkResult/index.wxss

@@ -0,0 +1,80 @@
+.pkResult {
+  width: 100vw;
+  height: 100vh;
+  background-color: #2B2859;
+  overflow: hidden;
+}
+.pkResult .title {
+  margin: 85rpx 0rpx 34rpx;
+  color: white;
+  text-align: center;
+  font-size: 46rpx;
+}
+.pkResult .time {
+  font-size: 34rpx;
+  text-align: center;
+  color: white;
+}
+.pkResult .body {
+  position: relative;
+  width: 720rpx;
+  height: 640rpx;
+  margin: 60rpx auto;
+  background-image: radial-gradient(50% 102%, #5171BD 1%, #21287A 100%);
+  box-shadow: 0 4rpx 10rpx 0 rgba(0, 0, 0, 0.3), inset 0 -2rpx 3rpx 0 #052552, inset 0 2rpx 3rpx 0;
+  border-radius: 20rpx;
+}
+.pkResult .body .left {
+  position: absolute;
+  top: 30rpx;
+  left: 30rpx;
+  height: 500rpx;
+  width: 328rpx;
+  background: url('http://reader-wx.ai160.com/images/reader/v3/victory.png') no-repeat;
+  background-size: 100% 100%;
+}
+.pkResult .body .right {
+  position: absolute;
+  top: 70rpx;
+  right: 30rpx;
+  height: 500rpx;
+  width: 328rpx;
+  background: url('http://reader-wx.ai160.com/images/reader/v3/defeated.png') no-repeat;
+  background-size: 100% 100%;
+}
+.pkResult .body .avatar {
+  position: absolute;
+  width: 110rpx;
+  height: 110rpx;
+  border-radius: 50%;
+}
+.pkResult .body .avatarL {
+  top: 64rpx;
+  left: 110rpx;
+}
+.pkResult .body .avatarR {
+  top: 57rpx;
+  left: 107rpx;
+}
+.pkResult .footer {
+  position: fixed;
+  bottom: 0px;
+  left: 0px;
+  width: 100%;
+  padding: 20rpx 104rpx;
+  box-sizing: border-box;
+  background-color: white;
+  display: flex;
+  align-items: center;
+  justify-content: space-between;
+}
+.pkResult .footer .stBtn {
+  padding: 16rpx 0rpx;
+  text-align: center;
+  border-radius: 50rpx;
+  width: 220rpx;
+  font-size: 30rpx;
+  color: white;
+  background-color: #66C5FF;
+  box-shadow: 0 6px 14px 0 rgba(50, 197, 255, 0.65);
+}

+ 11 - 2
pages/reading/index.js

@@ -35,6 +35,8 @@ Page({
     scrollTop: 0,
     //如果readingReset为true就是重读
     readingReset: false,
+    //readingType为public是普通阅读,为pk是pk逻辑
+    readingType: 'public',
     article: [{
       id: 1,
       text: '传说在很久很久以前,',
@@ -83,7 +85,8 @@ Page({
     })
     this.setData({
       article: data,
-      readingReset: options.reset || false
+      readingReset: options.reset || false,
+      readingType: options.readingType || 'public'
     })
     // 手工绑定 
     this.storeBindings = createStoreBindings(this, {
@@ -122,6 +125,7 @@ Page({
       console.log("===收到错误结果=============", res)
     });
   },
+  // 获取阅读内容
   async getreadInfo(videoId) {
     let videoInfo = await getreadInfo(videoId)
     wx.setNavigationBarTitle({
@@ -260,6 +264,11 @@ Page({
       scrollTop: 0
     })
   },
+  pkResult() {
+    wx.redirectTo({
+      url: `/pages/pkResult/index`,
+    })
+  },
   // 倒计时
   startRecording() {
     if (this.data.currentRow == null) {
@@ -306,7 +315,7 @@ Page({
     }
     this.setReadDetail(detail)
     wx.redirectTo({
-      url: `/pages/score/index`,
+      url: this.data.readingType == 'public' ? '/pages/score/index' : '/pages/pkResult/index',
     })
   },
   videoPlay() {

+ 2 - 2
pages/reading/index.wxml

@@ -72,8 +72,8 @@
     </view>
   </view>
   <view class="controller">
-    <image src="{{state?'/static/readingNow.gif':'/static/work.png'}}" class="playImg" bindtap="setCountDown" />
-    <view class="text">{{state?'完成录制':readingReset?'点击重录':'开始挑战'}}</view>
+    <image src="{{state?'/static/readingNow.gif':'/static/work.png'}}" class="playImg" bindtap="pkResult" />
+    <view class="text">{{state?'完成录制':readingReset?'点击重录':readingType=='public'?'开始朗读':'开始挑战'}}</view>
     <uploadFile wx:if="{{readingReset}}" class="btnPosition" />
   </view>
   <view class="playImgBg"></view>

+ 1 - 1
project.private.config.json

@@ -12,7 +12,7 @@
         {
           "name": "",
           "pathName": "pages/reading/index",
-          "query": "videoId=10312700101&reset=true",
+          "query": "videoId=10312700101&readingType=pk",
           "launchMode": "default",
           "scene": null
         },

+ 6 - 0
store/index.js

@@ -9,6 +9,8 @@ export const store = observable({
   userInfo: {},
   // 阅读结果
   readDetail: {},
+  //pk数据,包括被pk人的身份信息与录音得分
+  pkData: {},
   // 计算属性
   get sum() {
     return this.numA + this.numB
@@ -29,5 +31,9 @@ export const store = observable({
   setReadDetail: action(function (detail) {
     console.log('store中的', detail);
     this.readDetail = detail
+  }),
+  setPkData: action(function (data) {
+    console.log(data);
+    this.pkData = data
   })
 })