bayi пре 2 година
родитељ
комит
7dcf0bc27e

+ 2 - 0
api/works.js

@@ -18,4 +18,6 @@ module.exports = {
   getFollowWorks: data => request('/fans/interest', 'get', data),
   // 获取作品的挑战记录
   getPkRecord: data => request('/v3/pk', 'get', data),
+  // 发布朗读赛作品
+  publishRankWorks: data => request('/activityRead', 'post', data),
 }

+ 16 - 16
components/uploadFile/index.js

@@ -5,7 +5,8 @@ import {
   store
 } from '~/store/index'
 import {
-  publishWorks
+  publishWorks,
+  publishRankWorks
 } from '~/api/works'
 Component({
   behaviors: [storeBindingsBehavior],
@@ -22,7 +23,7 @@ Component({
    * 组件的属性列表
    */
   properties: {
-
+    readingType: ''
   },
   /**
    * 组件的初始数据
@@ -57,7 +58,7 @@ Component({
         success: (res) => {
           const formateRes = JSON.parse(res.data);
           let audioPath = formateRes.data;
-          this.shareWorks(audioPath);
+          this.uploadWorks(audioPath);
           this.setData({
             uploadSuccess: true,
           })
@@ -79,22 +80,21 @@ Component({
         uploadSuccess: false
       })
     },
-    async shareWorks(audio) {
+    async uploadWorks(audio) {
+      console.log(this.data);
       const data = {
-        "lessonId": this.data.id,
-        "originVideo": this.data.videoUrl,
+        "exampleId": this.data.readDetail.id,
         "audioPath": audio,
-        "title": this.data.title,
-        "iconImg": this.data.img,
-        "summary": this.data.summary,
-        "productId": this.data.productId,
-        "grade": this.data.grade,
-        "exampleId": this.data.exampleId,
-        "coverImg": this.data.coverImg,
-        "shareImg": this.data.shareImg
+        "originVideo": this.data.readDetail.originVideo,
       };
-      let res = await publishWorks(data)
-      console.log(data, res, '嘎嘎嘎嘎');
+      console.log(data, '嘎嘎嘎嘎');
+      let res
+      if (!this.properties.readingType) {
+        res = await publishWorks(data)
+      } else {
+        res = await publishRankWorks(data)
+      }
+      console.log(res, '嘎2');
     },
   }
 })

+ 7 - 1
pages/match/index.js

@@ -67,7 +67,13 @@ Page({
     let res = await getSelfReadRanking()
     console.log(res);
   },
-  bannelEvent() {},
+  bannelEvent({
+    target
+  }) {
+    wx.navigateTo({
+      url: `/pages/reading/index?videoId=${target.dataset.id}&readingType=readMatch`
+    })
+  },
   jumpUserInfo({
     currentTarget
   }) {

+ 2 - 2
pages/match/index.wxml

@@ -9,8 +9,8 @@
     <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.coverImg}}" class="swiper-item" mode="" />
+        <swiper-item>
+          <image src="{{item.coverImg}}" class="swiper-item" bindtap='bannelEvent' data-id='{{item.exampleId}}' />
         </swiper-item>
       </block>
     </swiper>

+ 48 - 53
pages/reading/index.js

@@ -40,7 +40,7 @@ Page({
     scrollTop: 0,
     //如果readingReset为true就是重读
     readingReset: false,
-    //readingType为public是普通阅读,为pk是pk逻辑
+    //readingType为public是普通阅读,为pk是pk逻辑,readMatch为朗读赛
     readingType: 'public',
     percent: 0,
     uploadState: false,
@@ -72,14 +72,6 @@ Page({
       id: 7,
       text: '一天,大神醒来,睁眼一看,',
       time: '20030'
-    }, {
-      id: 8,
-      text: '周围黑乎乎一片,',
-      time: '24210'
-    }, {
-      id: 9,
-      text: '什么也看不见。',
-      time: '27300'
     }]
   },
   onLoad(options) {
@@ -90,7 +82,7 @@ Page({
       item.readTime = data[index + 1] ? data[index + 1].time - item.time : ''
       return item
     })
-    console.log(options,'options');
+    console.log(options, 'options');
     this.setData({
       article: data,
       readingReset: options.reset || false,
@@ -252,14 +244,14 @@ Page({
         tempFilePath: res.tempFilePath,
       });
       //录音机结束后,驰声引擎执行结束操作,等待评测返回结果
-      // wsEngine.stop({
-      //   success: () => {
-      //     console.log('====== wsEngine stop success ======');
-      //   },
-      //   fail: (res) => {
-      //     console.log('录音结束报错', res);
-      //   },
-      // });
+      wsEngine.stop({
+        success: () => {
+          console.log('====== wsEngine stop success ======');
+        },
+        fail: (res) => {
+          console.log('录音结束报错', res);
+        },
+      });
     });
     //监听已录制完指定帧大小的文件事件。如果设置了 frameSize,则会回调此事件。
     recorderManager.onFrameRecorded((res) => {
@@ -290,38 +282,6 @@ Page({
       scrollTop: 0
     })
   },
-  // 测试的
-  pkResult() {
-    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()
-  },
   // 获取测评结果
   getRecordScore(res) {
     console.log('获取评测结果');
@@ -340,12 +300,12 @@ Page({
       tempFilePath: this.data.tempFilePath,
       title: this.data.videoInfo.userRead.title,
       id: this.data.videoInfo.userRead.exampleId,
+      originVideo: this.data.videoInfo.userRead.originVideo
     }
     this.setReadDetail(detail)
-    console.log(this.data.readingType, 'readingType');
-    if (this.data.readingType == 'public') {
+    if (this.data.readingType == 'public' || this.data.readingType == 'readMatch') {
       wx.redirectTo({
-        url: '/pages/score/index'
+        url: `/pages/score/index?readingType=${this.data.readingType}`
       })
     } else {
       this.uploadAudio(detail)
@@ -393,6 +353,41 @@ Page({
       })
     })
   },
+  // 测试的
+  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
+        })
+        this.setData({
+          scrollTop: this.rowH * this.data.currentRow
+        })
+        this.startRecording()
+      },
+      row.readTime);
+  },
+  // 视频播放结束
+  videoEnd() {
+    this.finishRecord()
+  },
   videoPlay() {
     if (this.data.readingReset) {
       this.resultAudioContext = wx.createInnerAudioContext();

+ 2 - 2
pages/reading/index.wxml

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

+ 4 - 0
pages/score/index.js

@@ -11,12 +11,15 @@ Page({
    */
   data: {
     score: {},
+    // 目前用来处理区分上传普通作品还是朗读赛作品
+    readingType: ''
   },
 
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad(options) {
+    console.log(options);
     this.storeBindings = createStoreBindings(this, {
       store,
       fields: {
@@ -31,6 +34,7 @@ Page({
     })
     this.setData({
       score,
+      readingType: options.readingType ? options.readingType : ''
     })
   },
   backReading() {

+ 1 - 1
pages/score/index.wxml

@@ -56,6 +56,6 @@
   <!-- 底部 -->
   <view class="footer">
     <view class="stBtn" bindtap="backReading">试听</view>
-    <uploadFile />
+    <uploadFile readingType='{{readingType}}' />
   </view>
 </view>