bayi пре 2 година
родитељ
комит
268daa4563
6 измењених фајлова са 480 додато и 478 уклоњено
  1. 25 23
      api/works.js
  2. 2 2
      pages/match/index.less
  3. 2 2
      pages/match/index.wxss
  4. 46 47
      pages/pkResult/index.js
  5. 11 10
      pages/pkResult/index.wxml
  6. 394 394
      pages/reading/index.js

+ 25 - 23
api/works.js

@@ -1,27 +1,29 @@
 import {
-    request
+  request
 } from "../utils/request";
 module.exports = {
-    // 获取作品类目
-    getCategoryList: data => request('/v3/column', 'get', data),
-    // 获取作品二级类目内容
-    getCategoryWorks: data => request('/v3/column/opus', 'get', data),
-    // 作品查询
-    searchWorks: data => request('/v3/recommend/query', 'get', data),
-    // 获取优秀作品展播列表
-    getHotrecommendList: data => request('/userRead/recommend', 'get', data),
-    // 获取官方推荐作品列表
-    getAuthorityList: data => request('/v3/recommend', 'get', data),
-    // 发布作品
-    publishWorks: data => request('/userRead', 'post', data),
-    // 上传挑战结果
-    uploadPk: data => request('/v3/pk', 'post', data),
-    // 获取关注的人的作品
-    getFollowWorks: data => request('/fans/interest', 'get', data),
-    // 获取作品的挑战记录
-    getPkRecord: data => request('/v3/pk', 'get', data),
-    // 发布朗读赛作品
-    publishRankWorks: data => request('/activityRead', 'post', data),
-    // 上传作品评分
-    postWorksScore: data => request('/assessment', 'post', data),
+  // 获取作品类目
+  getCategoryList: data => request('/v3/column', 'get', data),
+  // 获取作品二级类目内容
+  getCategoryWorks: data => request('/v3/column/opus', 'get', data),
+  // 作品查询
+  searchWorks: data => request('/v3/recommend/query', 'get', data),
+  // 获取优秀作品展播列表
+  getHotrecommendList: data => request('/userRead/recommend', 'get', data),
+  // 获取官方推荐作品列表
+  getAuthorityList: data => request('/v3/recommend', 'get', data),
+  // 发布作品
+  publishWorks: data => request('/userRead', 'post', data),
+  // 上传挑战结果
+  uploadPk: data => request('/v3/pk', 'post', data),
+  // 获取挑战结果
+  getPkResult: data => request(`/v3/pk/info/${data}`, 'get'),
+  // 获取作品的挑战记录
+  getPkRecord: data => request('/v3/pk', 'get', data),
+  // 获取关注的人的作品
+  getFollowWorks: data => request('/fans/interest', 'get', data),
+  // 发布朗读赛作品
+  publishRankWorks: data => request('/activityRead', 'post', data),
+  // 上传作品评分
+  postWorksScore: data => request('/assessment', 'post', data),
 }

+ 2 - 2
pages/match/index.less

@@ -195,7 +195,7 @@
     display: block;
     margin: 0px auto;
     padding:50rpx 0rpx;
-    width: 492rpx;
-    height: 404rpx;
+    width: 393rpx;
+    height: 323rpx;
   }
 }

+ 2 - 2
pages/match/index.wxss

@@ -165,6 +165,6 @@
   display: block;
   margin: 0px auto;
   padding: 50rpx 0rpx;
-  width: 492rpx;
-  height: 404rpx;
+  width: 393rpx;
+  height: 323rpx;
 }

+ 46 - 47
pages/pkResult/index.js

@@ -1,9 +1,6 @@
 import {
-  createStoreBindings
-} from 'mobx-miniprogram-bindings'
-import {
-  store
-} from '~/store/index'
+  getPkResult
+} from '~/api/works'
 let innerAudioContext
 Page({
 
@@ -11,6 +8,8 @@ Page({
    * 页面的初始数据
    */
   data: {
+    pkId: '',
+    pkRecord: {},
     vState: false,
     vStart: '00:00',
     vEnd: '00:00',
@@ -22,38 +21,37 @@ Page({
     currentType: '',
     victory: {},
     defeated: {},
-    equal: false
+    equal: false,
+    // 是否是分享进来的
+    isPlayback: false
   },
   /**
    * 生命周期函数--监听页面加载
    */
-  onLoad(options) {
-    console.log(options);
-    this.storeBindings = createStoreBindings(this, {
-      store,
-      fields: {
-        userInfo: 'userInfo',
-        readDetail: 'readDetail',
-        pkData: 'pkData'
-      },
+  async onLoad(options) {
+    let {
+      pkRecord,
+      pkRecordVOS
+    } = await getPkResult(options.id)
+    this.setData({
+      pkId: options.id,
+      pkRecord,
+      isplayback: options.playback || false
     })
-    this.storeBindings.updateStoreBindings()
-    this.compareScore()
+    this.compareScore(pkRecordVOS)
     this.innerAudioContext = wx.createInnerAudioContext()
   },
-  compareScore() {
-    let pkData = this.data.pkData
-    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 || 97
-    }
+  compareScore(resultData) {
+    let first = resultData[0]
+    let second = resultData[1]
+    let victory = first.userRead.score > second.userRead.score ? first : second
+    let defeated = second.userRead.score <= first.userRead.score ? second : first
     this.setData({
-      equal: score == myResult.score,
-      victory: myResult.score > score ? myResult : pkData,
-      defeated: myResult.score <= score ? myResult : pkData,
+      equal: first.userRead.score == second.userRead.score,
+      victory: first.userRead.score > second.userRead.score ? first : second,
+      defeated,
+      vEnd: this.setDuration(victory.userRead.duration),
+      dEnd: this.setDuration(defeated.userRead.duration),
     })
   },
   playAudio({
@@ -67,7 +65,7 @@ Page({
     // 处理音频播放
     if (type == 'victory' && !this.data.vState) {
       if (this.data.currentType != 'victory') {
-        this.innerAudioContext.src = this.data.victory.audioPath
+        this.innerAudioContext.src = this.data.victory.userRead.audioPath
       }
       this.setData({
         vState: true,
@@ -80,7 +78,7 @@ Page({
       })
     } else if (type == 'defeated' && !this.data.dState) {
       if (this.data.currentType != 'defeated') {
-        this.innerAudioContext.src = this.data.defeated.audioPath;
+        this.innerAudioContext.src = this.data.defeated.userRead.audioPath;
       }
       this.setData({
         dState: true,
@@ -99,7 +97,12 @@ Page({
     this.innerAudioContext.play();
     // })
     this.innerAudioContext.onTimeUpdate(() => {
-      this.setDuration(this.innerAudioContext.currentTime)
+      let label = this.data.currentType == 'victory' ? 'vStart' : 'dStart'
+      let progressV = this.data.currentType == 'victory' ? 'vProgress' : 'dProgress'
+      this.setData({
+        [label]: this.setDuration(this.innerAudioContext.currentTime),
+        [progressV]: Math.round((this.innerAudioContext.currentTime / this.innerAudioContext.duration) * 100)
+      })
     })
   },
   // 设置时间文案
@@ -118,16 +121,12 @@ Page({
       }
       t += sec;
     }
-    let label = this.data.currentType == 'victory' ? 'vStart' : 'dStart'
-    let progressV = this.data.currentType == 'victory' ? 'vProgress' : 'dProgress'
-    this.setData({
-      [label]: t,
-      [progressV]: Math.round((this.innerAudioContext.currentTime / this.innerAudioContext.duration) * 100)
-    })
+    return t
+
   },
   result() {
     wx.redirectTo({
-      url: `/pages/reading/index?videoId=${this.data.pkData.exampleId}&readingType=pk&reset=true`,
+      url: `/pages/reading/index?videoId=${this.data.victory.userRead.exampleId}&readingType=pk`,
     })
   },
   /**
@@ -159,17 +158,17 @@ Page({
             ctx.textAlign = "center";
             var lnamex = this.data.equal ? 100 : 100,
               lnamey = this.data.equal ? 125 : 115;
-            ctx.fillText(this.data.victory.nickName, lnamex, lnamey)
+            ctx.fillText(this.data.victory.user.nickName, lnamex, lnamey)
             var rnamex = this.data.equal ? 280 : 280,
               rnamey = this.data.equal ? 125 : 140;
-            ctx.fillText(this.data.defeated.nickName, rnamex, rnamey)
+            ctx.fillText(this.data.defeated.user.nickName, rnamex, rnamey)
             ctx.font = '19px PingFang';
             var lnumx = this.data.equal ? 100 : 100,
               lnumy = this.data.equal ? 150 : 140;
-            ctx.fillText(this.data.victory.score + '分', lnumx, lnumy)
+            ctx.fillText(this.data.victory.userRead.score + '分', lnumx, lnumy)
             var rnumx = this.data.equal ? 280 : 280,
               rnumy = this.data.equal ? 150 : 165;
-            ctx.fillText(this.data.defeated.score + '分', rnumx, rnumy)
+            ctx.fillText(this.data.defeated.userRead.score + '分', rnumx, rnumy)
             ctx.font = '13px PingFang';
             var ltimex = this.data.equal ? 136 : 136,
               ltimey = this.data.equal ? 252.5 : 239.5;
@@ -188,7 +187,7 @@ Page({
             ctx.arc(size / 2 + rx, size / 2 + ry, size / 2, 0, Math.PI * 2, false);
             ctx.clip();
             let leftImg = canvas.createImage();
-            leftImg.src = this.data.victory.avatar
+            leftImg.src = this.data.victory.user.avatar
             leftImg.onerror = () => {
               loadRightImg()
             }
@@ -199,16 +198,16 @@ Page({
 
             let loadRightImg = () => {
               let rightImg = canvas.createImage();
-              rightImg.src = this.data.defeated.avatar
+              rightImg.src = this.data.defeated.user.avatar
               rightImg.onload = () => {
                 ctx.drawImage(rightImg, rx, ry, size, size)
                 setTimeout(() => {
                   wx.canvasToTempFilePath({
                     canvas: canvas,
-                    success(res) {
+                    success: (res) => {
                       resolve({
                         title: '请欣赏我的课文朗读作品,点赞+评论。',
-                        path: `/pages/pkResult/index?uid=${wx.getStorageSync('uid')}`,
+                        path: `/pages/pkResult/index?id=${this.data.pkId}&uid=${wx.getStorageSync('uid')}&playback=true`,
                         imageUrl: res.tempFilePath
                       })
                     },

+ 11 - 10
pages/pkResult/index.wxml

@@ -1,11 +1,12 @@
+<wxs src="../../utils/filter.wxs" module="filters" />
 <view class="pkResult">
-  <view class="title">{{readDetail.title}}</view>
-  <view class="time">2023-01-12 13:13</view>
+  <view class="title">{{victory.userRead.title}}</view>
+  <view class="time">{{filters.formatDate(pkRecord.gmtCreated,1)}}</view>
   <view class="body">
     <view class="left {{equal?'equal':''}}">
-      <image src="{{victory.avatar}}" class="avatar avatarL" mode="" />
-      <view class="bodyTitle textOver">{{victory.nickName}}</view>
-      <view class="bodyScore">{{victory.score}}分</view>
+      <image src="{{victory.user.avatar}}" class="avatar avatarL" />
+      <view class="bodyTitle textOver">{{victory.user.nickName}}</view>
+      <view class="bodyScore">{{victory.userRead.score}}分</view>
       <image src="{{vState?'/static/work.png':'/static/play-big.png'}}" class="bodyPlay" bindtap="playAudio"
         data-type="victory" />
       <progress percent="{{vProgress}}" stroke-width="4" class="progress" style="margin-right:48rpx;" />
@@ -15,9 +16,9 @@
       </view>
     </view>
     <view class="right {{equal?'equalRight':''}}">
-      <image src="{{defeated.avatar}}" class="avatar avatarR" mode="" />
-      <view class="bodyTitle textOver">{{defeated.nickName}}</view>
-      <view class="bodyScore">{{defeated.score}}分</view>
+      <image src="{{defeated.user.avatar}}" class="avatar avatarR" />
+      <view class="bodyTitle textOver">{{defeated.user.nickName}}</view>
+      <view class="bodyScore">{{defeated.userRead.score}}分</view>
       <image src="{{dState?'/static/work.png':'/static/play-big.png'}}" class="bodyPlay" bindtap="playAudio"
         data-type="defeated" />
       <progress percent="{{dProgress}}" stroke-width="4" class="progress" />
@@ -27,11 +28,11 @@
       </view>
     </view>
   </view>
-  <view class="footer">
+  <view class="footer" wx:if="{{!isplayback}}">
     <view class="stBtn" bindtap="result">重新挑战</view>
     <button class="resetBtn btn" open-type="share">
       分享
     </button>
   </view>
 </view>
-<canvas id='share'  type="2d"> </canvas>
+<canvas id='share' type="2d"> </canvas>

+ 394 - 394
pages/reading/index.js

@@ -1,19 +1,19 @@
 import {
-    getreadInfo
+  getreadInfo
 } from '~/api/video'
 import {
-    publishWorks,
-    uploadPk,
-    postWorksScore
+  publishWorks,
+  uploadPk,
+  postWorksScore
 } from '~/api/works'
 import {
-    userEvent
+  userEvent
 } from '~/api/global'
 import {
-    createStoreBindings
+  createStoreBindings
 } from 'mobx-miniprogram-bindings'
 import {
-    store
+  store
 } from '~/store/index'
 const aiengine = require('~/utils/ChivoxAiEngine')
 const sha1 = require('~/utils/sha1');
@@ -32,408 +32,408 @@ let wsEngine = aiengine.createWsEngine({});
 /*微信录音*/
 let recorderManager = wx.getRecorderManager();
 Page({
-    data: {
-        videoInfo: {},
-        currentRow: null,
-        state: false,
-        countDown: {
-            state: false,
-            num: 3,
-        },
-        contentH: 0,
-        scrollTop: 0,
-        //如果readingReset为true就是重读
-        readingReset: false,
-        //readingType为public是普通阅读,为pk是pk逻辑,readMatch为朗读赛
-        readingType: 'public',
-        percent: 0,
-        uploadState: false,
-        article: []
+  data: {
+    videoInfo: {},
+    currentRow: null,
+    state: false,
+    countDown: {
+      state: false,
+      num: 3,
     },
-    onLoad(options) {
-        let videoId = options.videoId
-        this.getreadInfo(videoId, options.reset)
-        console.log(options, 'options');
-        this.setData({
-            readingReset: options.reset || false,
-            readingType: options.readingType || 'public'
-        })
-        // 手工绑定 
-        this.storeBindings = createStoreBindings(this, {
-            store,
-            fields: {
-                userInfo: 'userInfo',
-                readDetail: 'readDetail',
-                pkData: 'pkData'
-            },
-            actions: {
-                setReadDetail: 'setReadDetail'
-            }
-        })
+    contentH: 0,
+    scrollTop: 0,
+    //如果readingReset为true就是重读
+    readingReset: false,
+    //readingType为public是普通阅读,为pk是pk逻辑,readMatch为朗读赛
+    readingType: 'public',
+    percent: 0,
+    uploadState: false,
+    article: []
+  },
+  onLoad(options) {
+    let videoId = options.videoId
+    this.getreadInfo(videoId, options.reset)
+    console.log(options, 'options');
+    this.setData({
+      readingReset: options.reset || false,
+      readingType: options.readingType || 'public'
+    })
+    // 手工绑定 
+    this.storeBindings = createStoreBindings(this, {
+      store,
+      fields: {
+        userInfo: 'userInfo',
+        readDetail: 'readDetail',
+        pkData: 'pkData'
+      },
+      actions: {
+        setReadDetail: 'setReadDetail'
+      }
+    })
 
-        // 录音授权
-        wx.getSetting({
-            success(res) {
-                if (!res.authSetting['scope.record']) {
-                    wx.authorize({
-                        scope: 'scope.record',
-                        success() {
-                            // 用户已经同意小程序使用录音功能,后续调用接口不会弹窗询问
-                            wx.getRecorderManager()
-                        }
-                    })
-                }
+    // 录音授权
+    wx.getSetting({
+      success(res) {
+        if (!res.authSetting['scope.record']) {
+          wx.authorize({
+            scope: 'scope.record',
+            success() {
+              // 用户已经同意小程序使用录音功能,后续调用接口不会弹窗询问
+              wx.getRecorderManager()
             }
-        })
-        /*监听评测结果:必须在基础引擎创建后,调用任何评测接口前设置监听,否则有可能收不到相关事件。*/
-        wsEngine.onResult((res) => {
-            this.getRecordScore(res)
-        });
-        wsEngine.onErrorResult((res) => {
-            console.log("===收到错误结果=============", res)
-        });
-    },
-    // 获取阅读内容
-    async getreadInfo(videoId, reset = false) {
-        let videoInfo = await getreadInfo(videoId)
-        wx.setNavigationBarTitle({
-            title: videoInfo.userRead.title
-        })
-        let data = JSON.parse(videoInfo.userReadExtend.lessonText)
-        data = data.map((item, index) => {
-            item.time = Number(item.time)
-            item.readTime = data[index + 1] ? data[index + 1].time - item.time : ''
-            return item
-        })
-
-        this.setData({
-            article: data,
-            videoInfo
-        })
-        if (!reset) {
-            this.getHeight()
-        }
-        if (!this.data.videoInfo.userReadExtend || this.data.videoInfo.userReadExtend.resourcesType == 0) {
-            this.videoContext = wx.createVideoContext('myVideo')
-        } else {
-            this.innerAudioContext = wx.createInnerAudioContext();
-            this.innerAudioContext.src = videoInfo.userRead.audioPath
-            this.innerAudioContext.onEnded(res => {
-                this.finishRecord()
-            })
-            this.innerAudioContext.onStop((res) => {
-                this.finishRecord()
-            });
+          })
         }
+      }
+    })
+    /*监听评测结果:必须在基础引擎创建后,调用任何评测接口前设置监听,否则有可能收不到相关事件。*/
+    wsEngine.onResult((res) => {
+      this.getRecordScore(res)
+    });
+    wsEngine.onErrorResult((res) => {
+      console.log("===收到错误结果=============", res)
+    });
+  },
+  // 获取阅读内容
+  async getreadInfo(videoId, reset = false) {
+    let videoInfo = await getreadInfo(videoId)
+    wx.setNavigationBarTitle({
+      title: videoInfo.userRead.title
+    })
+    let data = JSON.parse(videoInfo.userReadExtend.lessonText)
+    data = data.map((item, index) => {
+      item.time = Number(item.time)
+      item.readTime = data[index + 1] ? data[index + 1].time - item.time : ''
+      return item
+    })
 
-    },
-    // 开始录制
-    setCountDown() {
-        let child = this.selectComponent('#readingTips').data
-        // 判断是否有权限朗读 不是vip并且没有朗读机会
-        const isVip = child.vipTime ? true : false
-        if (!isVip && child.userInfo.experienceAmount == 0) {
-            return this.selectComponent('#readingTips').showModal();
-        }
-        if (this.data.state) {
-            this.finishRecord()
-            return
-        }
-        if (this.data.readingReset) {
-            this.clearReset()
-            this.getHeight()
-        }
-        this.setData({
-            'countDown.state': true
-        })
-        this.stl = setInterval(() => {
-            if (this.data.countDown.num == 0) {
-                clearInterval(this.stl)
-                this.setData({
-                    state: true,
-                    countDown: {
-                        state: false,
-                        num: 3
-                    }
-                })
-                this.soundRecording()
-                this.playMediaState()
-                this.startRecording()
-            } else {
-                this.setData({
-                    'countDown.num': --this.data.countDown.num
-                })
-            }
-        }, 1000)
-    },
-    // 录音
-    soundRecording() {
-        /*调用微信开始录音接口,并启动语音评测*/
-        let timeStamp = new Date().getTime()
-        let sig = sha1(`16075689600000da${timeStamp}caa8e60da6042731c230fe431ac9c7fd`)
-        let app = {
-            applicationId: '16075689600000da',
-            sig, //签名字符串 
-            alg: 'sha1',
-            timestamp: timeStamp + '',
-            userId: wx.getStorageSync('uid')
-        }
-        let lessonText = JSON.parse(this.data.videoInfo.userReadExtend.lessonText).map((item) => {
-            return item.text
-        }).join('\n')
-        wsEngine.start({
-            request: {
-                coreType: "cn.pred.raw",
-                refText: lessonText,
-                rank: 100,
-                attachAudioUrl: 1,
-                result: {
-                    details: {
-                        gop_adjust: 1
-                    }
-                }
-            },
-            app,
-            audio: {
-                audioType: "mp3",
-                channel: 1,
-                sampleBytes: 2,
-                sampleRate: 16000
-            },
-            success: (res) => {
-                /*引擎启动成功,可以启动录音机开始录音,并将音频片传给引擎*/
-                const options = {
-                    sampleRate: 44100, //采样率
-                    numberOfChannels: 1, //录音通道数
-                    encodeBitRate: 192000, //编码码率
-                    format: 'mp3', //音频格式,有效值aac/mp3
-                    frameSize: 50 //指定帧大小,单位 KB
-                };
-                //开始录音,在开始录音回调中feed音频片
-                recorderManager.start(options);
-            },
-            fail: (res) => {
-                console.log("fail=============  " + res);
-            },
-        });
-        //监听录音开始事件
-        recorderManager.onStart(() => {});
-        //监听录音结束事件
-        recorderManager.onStop((res) => {
-            console.log('录音结束', res);
-            this.setData({
-                tempFilePath: res.tempFilePath,
-            });
-            //录音机结束后,驰声引擎执行结束操作,等待评测返回结果
-            wsEngine.stop({
-                success: () => {
-                    console.log('====== wsEngine stop success ======');
-                },
-                fail: (res) => {
-                    console.log('录音结束报错', res);
-                },
-            });
-        });
-        //监听已录制完指定帧大小的文件事件。如果设置了 frameSize,则会回调此事件。
-        recorderManager.onFrameRecorded((res) => {
-            const {
-                frameBuffer
-            } = res
-            //TODO 调用feed接口传递音频片给驰声评测引擎
-            wsEngine.feed({
-                data: frameBuffer, // frameBuffer为微信录音机回调的音频数据
-                success: () => {},
-                fail: (res) => {
-                    console.log('监听已录制完指定帧大小报错', res)
-                },
-            });
-        });
-    },
-    // 结束录制
-    finishRecord() {
-        recorderManager.stop();
-        this.stopMediaState()
-        clearTimeout(this.setTimeoutObj)
+    this.setData({
+      article: data,
+      videoInfo
+    })
+    if (!reset) {
+      this.getHeight()
+    }
+    if (!this.data.videoInfo.userReadExtend || this.data.videoInfo.userReadExtend.resourcesType == 0) {
+      this.videoContext = wx.createVideoContext('myVideo')
+    } else {
+      this.innerAudioContext = wx.createInnerAudioContext();
+      this.innerAudioContext.src = videoInfo.userRead.audioPath
+      this.innerAudioContext.onEnded(res => {
+        this.finishRecord()
+      })
+      this.innerAudioContext.onStop((res) => {
+        this.finishRecord()
+      });
+    }
+
+  },
+  // 开始录制
+  setCountDown() {
+    let child = this.selectComponent('#readingTips').data
+    // 判断是否有权限朗读 不是vip并且没有朗读机会
+    const isVip = child.vipTime ? true : false
+    if (!isVip && child.userInfo.experienceAmount == 0) {
+      return this.selectComponent('#readingTips').showModal();
+    }
+    if (this.data.state) {
+      this.finishRecord()
+      return
+    }
+    if (this.data.readingReset) {
+      this.clearReset()
+      this.getHeight()
+    }
+    this.setData({
+      'countDown.state': true
+    })
+    this.stl = setInterval(() => {
+      if (this.data.countDown.num == 0) {
         clearInterval(this.stl)
         this.setData({
+          state: true,
+          countDown: {
             state: false,
-            currentRow: null,
-            scrollTop: 0
+            num: 3
+          }
         })
-    },
-    // 获取测评结果
-    getRecordScore(res) {
-        const result = res.result;
-        const integrity = Math.floor(result.integrity); //完成度
-        const tone = Math.floor(result.tone); // 语调声调
-        const accuracy = Math.floor(result.overall); // 准确度 发音分
-        const fluency = Math.floor(result.fluency.overall); //流利度
-        let myOverall = Math.floor(integrity * 0.3 + accuracy * 0.5 + fluency * 0.1 + tone * 0.1);
-        let detail = {
-            integrity,
-            tone,
-            accuracy,
-            fluency,
-            myOverall,
-            tempFilePath: this.data.tempFilePath,
-            title: this.data.videoInfo.userRead.title,
-            id: this.data.videoInfo.userRead.exampleId,
-            coverImg: this.data.videoInfo.userRead.coverImg,
-            originVideo: this.data.videoInfo.userRead.originVideo
-        }
-        this.setReadDetail(detail)
-        if (this.data.readingType == 'public' || this.data.readingType == 'readMatch') {
-            wx.redirectTo({
-                url: `/pages/score/index?readingType=${this.data.readingType}`
-            })
-        } else {
-            this.uploadAudio(detail)
-        }
-    },
-    // 挑战录音上传
-    uploadAudio(detail) {
+        this.soundRecording()
+        this.playMediaState()
+        this.startRecording()
+      } else {
         this.setData({
-            uploadState: true
+          'countDown.num': --this.data.countDown.num
         })
-        const uploadTask = wx.uploadFile({
-            url: 'https://reader-api.ai160.com//file/upload',
-            filePath: this.data.tempFilePath,
-            name: '朗读录音',
-            header: {
-                uid: wx.getStorageSync('uid')
-            },
-            success: async (res) => {
-                const formateRes = JSON.parse(res.data);
-                let audioPath = formateRes.data;
-                let uploadRes = await publishWorks({
-                    exampleId: this.data.pkData.exampleId,
-                    audioPath
-                })
-                let _data = this.data.readDetail
-                postWorksScore({
-                    "userReadId": uploadRes.id,
-                    "complete": _data.integrity,
-                    "accuracy": _data.accuracy,
-                    "speed": _data.fluency,
-                    "intonation": _data.tone,
-                    "score": _data.myOverall
-                })
-                let data = {
-                    challengerUserReadId: uploadRes.id,
-                    userReadId: this.data.pkData.id,
-                }
-                let result = await uploadPk(data)
-                console.log(result, 'pk结果');
-                wx.redirectTo({
-                    url: '/pages/pkResult/index'
-                })
-            },
-            complete: () => {
-                this.setData({
-                    uploadState: false
-                })
-            }
-        });
-        uploadTask.onProgressUpdate((res) => {
-            this.setData({
-                percent: res.progress
-            })
+      }
+    }, 1000)
+  },
+  // 录音
+  soundRecording() {
+    /*调用微信开始录音接口,并启动语音评测*/
+    let timeStamp = new Date().getTime()
+    let sig = sha1(`16075689600000da${timeStamp}caa8e60da6042731c230fe431ac9c7fd`)
+    let app = {
+      applicationId: '16075689600000da',
+      sig, //签名字符串 
+      alg: 'sha1',
+      timestamp: timeStamp + '',
+      userId: wx.getStorageSync('uid')
+    }
+    let lessonText = JSON.parse(this.data.videoInfo.userReadExtend.lessonText).map((item) => {
+      return item.text
+    }).join('\n')
+    wsEngine.start({
+      request: {
+        coreType: "cn.pred.raw",
+        refText: lessonText,
+        rank: 100,
+        attachAudioUrl: 1,
+        result: {
+          details: {
+            gop_adjust: 1
+          }
+        }
+      },
+      app,
+      audio: {
+        audioType: "mp3",
+        channel: 1,
+        sampleBytes: 2,
+        sampleRate: 16000
+      },
+      success: (res) => {
+        /*引擎启动成功,可以启动录音机开始录音,并将音频片传给引擎*/
+        const options = {
+          sampleRate: 44100, //采样率
+          numberOfChannels: 1, //录音通道数
+          encodeBitRate: 192000, //编码码率
+          format: 'mp3', //音频格式,有效值aac/mp3
+          frameSize: 50 //指定帧大小,单位 KB
+        };
+        //开始录音,在开始录音回调中feed音频片
+        recorderManager.start(options);
+      },
+      fail: (res) => {
+        console.log("fail=============  " + res);
+      },
+    });
+    //监听录音开始事件
+    recorderManager.onStart(() => {});
+    //监听录音结束事件
+    recorderManager.onStop((res) => {
+      console.log('录音结束', res);
+      this.setData({
+        tempFilePath: res.tempFilePath,
+      });
+      //录音机结束后,驰声引擎执行结束操作,等待评测返回结果
+      wsEngine.stop({
+        success: () => {
+          console.log('====== wsEngine stop success ======');
+        },
+        fail: (res) => {
+          console.log('录音结束报错', res);
+        },
+      });
+    });
+    //监听已录制完指定帧大小的文件事件。如果设置了 frameSize,则会回调此事件。
+    recorderManager.onFrameRecorded((res) => {
+      const {
+        frameBuffer
+      } = res
+      //TODO 调用feed接口传递音频片给驰声评测引擎
+      wsEngine.feed({
+        data: frameBuffer, // frameBuffer为微信录音机回调的音频数据
+        success: () => {},
+        fail: (res) => {
+          console.log('监听已录制完指定帧大小报错', res)
+        },
+      });
+    });
+  },
+  // 结束录制
+  finishRecord() {
+    recorderManager.stop();
+    this.stopMediaState()
+    clearTimeout(this.setTimeoutObj)
+    clearInterval(this.stl)
+    this.setData({
+      state: false,
+      currentRow: null,
+      scrollTop: 0
+    })
+  },
+  // 获取测评结果
+  getRecordScore(res) {
+    const result = res.result;
+    const integrity = Math.floor(result.integrity); //完成度
+    const tone = Math.floor(result.tone); // 语调声调
+    const accuracy = Math.floor(result.overall); // 准确度 发音分
+    const fluency = Math.floor(result.fluency.overall); //流利度
+    let myOverall = Math.floor(integrity * 0.3 + accuracy * 0.5 + fluency * 0.1 + tone * 0.1);
+    let detail = {
+      integrity,
+      tone,
+      accuracy,
+      fluency,
+      myOverall,
+      tempFilePath: this.data.tempFilePath,
+      title: this.data.videoInfo.userRead.title,
+      id: this.data.videoInfo.userRead.exampleId,
+      coverImg: this.data.videoInfo.userRead.coverImg,
+      originVideo: this.data.videoInfo.userRead.originVideo
+    }
+    this.setReadDetail(detail)
+    if (this.data.readingType == 'public' || this.data.readingType == 'readMatch') {
+      wx.redirectTo({
+        url: `/pages/score/index?readingType=${this.data.readingType}`
+      })
+    } else {
+      this.uploadAudio(detail)
+    }
+  },
+  // 挑战录音上传
+  uploadAudio(detail) {
+    this.setData({
+      uploadState: true
+    })
+    const uploadTask = wx.uploadFile({
+      url: 'https://reader-api.ai160.com//file/upload',
+      filePath: this.data.tempFilePath,
+      name: '朗读录音',
+      header: {
+        uid: wx.getStorageSync('uid')
+      },
+      success: async (res) => {
+        const formateRes = JSON.parse(res.data);
+        let audioPath = formateRes.data;
+        let uploadRes = await publishWorks({
+          exampleId: this.data.pkData.exampleId,
+          audioPath
         })
-    },
-    // 测试的
-    pkResult() {
-        wx.redirectTo({
-            url: `/pages/score/index?readingType=${this.data.readingType}`
+        let _data = this.data.readDetail
+        postWorksScore({
+          "userReadId": uploadRes.id,
+          "complete": _data.integrity,
+          "accuracy": _data.accuracy,
+          "speed": _data.fluency,
+          "intonation": _data.tone,
+          "score": _data.myOverall
         })
-        /* wx.redirectTo({
-          url: `/pages/pkResult/index`,
-        }) */
-    },
-    // 字体换行
-    startRecording() {
-        if (this.data.currentRow == null) {
-            this.setData({
-                currentRow: 0
-            })
-        }
-        let row = this.data.article[this.data.currentRow]
-        if (!row.readTime) {
-            return
-        }
-        this.setTimeoutObj = setTimeout(() => {
-                this.setData({
-                    currentRow: ++this.data.currentRow
-                })
-                this.setData({
-                    scrollTop: this.rowH * this.data.currentRow
-                })
-                this.startRecording()
-            },
-            row.readTime);
-    },
-    // 视频播放结束
-    videoEnd() {
-        this.finishRecord()
-    },
-    videoPlay() {
-        if (this.data.readingReset) {
-            this.resultAudioContext = wx.createInnerAudioContext();
-            this.resultAudioContext.src = this.data.readDetail.tempFilePath; // 这里可以是录音的临时路径
-            this.resultAudioContext.play();
-        }
-    },
-    // 清除试听状态
-    clearReset() {
-        if (this.resultAudioContext) {
-            this.resultAudioContext.stop()
+        let data = {
+          challengerUserReadId: uploadRes.id,
+          userReadId: this.data.pkData.id,
         }
+        let result = await uploadPk(data)
+        console.log(result, 'pk结果');
+        wx.redirectTo({
+          url: `/pages/pkResult/index?id=${result.id}`
+        })
+      },
+      complete: () => {
         this.setData({
-            readingReset: false
+          uploadState: false
         })
-    },
-    // 控制视频或音频的播放状态
-    async playMediaState() {
-        if (!this.data.videoInfo.userReadExtend || this.data.videoInfo.userReadExtend.resourcesType == 0) {
-            this.videoContext.play()
-        } else {
-            this.innerAudioContext.play();
-        }
-        await userEvent({
-            action: 'READING',
-            readId: this.data.videoInfo.userRead.id
+      }
+    });
+    uploadTask.onProgressUpdate((res) => {
+      this.setData({
+        percent: res.progress
+      })
+    })
+  },
+  // 测试的
+  pkResult() {
+    wx.redirectTo({
+      url: `/pages/score/index?readingType=${this.data.readingType}`
+    })
+    /* wx.redirectTo({
+      url: `/pages/pkResult/index`,
+    }) */
+  },
+  // 字体换行
+  startRecording() {
+    if (this.data.currentRow == null) {
+      this.setData({
+        currentRow: 0
+      })
+    }
+    let row = this.data.article[this.data.currentRow]
+    if (!row.readTime) {
+      return
+    }
+    this.setTimeoutObj = setTimeout(() => {
+        this.setData({
+          currentRow: ++this.data.currentRow
         })
-    },
-    // 控制视频或音频的暂停状态
-    stopMediaState() {
-        if (!this.data.videoInfo.userReadExtend || this.data.videoInfo.userReadExtend.resourcesType == 0) {
-            this.videoContext.stop()
-            this.videoContext.seek(0)
-        } else {
-            this.innerAudioContext.stop()
-        }
-    },
-    // 获取设备高度与行高度
-    getHeight() {
-        var query = wx.createSelectorQuery();
-        query.select('.content').boundingClientRect((rect) => {
-            this.setData({
-                contentH: rect.height
-            })
-        }).exec()
-        query.select('.row').boundingClientRect((rect) => {
-            this.rowH = rect.height
-        }).exec()
-    },
-    /**
-     * 生命周期函数--监听页面卸载
-     */
-    onUnload() {
-        wsEngine.reset()
-        recorderManager.stop();
-        if (this.innerAudioContext) {
-            this.innerAudioContext.stop()
-        }
-        clearTimeout(this.setTimeoutObj)
-        clearInterval(this.stl)
-    },
+        this.setData({
+          scrollTop: this.rowH * this.data.currentRow
+        })
+        this.startRecording()
+      },
+      row.readTime);
+  },
+  // 视频播放结束
+  videoEnd() {
+    this.finishRecord()
+  },
+  videoPlay() {
+    if (this.data.readingReset) {
+      this.resultAudioContext = wx.createInnerAudioContext();
+      this.resultAudioContext.src = this.data.readDetail.tempFilePath; // 这里可以是录音的临时路径
+      this.resultAudioContext.play();
+    }
+  },
+  // 清除试听状态
+  clearReset() {
+    if (this.resultAudioContext) {
+      this.resultAudioContext.stop()
+    }
+    this.setData({
+      readingReset: false
+    })
+  },
+  // 控制视频或音频的播放状态
+  async playMediaState() {
+    if (!this.data.videoInfo.userReadExtend || this.data.videoInfo.userReadExtend.resourcesType == 0) {
+      this.videoContext.play()
+    } else {
+      this.innerAudioContext.play();
+    }
+    await userEvent({
+      action: 'READING',
+      readId: this.data.videoInfo.userRead.id
+    })
+  },
+  // 控制视频或音频的暂停状态
+  stopMediaState() {
+    if (!this.data.videoInfo.userReadExtend || this.data.videoInfo.userReadExtend.resourcesType == 0) {
+      this.videoContext.stop()
+      this.videoContext.seek(0)
+    } else {
+      this.innerAudioContext.stop()
+    }
+  },
+  // 获取设备高度与行高度
+  getHeight() {
+    var query = wx.createSelectorQuery();
+    query.select('.content').boundingClientRect((rect) => {
+      this.setData({
+        contentH: rect.height
+      })
+    }).exec()
+    query.select('.row').boundingClientRect((rect) => {
+      this.rowH = rect.height
+    }).exec()
+  },
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload() {
+    wsEngine.reset()
+    recorderManager.stop();
+    if (this.innerAudioContext) {
+      this.innerAudioContext.stop()
+    }
+    clearTimeout(this.setTimeoutObj)
+    clearInterval(this.stl)
+  },
 })