|
@@ -2,6 +2,10 @@ import {
|
|
|
getreadInfo
|
|
|
} from '~/api/video'
|
|
|
import {
|
|
|
+ publishWorks,
|
|
|
+ uploadPk
|
|
|
+} from '~/api/works'
|
|
|
+import {
|
|
|
createStoreBindings
|
|
|
} from 'mobx-miniprogram-bindings'
|
|
|
import {
|
|
@@ -38,6 +42,8 @@ Page({
|
|
|
readingReset: false,
|
|
|
//readingType为public是普通阅读,为pk是pk逻辑
|
|
|
readingType: 'public',
|
|
|
+ percent: 0,
|
|
|
+ uploadState: false,
|
|
|
article: [{
|
|
|
id: 1,
|
|
|
text: '传说在很久很久以前,',
|
|
@@ -94,7 +100,8 @@ Page({
|
|
|
store,
|
|
|
fields: {
|
|
|
userInfo: 'userInfo',
|
|
|
- readDetail: 'readDetail'
|
|
|
+ readDetail: 'readDetail',
|
|
|
+ pkData: 'pkData'
|
|
|
},
|
|
|
actions: {
|
|
|
setReadDetail: 'setReadDetail'
|
|
@@ -310,6 +317,7 @@ Page({
|
|
|
},
|
|
|
// 获取测评结果
|
|
|
getRecordScore(res) {
|
|
|
+ console.log('获取评测结果');
|
|
|
const result = res.result;
|
|
|
const integrity = Math.floor(result.integrity); //完成度
|
|
|
const tone = Math.floor(result.tone); // 语调声调
|
|
@@ -327,8 +335,55 @@ Page({
|
|
|
id: this.data.videoInfo.userRead.exampleId,
|
|
|
}
|
|
|
this.setReadDetail(detail)
|
|
|
- wx.redirectTo({
|
|
|
- url: this.data.readingType == 'public' ? '/pages/score/index' : '/pages/pkResult/index',
|
|
|
+ console.log(this.data.readingType, 'readingType');
|
|
|
+ if (this.data.readingType == 'public') {
|
|
|
+ wx.redirectTo({
|
|
|
+ url: '/pages/score/index'
|
|
|
+ })
|
|
|
+ } 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
|
|
|
+ })
|
|
|
+ console.log('uploadRes', uploadRes);
|
|
|
+ /* let winnerUId = this.data.pkData > detail.myOverall ? this.data.pkData.exampleId : this.data.pkData < detail.myOverall ? detail.id : '' */
|
|
|
+ let data = {
|
|
|
+ challengerUserReadId: uploadRes.id,
|
|
|
+ userReadId: this.data.pkData.id,
|
|
|
+ }
|
|
|
+ await uploadPk(data)
|
|
|
+ wx.redirectTo({
|
|
|
+ url: '/pages/pkResult/index'
|
|
|
+ })
|
|
|
+ },
|
|
|
+ complete: () => {
|
|
|
+ this.setData({
|
|
|
+ uploadState: false
|
|
|
+ })
|
|
|
+ }
|
|
|
+ });
|
|
|
+ uploadTask.onProgressUpdate((res) => {
|
|
|
+ this.setData({
|
|
|
+ percent: res.progress
|
|
|
+ })
|
|
|
})
|
|
|
},
|
|
|
videoPlay() {
|