Преглед на файлове

完善作品上传及试听逻辑

bayi преди 2 години
родител
ревизия
d0457e4b3f
променени са 9 файла, в които са добавени 27 реда и са изтрити 106 реда
  1. 17 5
      components/uploadFile/index.js
  2. 0 16
      pages/reading/index.js
  3. 1 1
      pages/reading/index.wxml
  4. 1 50
      pages/score/index.js
  5. 3 1
      pages/score/index.json
  6. 1 6
      pages/score/index.less
  7. 2 21
      pages/score/index.wxml
  8. 1 5
      pages/score/index.wxss
  9. 1 1
      project.private.config.json

+ 17 - 5
components/uploadFile/index.js

@@ -1,10 +1,20 @@
 import {
-  createStoreBindings
+  storeBindingsBehavior
 } from 'mobx-miniprogram-bindings'
 import {
   store
 } from '~/store/index'
 Component({
+  behaviors: [storeBindingsBehavior],
+  storeBindings: {
+    store,
+    fields: {
+      readDetail: 'readDetail'
+    },
+    actions: {
+      setReadDetail: 'setReadDetail'
+    }
+  },
   /**
    * 组件的属性列表
    */
@@ -21,7 +31,6 @@ Component({
     // 是否上传过
     uploadState: false,
     percent: 0,
-    audioPath: ''
   },
   /**
    * 组件的方法列表
@@ -43,11 +52,14 @@ Component({
           uid: wx.getStorageSync('uid')
         },
         success: (res) => {
-          const formateRes = JSON.parse(res.data);
-          let audioPath = formateRes.data;
+          // const formateRes = JSON.parse(res.data);
+          // let audioPath = formateRes.data;
+          // this.setReadDetail({
+          //   audioPath,
+          //   ...this.data.readDetail
+          // })
           this.setData({
             uploadSuccess: true,
-            audioPath
           })
         },
         complete: () => {

+ 0 - 16
pages/reading/index.js

@@ -286,22 +286,6 @@ Page({
   },
   // 获取测评结果
   getRecordScore(res) {
-    var res = {
-      result: {
-        rank: 100,
-        res: "chn.pred.G4.D4.0.3",
-        tone: 50,
-        integrity: 12,
-        forceout: 0,
-        pron: 7,
-        overall: 8,
-        fluency: {
-          pause: 1,
-          overall: 0,
-          speed: 73
-        },
-      }
-    }
     const result = res.result;
     const integrity = Math.floor(result.integrity); //完成度
     const tone = Math.floor(result.tone); // 语调声调

+ 1 - 1
pages/reading/index.wxml

@@ -13,7 +13,7 @@
     </scroll-view>
   </view>
   <view class="controller">
-    <image src="{{state?'/static/readingNow.gif':'/static/work.png'}}" class="playImg" bindtap="getRecordScore" />
+    <image src="{{state?'/static/readingNow.gif':'/static/work.png'}}" class="playImg" bindtap="setCountDown" />
     <view class="text">{{state?'完成录制':readingReset?'点击重录':'开始挑战'}}</view>
     <uploadFile wx:if="{{readingReset}}" class="btnPosition"/>
   </view>

+ 1 - 50
pages/score/index.js

@@ -11,13 +11,6 @@ Page({
    */
   data: {
     score: {},
-    tempFilePath: '',
-    uploadFlag: false,
-    uploadSuccess: false,
-    // 是否上传过
-    uploadState: false,
-    percent: 0,
-    audioPath: ''
   },
 
   /**
@@ -40,54 +33,12 @@ Page({
       score,
     })
   },
-  upload() {
-    if (this.data.uploadState) {
-      return
-    }
-    this.setData({
-      uploadFlag: true,
-      uploadState: true
-    })
-    const uploadTask = wx.uploadFile({
-      url: 'https://reader-api.ai160.com//file/upload',
-      filePath: this.data.score.tempFilePath,
-      name: '朗读录音',
-      header: {
-        uid: wx.getStorageSync('uid')
-      },
-      success: (res) => {
-        const formateRes = JSON.parse(res.data);
-        let audioPath = formateRes.data;
-        this.setData({
-          uploadSuccess: true,
-          audioPath
-        })
-      },
-      complete: () => {
-        this.setData({
-          uploadFlag: false
-        })
-      }
-    })
-    uploadTask.onProgressUpdate((res) => {
-      this.setData({
-        percent: res.progress
-      })
-    })
-  },
   backReading() {
     wx.redirectTo({
       url: `/pages/reading/index?videoId=${this.data.score.id}&reset=true`,
     })
   },
-  cancelMask() {
-    this.setData({
-      uploadSuccess: false
-    })
-  },
   onShareAppMessage() {
-    this.setData({
-      uploadSuccess: false
-    })
+
   }
 })

+ 3 - 1
pages/score/index.json

@@ -1,4 +1,6 @@
 {
-  "usingComponents": {},
+  "usingComponents": {
+    "uploadFile": "/components/uploadFile/index"
+  },
   "navigationBarTitleText": "测评报告"
 }

+ 1 - 6
pages/score/index.less

@@ -141,7 +141,7 @@
     align-items: center;
     justify-content: space-between;
 
-    .btn {
+    .stBtn {
       padding: 16rpx 0rpx;
       text-align: center;
       border-radius: 50rpx;
@@ -151,11 +151,6 @@
       background-color: #66C5FF;
       box-shadow: 0 6px 14px 0 rgba(50, 197, 255, 0.65);
     }
-
-    .btn2 {
-      background-color: #F84041;
-      box-shadow: 0 6rpx 14rpx 0 rgba(251, 79, 80, 0.76);
-    }
   }
 }
 

+ 2 - 21
pages/score/index.wxml

@@ -55,26 +55,7 @@
   </view>
   <!-- 底部 -->
   <view class="footer">
-    <view class="btn" bindtap="backReading">试听</view>
-    <!-- <view class="btn btn2" bindtap="upload">上传作品</view> -->
+    <view class="stBtn" bindtap="backReading">试听</view>
+    <uploadFile />
   </view>
-<!--   <view class="uploadBox" wx:if="{{uploadFlag}}">
-    <view class="upload">
-      <view class="speed">{{percent}}%</view>
-      <progress percent="{{percent}}" class="speedProgress" stroke-width="10" activeColor="#C3F166" />
-      <view>作品上传中</view>
-    </view>
-  </view> -->
-  <!-- 上传成功 -->
-  <!-- <view class="uploadBox successBox" wx:if="{{uploadSuccess}}" catchtap="cancelMask">
-    <view class="success" catchtap="true">
-      <image src="/static/lan.png" class="icon" mode="" />
-      <view class="tips1">作品上传成功</view>
-      <view class="tips2">快去分享你的作品</view>
-      <view class="tips2">召唤小伙伴点赞评论!</view>
-      <button class="resetBtn shareBtn" open-type="share">
-        分享作品
-      </button>
-    </view>
-  </view> -->
 </view>

+ 1 - 5
pages/score/index.wxss

@@ -121,7 +121,7 @@
   align-items: center;
   justify-content: space-between;
 }
-.container .footer .btn {
+.container .footer .stBtn {
   padding: 16rpx 0rpx;
   text-align: center;
   border-radius: 50rpx;
@@ -131,10 +131,6 @@
   background-color: #66C5FF;
   box-shadow: 0 6px 14px 0 rgba(50, 197, 255, 0.65);
 }
-.container .footer .btn2 {
-  background-color: #F84041;
-  box-shadow: 0 6rpx 14rpx 0 rgba(251, 79, 80, 0.76);
-}
 .uploadBox {
   position: fixed;
   top: 0px;

+ 1 - 1
project.private.config.json

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