reading.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746
  1. import httpRequestApi from '../../utils/APIClient';
  2. const aiengine = require('../../utils/ChivoxAiEngine')
  3. const sha1 = require('../../utils/sha1');
  4. import {
  5. formatDate
  6. } from '../../utils/util';
  7. Page({
  8. data: {
  9. title: '',
  10. id: '',
  11. img: '',
  12. fullScreenBtn: false,
  13. playBtn: true,
  14. gesture: true,
  15. muted: false,
  16. gesture: false,
  17. centerBtn: true,
  18. recordFlag: 0,
  19. recordSource: '',
  20. videoCtr: 'recordingVideoEnd',
  21. btnFlag: false,
  22. btnImgFlag: false,
  23. microphonePng: '../../static/index/microphone.png',
  24. recordingGif: '../../static/index/readingNow.gif',
  25. videoUrl: '',
  26. readingText: '',
  27. videoList: [],
  28. pageNo: 1,
  29. totalSize: 0,
  30. nextMargin: getApp().globalData.nextMargin,
  31. lowerThresHold: 100,
  32. isVideoListShow: true,
  33. overall: '', // 评测总分
  34. integrity: '', //完成度
  35. tone: '', //语调声调
  36. fluency: '', //流利度
  37. accuracy: '', // 正确分,发音分
  38. star: [0, 0, 0, 0, 0],
  39. ifTextShow: true,
  40. ifScoreDialogShow: false,
  41. ifScoreShow: false,
  42. statusbarobj: {
  43. isshowbtn: false, //是否显示按钮
  44. title: "小学语文朗读配音", //标题
  45. },
  46. },
  47. onLoad: function (option) {
  48. console.log(option);
  49. this.videoCtx = null;
  50. const uid = wx.getStorageSync('uid')
  51. this.getClassInfo(option.id);
  52. // this.getMicAuth()
  53. },
  54. getClassInfo: function (id) {
  55. httpRequestApi.getClassDetail(id).success(res => {
  56. console.log('课程信息', res)
  57. let reg = /\\n/g
  58. this.setData({
  59. title: res.data.data.userRead.title,
  60. videoUrl: res.data.data.userRead.videoPath,
  61. originVideo: res.data.data.userRead.originVideo,
  62. img: res.data.data.userRead.iconImg,
  63. id: res.data.data.userRead.id,
  64. readingText: res.data.data.userRead.lessonText,
  65. grade: res.data.data.userRead.grade,
  66. exampleId: res.data.data.userRead.exampleId,
  67. summary: res.data.data.userRead.summary,
  68. coverImg: res.data.data.userRead.coverImg,
  69. })
  70. this.getReadInfo(id)
  71. httpRequestApi.userIntoPage('pages/reading/reading', '朗读页面').success((res) => {
  72. })
  73. })
  74. },
  75. onHide: function () {
  76. console.log('onhide')
  77. if (this.data.audioPlaying) {
  78. console.log('返回时状态', this.data.audioPlaying)
  79. // this.ss.stopPlay();
  80. }
  81. if (this.data.btnImgFlag) {
  82. // this.ss.stopRecord();
  83. }
  84. // this.ss.destroyEngine();
  85. this.setData({
  86. recordFlag: 0
  87. })
  88. },
  89. onUnload: function () {
  90. console.log('onUnload')
  91. if (this.data.audioPlaying) {
  92. console.log('销毁时状态', this.data.audioPlaying)
  93. // this.ss.stopPlay();
  94. }
  95. if (this.data.btnImgFlag) {
  96. // this.ss.stopRecord();
  97. }
  98. // this.ss.destroyEngine();
  99. },
  100. onShow: function () {
  101. this.videoCtx = wx.createVideoContext('myVideo', this);
  102. let data = requirePlugin("myPlugin");
  103. const obj = {
  104. appid: 'a415',
  105. userid: wx.getStorageSync('uid'),
  106. getEvalMessage: (res) => {
  107. this.getRecordScore(res)
  108. // console.log('评测结果',res)
  109. },
  110. recorderCallback: (type, data) => {
  111. // 录音测评监控回调
  112. this.ssRecorderCallback(type, data)
  113. }
  114. }
  115. // this.ss = new data.ssEngine(obj);
  116. this.recorderManager = wx.getRecorderManager();
  117. this.recorderManager.onStop((res) => {
  118. // wx.showToast({
  119. // title: 'onStop',
  120. // icon: 'fail',
  121. // duration: 500
  122. // })
  123. this.videoCtx.stop();
  124. console.log('recorder stop', res)
  125. const recordFile = res.tempFilePath;
  126. this.setData({
  127. recordFlag: 0,
  128. recordSource: recordFile,
  129. btnFlag: true,
  130. btnImgFlag: false
  131. })
  132. this.wsEngine.stop({
  133. success: () => {
  134. console.log('====== wsEngine stop success ======');
  135. // TODO: add your code here
  136. },
  137. fail: (res) => {
  138. console.log("====== wsEngine stop fail ======");
  139. console.log(JSON.stringify(res)); //请关注res.errId, res.error
  140. // TODO: add your code here
  141. },
  142. complete: () => {
  143. // TODO: add your code here
  144. // clearInterval(recordTimeInterval);
  145. console.log("====== wsEngine stop complete ======");
  146. }
  147. });
  148. })
  149. this.recorderManager.onStart(() => {
  150. // this.saveVideo();
  151. this.setData({
  152. btnImgFlag: true,
  153. btnFlag: false
  154. })
  155. console.log('recorder start')
  156. });
  157. //监听已录制完指定帧大小的文件事件。如果设置了 frameSize,则会回调此事件。
  158. this.recorderManager.onFrameRecorded((res) => {
  159. const {
  160. frameBuffer
  161. } = res
  162. console.log('frameBuffer.byteLength', frameBuffer.byteLength)
  163. //TODO 调用feed接口传递音频片给驰声评测引擎
  164. this.wsEngine.feed({
  165. data: frameBuffer, // frameBuffer为微信录音机回调的音频数据
  166. success: () => {
  167. // feed 成功
  168. console.log('feed success.')
  169. },
  170. fail: (res) => {
  171. // feed 失败, 请关注res.errId, res.error
  172. console.log('feed fail:', JSON.stringify(res))
  173. },
  174. complete: () => {
  175. // feed 完成
  176. }
  177. });
  178. });
  179. this.wsEngine = aiengine.createWsEngine({});
  180. this.wsEngine.onResult(res => {
  181. console.log('驰声评测结果', res);
  182. let overall = res.result.overall;
  183. let accuracy = res.result.accuracy;
  184. wx.showModal({
  185. title: `总分${overall}`,
  186. content: `accuracy${accuracy}`,
  187. confirmText: '我知道了',
  188. showCancel: false,
  189. success(res) {
  190. console.log('用户点击确定')
  191. }
  192. })
  193. })
  194. this.wsEngine.onErrorResult(res => {
  195. console.log('驰声createWsEngine失败', res);
  196. })
  197. },
  198. ssRecorderCallback: function (type, data) {
  199. console.log('录音测评监控回调', type)
  200. console.log('录音测评监控回调', data)
  201. /* 录音开始 */
  202. if (type === 'onStart') {
  203. this.setData({
  204. btnImgFlag: true,
  205. btnFlag: false
  206. })
  207. console.log('recorder start')
  208. }
  209. if (type === 'onStop') {
  210. this.videoCtx.stop();
  211. this.setData({
  212. recordFlag: 0,
  213. recordSource: data.tempFilePath,
  214. btnFlag: true,
  215. btnImgFlag: false
  216. })
  217. console.log('recorder start')
  218. }
  219. },
  220. // 录音中视频播放结束 (控制录音同时结束)
  221. recordingVideoEnd: function () {
  222. console.log(this.data.videoCtr)
  223. console.log('recordingVideoEnd');
  224. //
  225. if (this.data.recordFlag === 0) {
  226. // this.recordStop();
  227. this.playingVideoEnd();
  228. return;
  229. }
  230. // 录音结束
  231. if (this.data.recordFlag === 1) {
  232. this.recordStop();
  233. }
  234. },
  235. // 播放中视频播放结束 (控制录音同时结束)
  236. playingVideoEnd: function () {
  237. console.log('playingVideoEnd')
  238. // this.ss.stopPlay();
  239. },
  240. /***
  241. * recordFlag:
  242. * 0 初始状态
  243. * 1 录音中
  244. * 2 录音结束
  245. ***/
  246. audioRecord: function () {
  247. console.log('111111111111111recordFlag', this.data.recordFlag)
  248. if (this.data.recordFlag === 0) {
  249. // this.recordStart();
  250. // this.saveVideo();
  251. console.log('2222222222是否有视频', this.videoCtx)
  252. if (this.videoCtx) {
  253. console.log('3333333333333停止视频停止视频停止视频')
  254. this.videoCtx.stop();
  255. // this.videoCtx.seek(0);
  256. }
  257. if (this.data.audioPlaying) {
  258. // this.ss.stopPlay();
  259. }
  260. // if (this.recorderManager) {
  261. // this.recorderManager.stop();
  262. // }
  263. // if (this.innerAudioContext) {
  264. // this.innerAudioContext.stop();
  265. // }
  266. this.getMicAuth()
  267. // this.videoComplete();
  268. return;
  269. }
  270. // 录音结束后
  271. if (this.data.recordFlag === 1) {
  272. wx.showLoading({
  273. title: '作品转码中',
  274. mask: true
  275. })
  276. this.recordStop();
  277. }
  278. },
  279. // 录音开始
  280. /**
  281. * duration: 时长 最长10分钟
  282. sampleRate: 44100, 采样率
  283. numberOfChannels: 1, 录音通道
  284. encodeBitRate: 192000, 码率
  285. format: 'mp3', 格式
  286. frameSize: 50 制定帧大小
  287. */
  288. recordStart: function () {
  289. console.log('录音开始');
  290. const options = {
  291. duration: 600000,
  292. sampleRate: 44100,
  293. numberOfChannels: 1,
  294. encodeBitRate: 192000,
  295. format: 'mp3',
  296. frameSize: 50
  297. }
  298. this.recorderManager.start(options);
  299. // this.ss.startRecord({
  300. // coreType: 'cn.sent.score', //测评题型
  301. // evalTime: 300000, //测评的录音时间,时间到自动停止测评
  302. // refText: this.data.readingText, //测评文本
  303. // warrantId: 'c11163aa6c834a028da4a4b30955be96', //鉴权id
  304. // })
  305. // 驰声测评
  306. let timeStamp = new Date().getTime()
  307. let sig = sha1(`16075689600000da${timeStamp}caa8e60da6042731c230fe431ac9c7fd`)
  308. console.log('加密串', sig)
  309. // return
  310. let app = {
  311. applicationId: '16075689600000da',
  312. sig, //签名字符串 通过签名算法alg(appkey + timestamp + secretKey)生成
  313. alg: 'sha1',
  314. timestamp: timeStamp + '',
  315. userId: wx.getStorageSync('uid')
  316. }
  317. console.log('app数据', app)
  318. let lessonText = this.data.readingText;
  319. console.log('课文课文课文',lessonText)
  320. this.wsEngine.start({
  321. app,
  322. request: {
  323. coreType: "cn.pred.raw",
  324. refText: lessonText,
  325. rank: 100,
  326. attachAudioUrl: 1
  327. },
  328. audio: {
  329. audioType: "mp3",
  330. channel: 1,
  331. sampleBytes: 2,
  332. sampleRate: 16000
  333. },
  334. success: (res) => {
  335. // 调用成功
  336. console.log('驰声start成功', res)
  337. },
  338. fail: (res) => {
  339. // start失败,请关注res.errId, res.error
  340. console.log('驰声start失败', res)
  341. }
  342. })
  343. },
  344. getMicAuth() {
  345. let _this = this;
  346. wx.getSetting({
  347. success(res) {
  348. if (res.authSetting['scope.record']) {
  349. // that.videoComplete();
  350. _this.videoComplete();
  351. } else {
  352. _this.getMicSetAuth();
  353. return;
  354. }
  355. }
  356. })
  357. },
  358. getMicSetAuth() {
  359. let _this = this;
  360. wx.authorize({
  361. scope: 'scope.record',
  362. success() {
  363. // 用户已经同意小程序使用录音功能,后续调用 wx.startRecord 接口不会弹窗询问
  364. _this.audioRecord();
  365. },
  366. fail() {
  367. wx.showModal({
  368. title: '录音前请打开麦克风权限',
  369. content: '',
  370. confirmText: '我知道了',
  371. showCancel: false,
  372. success(res) {
  373. // console.log('用户点击确定')
  374. wx.openSetting({
  375. success(res) {
  376. console.log('跳转到设置页', res.authSetting)
  377. // res.authSetting = {
  378. // "scope.userInfo": true,
  379. // "scope.userLocation": true
  380. // }
  381. }
  382. })
  383. }
  384. })
  385. }
  386. })
  387. },
  388. // 录音结束
  389. recordStop: function () {
  390. this.setData({
  391. muted: false
  392. })
  393. // this.ss.stopRecord();
  394. console.log('录音结束')
  395. this.recorderManager.stop();
  396. wx.hideLoading()
  397. },
  398. // 获取测评结果
  399. getRecordScore(res) {
  400. console.log('测评结果', res)
  401. const result = res.result;
  402. const overall = result.overall; // 总分
  403. const integrity = result.integrity; //完成度
  404. const tone = result.tone; // 语调声调
  405. const accuracy = result.accuracy; // 发音分
  406. const fluency = result.fluency.overall; //流利度
  407. let starArray = [];
  408. let score = overall / 20;
  409. if (score <= 0) {
  410. starArray = [0, 0, 0, 0, 0]
  411. } else {
  412. for (let i = 1; i < 5; i += 0.9) {
  413. if (i < score) {
  414. starArray.push(1);
  415. } else {
  416. starArray.push(0)
  417. }
  418. }
  419. }
  420. this.setData({
  421. overall,
  422. integrity,
  423. tone,
  424. accuracy,
  425. fluency,
  426. ifScoreDialogShow: true,
  427. star: starArray
  428. })
  429. },
  430. closeScoreDialog() {
  431. this.setData({
  432. ifScoreDialogShow: false,
  433. ifScoreShow: true,
  434. ifTextShow: false
  435. })
  436. },
  437. // 播放录音
  438. audioPlay: function () {
  439. /* 用了先声智能以后录音播放由先声只能接管 */
  440. this.setData({
  441. videoUrl: this.data.videoUrl
  442. })
  443. if (this.data.audioPath) {
  444. if (this.data.audioPlaying) {
  445. // this.ss.stopPlay();
  446. }
  447. // this.ss.startPlay(this.data.audioPath);
  448. this.videoCtx.stop();
  449. this.videoCtx.play();
  450. } else {
  451. const recordSource = this.data.recordSource
  452. wx.uploadFile({
  453. url: 'https://reader-api.ai160.com/file/upload',
  454. filePath: recordSource,
  455. name: '朗读录音',
  456. header: {
  457. uid: wx.getStorageSync('uid')
  458. },
  459. success: (res) => {
  460. const formateRes = JSON.parse(res.data);
  461. let audioPath = formateRes.data;
  462. this.setData({
  463. audioPath,
  464. audioPlaying: true
  465. })
  466. // this.ss.startPlay(audioPath);
  467. // this.videoCtx.seek(0);
  468. this.videoCtx.stop();
  469. console.log('播放器归0')
  470. this.videoCtx.play();
  471. console.log('播放器播放')
  472. }
  473. })
  474. }
  475. },
  476. videoComplete: function () {
  477. // let videoUrl = 'http://efunimgs.ai160.com/ott/test/002tPr2Xlx07oP7B4ro40104120022hP0k010.mp4';
  478. this.setData({
  479. recordFlag: 1,
  480. videoUrl: this.data.originVideo,
  481. centerBtn: false,
  482. playBtn: false,
  483. isVideoListShow: false,
  484. muted: true,
  485. ifTextShow: true,
  486. ifScoreShow: false
  487. }, () => {
  488. this.videoCtx.play();
  489. this.recordStart();
  490. })
  491. },
  492. // 上传
  493. upload: function () {
  494. if (this.videoCtx) {
  495. this.videoCtx.stop();
  496. }
  497. if (this.data.audioPlaying) {
  498. // this.ss.stopPlay();
  499. this.setData({
  500. audioPlaying: false
  501. })
  502. }
  503. wx.showLoading({
  504. title: '作品上传中',
  505. mask: true
  506. })
  507. if (this.data.audioPath) {
  508. this.shareWorks(this.data.audioPath)
  509. } else {
  510. const recordSource = this.data.recordSource;
  511. wx.uploadFile({
  512. url: 'https://reader-api.ai160.com/file/upload',
  513. filePath: recordSource,
  514. name: '朗读录音',
  515. header: {
  516. uid: wx.getStorageSync('uid')
  517. },
  518. success: (res) => {
  519. const formateRes = JSON.parse(res.data);
  520. let audioPath = formateRes.data;
  521. this.shareWorks(audioPath);
  522. }
  523. })
  524. }
  525. },
  526. shareWorks: function (audio) {
  527. const data = {
  528. "lessonId": this.data.id,
  529. "originVideo": this.data.videoUrl,
  530. "audioPath": audio,
  531. "title": this.data.title,
  532. "iconImg": this.data.img,
  533. "summary": this.data.summary,
  534. "productId": this.data.productId,
  535. "grade": this.data.grade,
  536. "exampleId": this.data.exampleId,
  537. "coverImg": this.data.coverImg
  538. };
  539. httpRequestApi.postWork(data).success(res => {
  540. wx.hideLoading({
  541. success: () => {
  542. wx.showToast({
  543. title: '作品已上传正在审核中',
  544. icon: 'none',
  545. duration: 1000,
  546. success: () => {
  547. console.log('上传成功', res);
  548. const _data = this.data;
  549. const scoreData = {
  550. "userReadId": res.data.data.id,
  551. "complete": _data.integrity,
  552. "accuracy": _data.accuracy,
  553. "speed": _data.fluency,
  554. "intonation": _data.tone,
  555. "score": _data.overall
  556. }
  557. // 上传评分
  558. httpRequestApi.postWorksScore(scoreData).success(res => {
  559. console.log(res)
  560. });
  561. const pages = getCurrentPages();
  562. const prevPage = pages[pages.length - 2];
  563. prevPage.setData({
  564. // workId: res.data.data.id, // 有id就塞到第一位
  565. fromReading: true
  566. }, () => {
  567. wx.navigateBack({
  568. delta: 1
  569. })
  570. })
  571. }
  572. })
  573. }
  574. });
  575. }).fail(res => {
  576. wx.hideLoading({
  577. success: () => {
  578. wx.showToast({
  579. title: '上传超时',
  580. icon: 'fail',
  581. duration: 1000
  582. })
  583. }
  584. });
  585. })
  586. },
  587. // 获取本课朗读内容
  588. getReadInfo: function (id, pageNo, pageSize) {
  589. // const uid = wx.getStorageSync('uid');
  590. const data = {
  591. exampleId: this.data.id || id,
  592. pageNo: this.data.pageNo,
  593. pageSize: 3,
  594. type: 'READ'
  595. };
  596. httpRequestApi.getClassRead(data).success(res => {
  597. const readInfo = res.data.data.list;
  598. console.log(res)
  599. readInfo.forEach(item => {
  600. const temp = {};
  601. temp.title = item.userRead ? item.userRead.title : '';
  602. temp.img = item.userRead.iconImg;
  603. temp.plays = item.userRead.playAmount ? item.userRead.playAmount : 0;
  604. temp.likes = item.userRead.likeAmount ? item.userRead.likeAmount : 0;
  605. temp.classId = item.userRead.exampleId;
  606. temp.time = formatDate(item.userRead.gmtCreated, 3);
  607. temp.avatar = item.user ? item.user.avatar : '';
  608. temp.uid = item.user ? item.user.uid : '';
  609. temp.url = item.userRead.videoPath;
  610. // temp.avatar = item.user.avatar;
  611. temp.nickName = item.user ? item.user.wechatName : '';
  612. temp.id = item.userRead.id;
  613. temp.noReading = true;
  614. temp.isFans = item.isFans ? true : item.user.uid === this.uid ? true : false;
  615. temp.coverImg = item.userRead.coverImg;
  616. temp.videoShow = false;
  617. temp.grade = item.userRead.grade;
  618. temp.type = item.userRead.type;
  619. // recommendWorks.push(temp);
  620. // that.data.hotData.hotWorks.push(temp);
  621. this.data.videoList.push(temp);
  622. });
  623. this.setData({
  624. videoList: this.data.videoList,
  625. totalSize: res.data.data.totalSize
  626. })
  627. });
  628. },
  629. // 评论区点击
  630. commentTap: function (e) {
  631. console.log('点击评论区', e)
  632. if (e.target.dataset.type === 'blank') {
  633. this.setData({
  634. commentShow: false
  635. })
  636. }
  637. },
  638. scrollToLower: function (e) {
  639. console.log('滑动到底部', e)
  640. this.setData({
  641. pageNo: this.data.pageNo + 1
  642. }, () => {
  643. this.getReadInfo()
  644. })
  645. },
  646. scrollToUpper: function (e) {
  647. console.log('滑动到顶部', e)
  648. },
  649. // 打开评论
  650. openComment: function (e) {
  651. console.log('id', e.detail.activeId)
  652. this.setData({
  653. commentShow: !this.data.commentShow,
  654. commentId: e.detail.activeId,
  655. });
  656. },
  657. goToReading: function (e) {
  658. this.setData({
  659. pageNo: 1,
  660. videoList: []
  661. })
  662. const id = e.detail.activeId ? e.detail.activeId : e.currentTarget.dataset.id;
  663. this.getClassInfo(id)
  664. },
  665. onShareAppMessage: function (res) {
  666. console.log('点击分享按钮', res)
  667. console.log('点击分享按钮', this.data.shareTitle)
  668. console.log('点击分享按钮', this.data.shareId)
  669. console.log('点击分享按钮', this.data.shareImg)
  670. if (res.from === 'button') {
  671. return {
  672. title: '请欣赏我的课文朗读作品,点赞+评论。',
  673. path: `/pages/index/index?readId=${this.data.shareId}`,
  674. imageUrl: '../../static/index/share_icon.png'
  675. }
  676. } else {
  677. return {
  678. title: '课文朗读,从未如此有趣。',
  679. path: '/pages/index/index',
  680. }
  681. }
  682. },
  683. touchMove: function () {
  684. return
  685. },
  686. openShare: function (e) {
  687. console.log('用户点击分享按钮', e)
  688. this.setData({
  689. shareTitle: e.detail.currentTarget.dataset.title,
  690. shareId: e.detail.currentTarget.dataset.id,
  691. shareImg: e.detail.currentTarget.dataset.img
  692. })
  693. },
  694. onPlay: function (e) {
  695. // 下边视频列表onplay
  696. console.log('视频播放视频播放')
  697. if (this.videoCtx) {
  698. this.videoCtx.stop();
  699. } else {
  700. this.videoCtx = wx.createVideoContext('myVideo', this);
  701. this.videoCtx.stop();
  702. }
  703. },
  704. collectTap: function (e) {
  705. console.log('点击收藏', e)
  706. const index = e.detail.index;
  707. let str = `videoList[${index}].isFavorite`
  708. this.setData({
  709. [str]: e.detail.isCollect
  710. })
  711. },
  712. likeTap: function (e) {
  713. console.log('点赞', e)
  714. const index = e.detail.index;
  715. let likeStr = `videoList[${index}].isLike`;
  716. let likeNumStr = `videoList[${index}].likes`;
  717. this.setData({
  718. [likeStr]: true,
  719. [likeNumStr]: this.data.videoList[index].likes + 1
  720. })
  721. },
  722. })