1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- import {
- storeBindingsBehavior
- } from 'mobx-miniprogram-bindings'
- import {
- store
- } from '~/store/index'
- Component({
- behaviors: [storeBindingsBehavior],
- storeBindings: {
- store,
- fields: {
- readDetail: 'readDetail'
- },
- actions: {
- setReadDetail: 'setReadDetail'
- }
- },
- /**
- * 组件的属性列表
- */
- properties: {
- },
- /**
- * 组件的初始数据
- */
- data: {
- tempFilePath: '',
- uploadFlag: false,
- uploadSuccess: false,
- // 是否上传过
- uploadState: false,
- percent: 0,
- },
- /**
- * 组件的方法列表
- */
- methods: {
- 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.readDetail.tempFilePath,
- name: '朗读录音',
- header: {
- uid: wx.getStorageSync('uid')
- },
- success: (res) => {
- // const formateRes = JSON.parse(res.data);
- // let audioPath = formateRes.data;
- // this.setReadDetail({
- // audioPath,
- // ...this.data.readDetail
- // })
- this.setData({
- uploadSuccess: true,
- })
- },
- complete: () => {
- this.setData({
- uploadFlag: false
- })
- }
- })
- uploadTask.onProgressUpdate((res) => {
- this.setData({
- percent: res.progress
- })
- })
- },
- cancelMask() {
- this.setData({
- uploadSuccess: false
- })
- },
- }
- })
|