index.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720
  1. import {
  2. getreadInfo,
  3. submitPlayLog
  4. } from '~/api/video'
  5. import {
  6. publishWorks,
  7. uploadPk,
  8. postWorksScore
  9. } from '~/api/works'
  10. import {
  11. userEvent
  12. } from '~/api/global'
  13. import {
  14. createStoreBindings
  15. } from 'mobx-miniprogram-bindings'
  16. import {
  17. store
  18. } from '~/store/index'
  19. import {
  20. setDuration
  21. } from '~/utils/util'
  22. const aiengine = require('~/utils/ChivoxAiEngine')
  23. const sha1 = require('~/utils/sha1');
  24. // 文章行高
  25. let rowH = 0
  26. let videoContext = null
  27. // 滚动变色定时器
  28. let stl = null
  29. // 倒计时
  30. let setTimeoutObj = null
  31. // 录音
  32. let innerAudioContext = null
  33. // 试听
  34. let resultAudioContext = null
  35. /*创建基础引擎*/
  36. let wsEngine = aiengine.createWsEngine({});
  37. /*微信录音*/
  38. let recorderManager = wx.getRecorderManager();
  39. Page({
  40. data: {
  41. videoInfo: {},
  42. videoPath: '',
  43. currentRow: null,
  44. state: false,
  45. // 示例播放状态
  46. exampleState: false,
  47. // 是否静音播放视频
  48. muted: false,
  49. countDown: {
  50. state: false,
  51. num: 3,
  52. },
  53. contentH: 0,
  54. scrollTop: 0,
  55. //如果readingReset为true就是重读
  56. readingReset: false,
  57. //readingType为public是普通阅读,为pk是pk逻辑,readMatch为朗读赛
  58. readingType: 'public',
  59. percent: 0,
  60. uploadState: false,
  61. article: [],
  62. silderData: {
  63. currentTime: '00:00',
  64. endTime: '00:00',
  65. silderValue: 0
  66. }
  67. },
  68. onLoad(options) {
  69. let videoId = options.videoId
  70. this.getreadInfo(videoId, options.reset)
  71. this.setData({
  72. readingReset: options.reset || false,
  73. readingType: options.readingType || 'public',
  74. uploadHide: options.uploadHide
  75. })
  76. // 手工绑定
  77. this.storeBindings = createStoreBindings(this, {
  78. store,
  79. fields: {
  80. userInfo: 'userInfo',
  81. readDetail: 'readDetail',
  82. pkData: 'pkData'
  83. },
  84. actions: {
  85. setReadDetail: 'setReadDetail'
  86. }
  87. })
  88. // 录音授权
  89. wx.getSetting({
  90. success(res) {
  91. if (!res.authSetting['scope.record']) {
  92. wx.authorize({
  93. scope: 'scope.record',
  94. success() {
  95. // 用户已经同意小程序使用录音功能,后续调用接口不会弹窗询问
  96. wx.getRecorderManager()
  97. }
  98. })
  99. }
  100. }
  101. })
  102. /*监听评测结果:必须在基础引擎创建后,调用任何评测接口前设置监听,否则有可能收不到相关事件。*/
  103. wsEngine.onResult((res) => {
  104. this.getRecordScore(res)
  105. });
  106. wsEngine.onErrorResult((res) => {
  107. console.log("===收到错误结果=============", res)
  108. });
  109. this.innerAudioContext = wx.createInnerAudioContext();
  110. this.innerAudioContext.onTimeUpdate(res => {
  111. this.setData({
  112. ["silderData.sliderValue"]: Math.round(this.innerAudioContext.currentTime / this.innerAudioContext.duration * 100),
  113. ["silderData.currentTime"]: setDuration(this.innerAudioContext.currentTime)
  114. })
  115. })
  116. this.resultAudioContext = wx.createInnerAudioContext();
  117. this.resultAudioContext.onTimeUpdate(res => {
  118. this.setData({
  119. ["silderData.sliderValue"]: Math.round(this.resultAudioContext.currentTime / this.resultAudioContext.duration * 100),
  120. ["silderData.currentTime"]: setDuration(this.resultAudioContext.currentTime)
  121. })
  122. })
  123. this.resultAudioContext.onError(res => {
  124. console.log(res, 'resultAudioContext');
  125. })
  126. this.innerAudioContext.onError(res => {
  127. console.log(res, 'bbbb');
  128. })
  129. this.resultAudioContext.onEnded(res => {
  130. console.log('102-resultAudioContext.ended');
  131. this.setData({
  132. exampleState: false
  133. })
  134. if (this.data.videoInfo.userReadExtend.resourcesType == 0) {
  135. this.videoContext.stop()
  136. this.videoContext.seek(0)
  137. }
  138. })
  139. this.resultAudioContext.onStop((res) => {
  140. console.log('109-resultAudioContext.onStop');
  141. this.setData({
  142. exampleState: false
  143. })
  144. if (this.data.videoInfo.userReadExtend.resourcesType == 0) {
  145. this.videoContext.stop()
  146. this.videoContext.seek(0)
  147. }
  148. });
  149. this.resultAudioContext.onEnded(res => {
  150. this.setData({
  151. ["silderData.sliderValue"]: 100
  152. })
  153. })
  154. },
  155. // 获取阅读内容
  156. async getreadInfo(videoId, reset = false) {
  157. let videoInfo = await getreadInfo(videoId)
  158. wx.setNavigationBarTitle({
  159. title: videoInfo.userRead.title
  160. })
  161. let data = JSON.parse(videoInfo.userReadExtend.lessonText)
  162. data = data.map((item, index) => {
  163. item.time = Number(item.time)
  164. item.readTime = data[index + 1] ? data[index + 1].time - item.time : ''
  165. return item
  166. })
  167. this.setData({
  168. videoPath: videoInfo.userRead.originVideo,
  169. article: data,
  170. videoInfo,
  171. ["silderData.endTime"]: setDuration(videoInfo.userRead.duration)
  172. })
  173. if (!reset) {
  174. this.getHeight()
  175. }
  176. if (this.data.videoInfo.userReadExtend.resourcesType == 0) {
  177. this.videoContext = wx.createVideoContext('myVideo')
  178. } else {
  179. this.innerAudioContext.src = videoInfo.userRead.originVideo
  180. this.innerAudioContext.onEnded(res => {
  181. console.log("138innerAudioContext触发的");
  182. this.resetReading()
  183. })
  184. this.innerAudioContext.onStop((res) => {
  185. console.log("143innerAudioContext触发的");
  186. });
  187. }
  188. },
  189. // 开始录制
  190. setCountDown() {
  191. let child = this.selectComponent('#readingTips').data
  192. // 判断是否有权限朗读 不是vip并且没有朗读机会
  193. const isVip = child.vipTime ? true : false
  194. if (!isVip && child.userInfo.experienceAmount <= 0 && this.data.readingType != 'readMatch') {
  195. return this.selectComponent('#readingTips').showModal();
  196. }
  197. if (this.data.state) {
  198. this.resetReading()
  199. return
  200. }
  201. if (!this.data.readingReset) {
  202. this.getHeight()
  203. }
  204. this.resetReading()
  205. this.setData({
  206. readingReset: false,
  207. 'countDown.state': true
  208. })
  209. this.stl = setInterval(() => {
  210. if (this.data.countDown.num == 0) {
  211. clearInterval(this.stl)
  212. this.setData({
  213. state: true,
  214. countDown: {
  215. state: false,
  216. num: 3
  217. }
  218. })
  219. this.playMediaState()
  220. this.soundRecording()
  221. this.startRecording()
  222. } else {
  223. this.setData({
  224. 'countDown.num': --this.data.countDown.num
  225. })
  226. }
  227. }, 1000)
  228. },
  229. // 录音
  230. soundRecording() {
  231. console.log('zzz');
  232. /*调用微信开始录音接口,并启动语音评测*/
  233. let timeStamp = new Date().getTime()
  234. let sig = sha1(`16075689600000da${timeStamp}caa8e60da6042731c230fe431ac9c7fd`)
  235. let app = {
  236. applicationId: '16075689600000da',
  237. sig, //签名字符串
  238. alg: 'sha1',
  239. timestamp: timeStamp + '',
  240. userId: wx.getStorageSync('uid')
  241. }
  242. let lessonText = JSON.parse(this.data.videoInfo.userReadExtend.lessonText).map((item) => {
  243. return item.text
  244. }).join('\n')
  245. // https://www.chivox.com/opendoc/#/ChineseDoc/coreCn/Chinese/cn.sent.raw?id=%e5%8f%82%e6%95%b0%e8%af%b4%e6%98%8e <----参数说明
  246. wsEngine.start({
  247. request: {
  248. coreType: "cn.pred.raw",
  249. refText: lessonText,
  250. rank: 100,
  251. attachAudioUrl: 1,
  252. result: {
  253. details: {
  254. gop_adjust: -0.1
  255. }
  256. }
  257. },
  258. app,
  259. audio: {
  260. audioType: "mp3",
  261. channel: 1,
  262. sampleBytes: 2,
  263. sampleRate: 16000
  264. },
  265. success: (res) => {
  266. /*引擎启动成功,可以启动录音机开始录音,并将音频片传给引擎*/
  267. const options = {
  268. duration: 600000,
  269. sampleRate: 44100, //采样率
  270. numberOfChannels: 1, //录音通道数
  271. encodeBitRate: 192000, //编码码率
  272. format: 'mp3', //音频格式,有效值aac/mp3
  273. frameSize: 50 //指定帧大小,单位 KB
  274. };
  275. //开始录音,在开始录音回调中feed音频片
  276. recorderManager.start(options);
  277. },
  278. fail: (res) => {
  279. console.log("fail============= " + res);
  280. },
  281. });
  282. recorderManager.onError(res => {
  283. console.log(res, 'rrrrrsse');
  284. })
  285. //监听录音开始事件
  286. recorderManager.onStart(() => {});
  287. //监听录音结束事件
  288. recorderManager.onStop((res) => {
  289. console.log('录音结束', res);
  290. this.setData({
  291. tempFilePath: res.tempFilePath,
  292. });
  293. //录音机结束后,驰声引擎执行结束操作,等待评测返回结果
  294. wsEngine.stop({
  295. success: () => {
  296. console.log('====== wsEngine stop success ======');
  297. },
  298. fail: (res) => {
  299. console.log('录音结束报错', res);
  300. },
  301. });
  302. });
  303. //监听已录制完指定帧大小的文件事件。如果设置了 frameSize,则会回调此事件。
  304. recorderManager.onFrameRecorded((res) => {
  305. const {
  306. frameBuffer
  307. } = res
  308. //TODO 调用feed接口传递音频片给驰声评测引擎
  309. wsEngine.feed({
  310. data: frameBuffer, // frameBuffer为微信录音机回调的音频数据
  311. success: () => {},
  312. fail: (res) => {
  313. console.log('监听已录制完指定帧大小报错', res)
  314. },
  315. });
  316. });
  317. },
  318. // eeeeee() {
  319. // wx.navigateTo({
  320. // url: `/pages/score/index?readingType=${this.data.readingType}`,
  321. // events: {
  322. // // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
  323. // someEvent: (data) => {
  324. // console.log(data)
  325. // this.setData({
  326. // readingReset: data.reset || false,
  327. // readingType: data.readingType || 'public',
  328. // uploadHide: data.uploadHide
  329. // })
  330. // console.log(this.data, 'ggggggggg');
  331. // }
  332. // },
  333. // })
  334. // },
  335. // 获取测评结果
  336. getRecordScore(res) {
  337. const result = res.result;
  338. const integrity = Math.floor(result.integrity); //完成度
  339. const tone = Math.floor(result.tone); // 语调声调
  340. const accuracy = Math.floor(result.accuracy); // 准确度 发音分
  341. const fluency = Math.floor(result.fluency.overall); //流利度
  342. let myOverall = Math.floor(integrity * 0.45 + accuracy * 0.35 + fluency * 0.1 + tone * 0.1);
  343. let detail = {
  344. integrity,
  345. tone,
  346. accuracy,
  347. fluency,
  348. myOverall,
  349. tempFilePath: this.data.tempFilePath,
  350. title: this.data.videoInfo.userRead.title,
  351. id: this.data.videoInfo.userRead.exampleId,
  352. coverImg: this.data.videoInfo.userRead.coverImg,
  353. resourcesType: this.data.videoInfo.userReadExtend.resourcesType,
  354. aBg: this.data.videoInfo.userReadExtend.resourcesType == 1 ? this.data.videoInfo.userReadExtend.backgroundVirtualImg : '',
  355. originVideo: this.data.videoInfo.userRead.originVideo
  356. }
  357. this.setReadDetail(detail)
  358. if (this.data.readingType == 'public' || this.data.readingType == 'readMatch') {
  359. wx.navigateTo({
  360. url: `/pages/score/index?readingType=${this.data.readingType}`,
  361. events: {
  362. // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
  363. goback: (data) => {
  364. console.log(data)
  365. this.setData({
  366. readingReset: data.reset || false,
  367. readingType: data.readingType || 'public',
  368. uploadHide: data.uploadHide
  369. })
  370. console.log(this.data);
  371. }
  372. },
  373. })
  374. } else {
  375. this.uploadAudio(detail)
  376. }
  377. },
  378. // 挑战录音上传
  379. uploadAudio(detail) {
  380. this.setData({
  381. uploadState: true
  382. })
  383. const uploadTask = wx.uploadFile({
  384. url: 'https://reader-api.ai160.com//file/upload',
  385. filePath: this.data.tempFilePath,
  386. name: '朗读录音',
  387. header: {
  388. uid: wx.getStorageSync('uid')
  389. },
  390. success: async (res) => {
  391. const formateRes = JSON.parse(res.data);
  392. let audioPath = formateRes.data;
  393. let uploadRes = await publishWorks({
  394. exampleId: this.data.pkData.exampleId,
  395. audioPath
  396. })
  397. let _data = this.data.readDetail
  398. console.log('挑战分数-----', {
  399. "userReadId": uploadRes.id,
  400. "complete": _data.integrity,
  401. "accuracy": _data.accuracy,
  402. "speed": _data.fluency,
  403. "intonation": _data.tone,
  404. "score": _data.myOverall
  405. });
  406. postWorksScore({
  407. "userReadId": uploadRes.id,
  408. "complete": _data.integrity,
  409. "accuracy": _data.accuracy,
  410. "speed": _data.fluency,
  411. "intonation": _data.tone,
  412. "score": _data.myOverall
  413. })
  414. let data = {
  415. challengerUserReadId: uploadRes.id,
  416. userReadId: this.data.pkData.id,
  417. winnerUId: this.data.pkData.score > _data.myOverall ? this.data.pkData.uid : this.data.pkData.score == _data.myOverall ? '' : wx.getStorageSync('uid')
  418. }
  419. console.log('uploadPk-----', data);
  420. let result = await uploadPk(data)
  421. wx.redirectTo({
  422. url: `/pages/pkResult/index?id=${result.id}`
  423. })
  424. },
  425. complete: () => {
  426. this.setData({
  427. uploadState: false
  428. })
  429. }
  430. });
  431. uploadTask.onProgressUpdate((res) => {
  432. this.setData({
  433. percent: res.progress
  434. })
  435. })
  436. },
  437. // 字体换行
  438. startRecording() {
  439. if (this.data.currentRow == null) {
  440. this.setData({
  441. currentRow: 0
  442. })
  443. }
  444. let row = this.data.article[this.data.currentRow]
  445. if (!row.readTime) {
  446. return
  447. }
  448. this.setTimeoutObj = setTimeout(() => {
  449. this.setData({
  450. currentRow: ++this.data.currentRow
  451. })
  452. this.setData({
  453. scrollTop: this.rowH * this.data.currentRow
  454. })
  455. this.startRecording()
  456. },
  457. row.readTime);
  458. },
  459. // 视频播放结束
  460. videoEnd() {
  461. this.resetReading()
  462. },
  463. videoPlay() {
  464. if (this.data.state) {
  465. return
  466. }
  467. if (this.data.videoInfo.userReadExtend.resourcesType == 1) {
  468. if (this.data.exampleState) {
  469. this.setData({
  470. exampleState: false
  471. })
  472. return this.resultAudioContext.stop()
  473. }
  474. this.resultAudioContext.src = this.data.readingReset ? this.data.readDetail.tempFilePath : this.data.videoInfo.userRead.audioPath;
  475. setTimeout(() => {
  476. this.resultAudioContext.play();
  477. }, 200)
  478. this.setData({
  479. exampleState: true
  480. })
  481. } else {
  482. if (this.data.readingReset) {
  483. this.resultAudioContext.src = this.data.readDetail.tempFilePath;
  484. this.resultAudioContext.play();
  485. this.setData({
  486. muted: true,
  487. exampleState: true
  488. })
  489. } else {
  490. this.setData({
  491. muted: false,
  492. exampleState: true
  493. })
  494. }
  495. this.setData({
  496. videoPath: this.data.videoInfo.userRead.videoPath
  497. })
  498. wx.nextTick(() => {
  499. this.videoContext.play()
  500. })
  501. }
  502. submitPlayLog({
  503. userReadId: this.data.videoInfo.userRead.exampleId,
  504. playStopTime: 1000
  505. })
  506. },
  507. // 控制视频或音频的播放状态
  508. async playMediaState() {
  509. this.setData({
  510. muted: false
  511. })
  512. if (this.data.videoInfo.userReadExtend.resourcesType == 0) {
  513. this.setData({
  514. videoPath: this.data.videoInfo.userRead.originVideo
  515. })
  516. wx.nextTick(() => {
  517. this.videoContext.play()
  518. })
  519. } else {
  520. this.innerAudioContext.play();
  521. }
  522. await userEvent({
  523. action: 'READING',
  524. readId: this.data.videoInfo.userRead.id
  525. })
  526. },
  527. // 重置一切状态
  528. resetReading() {
  529. clearTimeout(this.setTimeoutObj)
  530. clearInterval(this.stl)
  531. // 重置视频
  532. if (this.data.videoInfo.userReadExtend.resourcesType == 0) {
  533. this.videoContext.stop()
  534. this.videoContext.seek(0)
  535. }
  536. // 重置试听音频
  537. if (this.data.exampleState) {
  538. this.resultAudioContext.stop()
  539. // 重置录音时的背景音乐
  540. this.innerAudioContext.stop();
  541. console.log('是我暂停了');
  542. }
  543. if (this.data.state) {
  544. // 重置录音时的背景音乐
  545. this.innerAudioContext.stop();
  546. /*微信录音结束*/
  547. recorderManager.stop();
  548. }
  549. this.setData({
  550. exampleState: false,
  551. state: false,
  552. currentRow: null,
  553. scrollTop: 0,
  554. ["silderData.sliderValue"]: 0,
  555. ["silderData.currentTime"]: '00:00'
  556. })
  557. },
  558. // 获取设备高度与行高度
  559. getHeight() {
  560. var query = wx.createSelectorQuery();
  561. query.select('.content').boundingClientRect((rect) => {
  562. this.setData({
  563. contentH: rect.height
  564. })
  565. }).exec()
  566. query.select('.row').boundingClientRect((rect) => {
  567. this.rowH = rect.height
  568. }).exec()
  569. },
  570. // 进度条
  571. slider({
  572. detail
  573. }) {
  574. this.resultAudioContext.pause();
  575. console.log(detail.value / 100 * this.data.videoInfo.userRead.duration)
  576. this.resultAudioContext.seek(detail.value / 100 * this.data.videoInfo.userRead.duration)
  577. setTimeout(() => {
  578. this.resultAudioContext.play()
  579. }, 300)
  580. },
  581. onHide() {
  582. console.log('结束了吗');
  583. this.resetReading()
  584. },
  585. onUnload() {
  586. this.resetReading()
  587. this.storeBindings.destroyStoreBindings()
  588. },
  589. backReading() {
  590. wx.navigateBack({
  591. delta: 1
  592. })
  593. },
  594. creatShare() {
  595. return new Promise((resolve, reject) => {
  596. let video = this.data.videoInfo
  597. let context = wx.createSelectorQuery();
  598. context
  599. .select('#share')
  600. .fields({
  601. node: true,
  602. size: true
  603. }).exec((res) => {
  604. const canvas = res[0].node;
  605. const ctx = canvas.getContext('2d');
  606. const dpr = wx.getSystemInfoSync().pixelRatio;
  607. canvas.width = res[0].width * dpr;
  608. canvas.height = res[0].height * dpr;
  609. ctx.scale(dpr, dpr);
  610. ctx.font = '14px PingFang';
  611. let pic = canvas.createImage();
  612. pic.src = video.userReadExtend && video.userReadExtend.resourcesType == 1 ? video.userReadExtend.backgroundVirtualImg : video.userRead.coverImg;
  613. pic.onload = () => {
  614. ctx.drawImage(pic, 0, 0, 375, 211);
  615. let peiyin = canvas.createImage();
  616. peiyin.src = '/static/peiyin.jpg';
  617. peiyin.onload = () => {
  618. ctx.drawImage(peiyin, 0, 211, 375, 89);
  619. //分享
  620. let fx = canvas.createImage();
  621. fx.src = '/static/share.png'
  622. fx.onload = () => {
  623. ctx.drawImage(fx, 12, 220, 20, 20)
  624. ctx.fillText('分享', 36, 238)
  625. // 收藏,一个一个渲染
  626. let sc = canvas.createImage();
  627. sc.src = '/static/no_collect.png'
  628. sc.onload = () => {
  629. ctx.drawImage(sc, 110, 220, 19, 19)
  630. ctx.fillText('收藏', 134, 238)
  631. //点赞
  632. let dz = canvas.createImage();
  633. dz.src = '/static/heart.png'
  634. dz.onload = () => {
  635. ctx.drawImage(dz, 318, 222, 22, 22)
  636. ctx.fillText(0, 254, 238)
  637. // 评论
  638. let pl = canvas.createImage();
  639. pl.src = '/static/comment.png'
  640. pl.onload = () => {
  641. ctx.drawImage(pl, 228, 222, 22, 22)
  642. ctx.fillText(0, 340, 238)
  643. if (video.userReadExtend.resourcesType == 1) {
  644. let aBg = canvas.createImage();
  645. aBg.src = '/static/shareAudioBg.png';
  646. aBg.onload = () => {
  647. ctx.drawImage(aBg, 127.5, 38, 120, 120);
  648. let rate = 0.5
  649. ctx.arc(
  650. Math.floor(375 * rate),
  651. 98,
  652. Math.floor(100 * rate),
  653. 0,
  654. 2 * Math.PI
  655. );
  656. ctx.clip() //裁剪
  657. let coverImg = canvas.createImage();
  658. coverImg.src = video.userRead.coverImg;
  659. coverImg.onload = () => {
  660. ctx.drawImage( //定位在圆圈范围内便会出现
  661. coverImg, //图片暂存路径
  662. 129, 42,
  663. 110, 110,
  664. );
  665. ctx.restore()
  666. }
  667. }
  668. }
  669. setTimeout(() => {
  670. wx.canvasToTempFilePath({
  671. canvas: canvas,
  672. success(res) {
  673. resolve({
  674. title: '我的新作品发布啦,快来捧场点赞!',
  675. path: `/pages/pkPage/index?videoId=${wx.getStorageSync('shareVideoId')}&uid=${wx.getStorageSync('uid')}&isShare=true`,
  676. imageUrl: res.tempFilePath
  677. })
  678. },
  679. fail(res) {
  680. reject()
  681. }
  682. }, this)
  683. }, 500)
  684. }
  685. }
  686. }
  687. }
  688. }
  689. }
  690. })
  691. })
  692. },
  693. onShareAppMessage({
  694. from,
  695. target
  696. }) {
  697. if (from == 'button') {
  698. const promise = new Promise(resolve => {
  699. this.creatShare().then(res => {
  700. resolve(res)
  701. })
  702. })
  703. return {
  704. title: '我的新作品发布啦,快来捧场点赞!',
  705. path: `/pages/index/index?uid=${wx.getStorageSync('uid')}`,
  706. imageUrl: 'http://reader-wx.ai160.com/images/reader/v3/375-300-1.jpg',
  707. promise
  708. }
  709. } else {
  710. return {
  711. title: '自从用了它,家里朗朗书声,美妙极了!你家孩子也快来试试!',
  712. path: `/pages/index/index?uid=${wx.getStorageSync('uid')}`,
  713. imageUrl: 'http://reader-wx.ai160.com/images/reader/v3/375-300-1.jpg'
  714. }
  715. }
  716. },
  717. })