index.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import {
  2. createStoreBindings
  3. } from 'mobx-miniprogram-bindings'
  4. import {
  5. store
  6. } from '~/store/index'
  7. Page({
  8. /**
  9. * 页面的初始数据
  10. */
  11. data: {
  12. score: {},
  13. tempFilePath: ''
  14. },
  15. /**
  16. * 生命周期函数--监听页面加载
  17. */
  18. onLoad(options) {
  19. this.storeBindings = createStoreBindings(this, {
  20. store,
  21. fields: {
  22. userInfo: 'userInfo'
  23. },
  24. })
  25. this.storeBindings.updateStoreBindings()
  26. let score = JSON.parse(options.detail)
  27. wx.setNavigationBarTitle({
  28. title: score.title
  29. })
  30. let tempFilePath = wx.getStorageSync('tempFilePath')
  31. this.setData({
  32. score,
  33. tempFilePath
  34. })
  35. },
  36. upload() {
  37. const uploadTask = wx.uploadFile({
  38. url: 'https://reader-api.ai160.com//file/upload',
  39. filePath: this.data.tempFilePath,
  40. name: '朗读录音',
  41. header: {
  42. uid: wx.getStorageSync('uid')
  43. },
  44. success: (res) => {
  45. const formateRes = JSON.parse(res.data);
  46. let audioPath = formateRes.data;
  47. console.log(audioPath);
  48. }
  49. })
  50. uploadTask.onProgressUpdate((res) => {
  51. console.log('上传进度', res.progress)
  52. })
  53. },
  54. onShareAppMessage() {
  55. }
  56. })