Ver código fonte

修改reading

bayi 2 anos atrás
pai
commit
e734f4af9d

+ 53 - 40
pages/reading/index.js

@@ -99,16 +99,24 @@ Page({
     this.innerAudioContext = wx.createInnerAudioContext();
     this.resultAudioContext = wx.createInnerAudioContext();
     this.resultAudioContext.onEnded(res => {
+      console.log('102-resultAudioContext.ended');
       this.setData({
         exampleState: false
       })
-      this.stopMediaState()
+      if (this.data.videoInfo.userReadExtend.resourcesType == 0) {
+        this.videoContext.stop()
+        this.videoContext.seek(0)
+      }
     })
     this.resultAudioContext.onStop((res) => {
+      console.log('109-resultAudioContext.onStop');
       this.setData({
         exampleState: false
       })
-      this.stopMediaState()
+      if (this.data.videoInfo.userReadExtend.resourcesType == 0) {
+        this.videoContext.stop()
+        this.videoContext.seek(0)
+      }
     });
   },
   // 获取阅读内容
@@ -130,17 +138,18 @@ Page({
     if (!reset) {
       this.getHeight()
     }
-    if (!this.data.videoInfo.userReadExtend || this.data.videoInfo.userReadExtend.resourcesType == 0) {
+    if (this.data.videoInfo.userReadExtend.resourcesType == 0) {
       this.videoContext = wx.createVideoContext('myVideo')
     } else {
+      console.log('走了136');
       this.innerAudioContext.src = videoInfo.userRead.originVideo
       this.innerAudioContext.onEnded(res => {
         console.log("138innerAudioContext触发的");
-        this.finishRecord()
+        this.resetReading()
       })
       this.innerAudioContext.onStop((res) => {
         console.log("143innerAudioContext触发的");
-        this.finishRecord()
+        // this.resetReading()
       });
     }
 
@@ -154,13 +163,13 @@ Page({
       return this.selectComponent('#readingTips').showModal();
     }
     if (this.data.state) {
-      this.finishRecord()
+      this.resetReading()
       return
     }
     if (!this.data.readingReset) {
       this.getHeight()
     }
-    this.stopMediaState()
+    this.resetReading()
     this.setData({
       readingReset: false,
       'countDown.state': true
@@ -187,6 +196,7 @@ Page({
   },
   // 录音
   soundRecording() {
+    console.log('zzz');
     /*调用微信开始录音接口,并启动语音评测*/
     let timeStamp = new Date().getTime()
     let sig = sha1(`16075689600000da${timeStamp}caa8e60da6042731c230fe431ac9c7fd`)
@@ -272,19 +282,6 @@ Page({
       });
     });
   },
-  // 结束录制
-  finishRecord() {
-    console.log('触发结束录制了');
-    recorderManager.stop();
-    this.stopMediaState()
-    clearTimeout(this.setTimeoutObj)
-    clearInterval(this.stl)
-    this.setData({
-      state: false,
-      currentRow: null,
-      scrollTop: 0
-    })
-  },
   // 获取测评结果
   getRecordScore(res) {
     const result = res.result;
@@ -391,9 +388,13 @@ Page({
   // 视频播放结束
   videoEnd() {
     console.log('视频播放结束触发的');
-    this.finishRecord()
+    this.resetReading()
   },
   videoPlay() {
+    console.log("触发");
+    if (this.data.state) {
+      return
+    }
     if (this.data.videoInfo.userReadExtend.resourcesType == 1) {
       if (this.data.exampleState) {
         this.setData({
@@ -408,6 +409,7 @@ Page({
       })
     } else {
       if (this.data.readingReset) {
+        console.log('是我播放了');
         this.resultAudioContext.src = this.data.readDetail.tempFilePath;
         this.resultAudioContext.play();
         this.setData({
@@ -422,16 +424,14 @@ Page({
       }
       this.videoContext.play()
     }
-    /*    if (!this.data.readingReset) {
-         this.startRecording()
-       } */
   },
   // 控制视频或音频的播放状态
   async playMediaState() {
+    console.log('触发');
     this.setData({
       muted: false
     })
-    if (!this.data.videoInfo.userReadExtend || this.data.videoInfo.userReadExtend.resourcesType == 0) {
+    if (this.data.videoInfo.userReadExtend.resourcesType == 0) {
       this.videoContext.play()
     } else {
       this.innerAudioContext.play();
@@ -441,14 +441,35 @@ Page({
       readId: this.data.videoInfo.userRead.id
     })
   },
-  // 控制视频或音频的暂停状态
-  stopMediaState() {
-    if (!this.data.videoInfo.userReadExtend || this.data.videoInfo.userReadExtend.resourcesType == 0) {
+  // 重置一切状态
+  resetReading() {
+    clearTimeout(this.setTimeoutObj)
+    clearInterval(this.stl)
+    console.log(this.data.exampleState, this.data.state, 'vvvvvvvvvvvvvvvvvvvvvvv');
+    // 重置视频
+    if (this.data.videoInfo.userReadExtend.resourcesType == 0) {
       this.videoContext.stop()
       this.videoContext.seek(0)
     }
-    this.innerAudioContext.stop()
-    this.resultAudioContext.stop()
+    // 重置试听音频
+    if (this.data.exampleState) {
+      this.resultAudioContext.stop()
+      // 重置录音时的背景音乐
+      this.innerAudioContext.stop();
+      console.log('是我暂停了');
+    }
+    if (this.data.state) {
+      // 重置录音时的背景音乐
+      this.innerAudioContext.stop();
+      /*微信录音结束*/
+      recorderManager.stop();
+    }
+    this.setData({
+      exampleState: false,
+      state: false,
+      currentRow: null,
+      scrollTop: 0
+    })
   },
   // 获取设备高度与行高度
   getHeight() {
@@ -463,18 +484,10 @@ Page({
     }).exec()
   },
   onHide() {
-    wsEngine.reset()
-    if (this.innerAudioContext) {
-      this.innerAudioContext.stop()
-    }
-    this.finishRecord()
+    this.resetReading()
   },
   onUnload() {
-    wsEngine.reset()
-    if (this.innerAudioContext) {
-      this.innerAudioContext.stop()
-    }
-    this.finishRecord()
+    this.resetReading()
   },
   creatShare() {
     return new Promise((resolve, reject) => {

+ 19 - 8
pages/reading/index.less

@@ -16,6 +16,17 @@
     pointer-events: auto;
   }
 
+  .playBtn {
+    position: absolute;
+    width: 100rpx;
+    height: 100rpx;
+    left: 0px;
+    right: 0px;
+    top: 160rpx;
+    margin: 0rpx auto;
+    z-index: 11;
+  }
+
   .watermark {
     position: absolute;
     left: 0px;
@@ -68,22 +79,22 @@
       justify-content: center;
 
       .audioPlayBg {
-        width: 200rpx;
-        height: 200rpx;
+        width: 260rpx;
+        height: 260rpx;
       }
 
       .audioPlayZhen {
         position: absolute;
-        right: 270rpx;
-        top: 118rpx;
-        width: 42rpx;
-        height: 50rpx;
+        right: 230rpx;
+        top: 98rpx;
+        width: 62rpx;
+        height: 70rpx;
       }
 
       .cover {
         position: absolute;
-        width: 180rpx;
-        height: 180rpx;
+        width: 230rpx;
+        height: 230rpx;
         border-radius: 50%;
       }
 

+ 6 - 4
pages/reading/index.wxml

@@ -1,6 +1,7 @@
 <view class="readingBox">
   <block wx:if="{{!videoInfo.userReadExtend||videoInfo.userReadExtend.resourcesType==0}}">
     <image src="{{videoInfo.userRead.coverImg}}" class='poster' wx:if="{{!state&&!exampleState}}" bindtap="videoPlay" />
+    <image src="/static/play-btn.png" bindtap="videoPlay" wx:if="{{!state&&!exampleState}}" class="playBtn" />
     <!-- 水印 -->
     <image src="{{videoInfo.readMaskTemplate.imgPath}}" class="watermark" />
     <video id="myVideo" src="{{state?videoInfo.userRead.originVideo:videoInfo.userRead.videoPath}}" bindended='videoEnd'
@@ -8,14 +9,15 @@
     <!-- 这个用于预加载资源 -->
     <video src="{{videoInfo.userRead.originVideo}}" style="display: none;"></video>
   </block>
-  <view class=" audio" wx:else>
+  <view class="audio" wx:else>
     <image src="{{videoInfo.userRead.coverImg}}" class="audioBg" mode="" />
     <view class="mask"></view>
-    <view class="audioPlay" style="background-image: url({{videoInfo.userReadExtend.backgroundVirtualImg}});">
+    <view class="audioPlay" bindtap='videoPlay'
+      style="background-image: url({{videoInfo.userReadExtend.backgroundVirtualImg}});">
       <image src="/static/audioBg.png" class="audioPlayBg {{state?'circle':''}}" />
       <image src="/static/zhen.png" class="audioPlayZhen" />
-      <image src="{{videoInfo.userRead.coverImg}}" bindtap='videoPlay' class="cover {{state||exampleState?'circle':''}}"
-        mode="" />
+      <image src="/static/play-btn.png" wx:if="{{!state&&!exampleState}}" class="playBtn" />
+      <image src="{{videoInfo.userRead.coverImg}}" class="cover {{state||exampleState?'circle':''}}" mode="" />
     </view>
   </view>
   <view class="contentBox" wx:if="{{!readingReset}}">

+ 18 - 8
pages/reading/index.wxss

@@ -15,6 +15,16 @@
   z-index: 10;
   pointer-events: auto;
 }
+.readingBox .playBtn {
+  position: absolute;
+  width: 100rpx;
+  height: 100rpx;
+  left: 0px;
+  right: 0px;
+  top: 160rpx;
+  margin: 0rpx auto;
+  z-index: 11;
+}
 .readingBox .watermark {
   position: absolute;
   left: 0px;
@@ -62,20 +72,20 @@
   justify-content: center;
 }
 .readingBox .audio .audioPlay .audioPlayBg {
-  width: 200rpx;
-  height: 200rpx;
+  width: 260rpx;
+  height: 260rpx;
 }
 .readingBox .audio .audioPlay .audioPlayZhen {
   position: absolute;
-  right: 270rpx;
-  top: 118rpx;
-  width: 42rpx;
-  height: 50rpx;
+  right: 230rpx;
+  top: 98rpx;
+  width: 62rpx;
+  height: 70rpx;
 }
 .readingBox .audio .audioPlay .cover {
   position: absolute;
-  width: 180rpx;
-  height: 180rpx;
+  width: 230rpx;
+  height: 230rpx;
   border-radius: 50%;
 }
 .readingBox .audio .audioPlay .circle {

+ 2 - 2
utils/request.js

@@ -31,13 +31,13 @@ function request(url, method, data, oldBaseUrl = false) {
             message
           }
         } = result
-        console.log(code, 'cccc');
         if (code == '200') {
           reslove(data)
         } else if (code == '1102' || code == '1204' || code == '503') {
+          console.log(code, '<=====code', message);
           wx.clearStorage()
         } else {
-          console.log(message);
+          console.log(code, '<=====code', message);
           // reject(message)
         }
       },