works.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811
  1. import httpRequestApi from '../../../utils/APIClient';
  2. import {
  3. formatDate
  4. } from '../../../utils/util';
  5. import {
  6. getOpenidNoLogin
  7. } from '../../../utils/httpUtilNoLogin';
  8. import {
  9. getOpenidSessionKey
  10. } from '../../../utils/httpUtil';
  11. const app = getApp()
  12. Page({
  13. data: {
  14. fullScreenBtn: false,
  15. playBtn: true,
  16. gesture: false,
  17. author: '',
  18. videoSrc: '',
  19. total: '',
  20. authorAvatar: '',
  21. user: [],
  22. inputValue: '',
  23. inputSBValue: '',
  24. replyList: [],
  25. howMuch: '200',
  26. moneySelect: 'moneySelect',
  27. moneyNormal: 'moneyNormal',
  28. ifReward: false,
  29. id: '',
  30. path: '',
  31. replyModal: false,
  32. totalRead: 0,
  33. pageNo: 1,
  34. pageSize: 3,
  35. goBackHome: false,
  36. isIOS: app.globalData.isIOS,
  37. alertFlag: false,
  38. modalType: "text",
  39. noScroll: '',
  40. modalText: app.globalData.isIOS ? [{
  41. text: '由于相关规范,ios功能暂不可用',
  42. type: 'bigOrange'
  43. },
  44. {
  45. text: '联系客服解锁哦',
  46. type: 'normal'
  47. }
  48. ] : [{
  49. text: '快去开通VIP',
  50. type: 'bigOrange'
  51. },
  52. {
  53. text: '享受更多权益吧',
  54. type: 'normal'
  55. }
  56. ],
  57. modalBtnText: '解锁课程',
  58. isModalShow: false,
  59. modalCloseShow: true,
  60. hide: true,
  61. addComeOut: '',
  62. flowerNum: '6',
  63. readIsRisky: ''
  64. // shareFlag: false
  65. },
  66. showAlert: function () {
  67. this.setData({
  68. alertFlag: !this.data.alertFlag
  69. })
  70. },
  71. onLoad: function (option) {
  72. console.log(option)
  73. console.log(option.flowerCount)
  74. console.log(option.flowerCount === 0)
  75. if (option.flowerCount) {
  76. this.setData({
  77. fromReading: true
  78. })
  79. this.flowerAnimationHandler();
  80. // setTimeout(() => {
  81. // this.openShare();
  82. // }, 300)
  83. if (option.flowerCount > 0) {
  84. this.setData({
  85. flowerNum: option.flowerCount
  86. })
  87. }
  88. }
  89. // getOpenidNoLogin
  90. getOpenidNoLogin((res) => {
  91. let id = option.id ? option.id : option.scene.replace('QR', '')
  92. if (option.scene || option.shareCard) {
  93. this.setData({
  94. goBackHome: true
  95. })
  96. }
  97. // wx.setNavigationBarTitle({
  98. // title: option.title //页面标题为路由参数
  99. // })
  100. this.uid = wx.getStorageSync('uid');
  101. let stackSize = 1;
  102. if (option.stackSize) {
  103. stackSize = option.stackSize;
  104. }
  105. console.log(2222222222222222)
  106. this.setData({
  107. // title: option.title,
  108. id: id,
  109. myUid: this.uid,
  110. stackSize
  111. }, () => {
  112. console.log(this.data.id)
  113. this.getWorks(this.uid, id);
  114. // this.getReply();
  115. })
  116. }, (error) => {
  117. wx.setStorageSync('userSourseType', 'reading')
  118. // this.setData({
  119. // hide: !this.data.hide,
  120. // onLoadOption: option
  121. // })
  122. return;
  123. });
  124. },
  125. onHide: function () {
  126. // this.data.stackSize >= 2
  127. console.log('=================================hide')
  128. if (this.innerAudioContext) {
  129. console.log('音频应该被暂停')
  130. this.innerAudioContext.pause();
  131. this.innerAudioContext.volume = 0;
  132. }
  133. // this.videoCtx = null
  134. },
  135. onUnload: function () {
  136. console.log('-------------------页面雨鞋')
  137. if (this.videoPlayTime) {
  138. const data = {
  139. "title": this.data.title,
  140. "lessonId": this.data.classId,
  141. "productId": this.data.productId,
  142. "playStopTime": Math.ceil(this.videoPlayTime),
  143. "userReadId": this.data.userReadId,
  144. "type": 'READ',
  145. }
  146. httpRequestApi.playLogReport(data).success(res => {
  147. console.log(res)
  148. })
  149. if (this.innerAudioContext) {
  150. console.log('音频应该被暂停')
  151. this.innerAudioContext.pause();
  152. this.innerAudioContext.volume = 0;
  153. }
  154. }
  155. if (this.innerAudioContext) {
  156. this.innerAudioContext.destroy();
  157. }
  158. this.videoCtx = null
  159. // let videoCtx = wx.createVideoContext('worksVideo', this);
  160. // videoCtx.stop();
  161. },
  162. getWorks: function (uid, id) {
  163. httpRequestApi.getWorksDetail(uid, id, this.data.goBackHome ? 'READ_SHARE' : '').success((res) => {
  164. const others = res.data.data.otherRead;
  165. const author = res.data.data.user;
  166. const works = res.data.data.userRead;
  167. console.log(11111111, author)
  168. console.log(22222222, others)
  169. wx.setNavigationBarTitle({
  170. title: works.title //页面标题为路由参数
  171. })
  172. const othersTemp = [];
  173. others.forEach((item) => {
  174. if (!item) return
  175. const temp = {};
  176. temp.uid = item.userRead.id;
  177. temp.title = item.userRead.title;
  178. temp.image = item.user.avatar;
  179. temp.nickName = item.user.wechatName;
  180. othersTemp.push(temp);
  181. });
  182. this.setData({
  183. user: othersTemp,
  184. totalRead: res.data.data.totalRead,
  185. author: author.wechatName,
  186. authorAvatar: author.avatar,
  187. authorProfession: author.profession,
  188. authorUid: author.uid,
  189. audioSrc: works.audioPath,
  190. iconImg: works.iconImg,
  191. classId: works.lessonId,
  192. isLike: res.data.data.isLike,
  193. isFans: res.data.data.isFans,
  194. videoSrc: works.originVideo,
  195. title: works.title,
  196. userReadId: works.id
  197. })
  198. httpRequestApi.checkLesson(works.lessonId).success(res => {
  199. const productId = res.data.data[0];
  200. this.setData({
  201. productId: productId
  202. })
  203. });
  204. if (this.data.fromReading) {
  205. setTimeout(() => {
  206. this.openShare()
  207. })
  208. }
  209. if (works.isRisky === 'DEL') {
  210. this.setData({
  211. readIsRisky: 'DEL'
  212. });
  213. return false;
  214. }
  215. // 设置音频路径
  216. this.innerAudioContext = wx.createInnerAudioContext();
  217. this.innerAudioContext.onPause((res) => {
  218. // 播放音频失败的回调
  219. console.log('音频暂停')
  220. })
  221. this.innerAudioContext.src = this.data.audioSrc; // 这里可以是录音的临时路径
  222. });
  223. },
  224. onShow() {
  225. this.timeOut = setInterval(()=>{
  226. if (this.data.id) {
  227. clearInterval(this.timeOut)
  228. this.setData({
  229. replyList: [],
  230. pageNo: 1,
  231. pageSize: 8
  232. }, () => {
  233. this.getReply();
  234. })
  235. }
  236. },200)
  237. },
  238. videoPlayHandler: function () {
  239. if (this.data.readIsRisky === 'DEL') {
  240. wx.showModal({
  241. title: '提示',
  242. content: '作品还在审核中,请稍后收听(一分钟内)。',
  243. confirmText: '我知道了',
  244. showCancel: false,
  245. success(res) {
  246. console.log('用户点击确定')
  247. }
  248. })
  249. return false;
  250. }
  251. this.setData({
  252. videoLoad: true
  253. }, () => {
  254. this.videoCtx = wx.createVideoContext('worksVideo', this);
  255. this.videoCtx.play();
  256. })
  257. },
  258. likeWorks: function (e) {
  259. // + 1 + 1的动画
  260. this.setData({
  261. addComeOut: 'add-one-come-out'
  262. // isLike: true
  263. })
  264. setTimeout(() => {
  265. if (this.data.addComeOut) {
  266. this.setData({
  267. addComeOut: ''
  268. })
  269. }
  270. }, 1100)
  271. // 恭喜获得x朵小红花
  272. if (this.data.isLike) {
  273. // wx.showToast({
  274. // title: '不要重复点赞哦',
  275. // icon: 'fail',
  276. // duration: 1000
  277. // })
  278. return;
  279. }
  280. httpRequestApi.likeWorks(this.uid, this.data.id).success(res => {
  281. this.setData({
  282. isLike: true,
  283. flowerNum: res.data.count
  284. }, () => {
  285. if (res.data.count > 0) {
  286. this.flowerAnimationHandler();
  287. }
  288. });
  289. })
  290. },
  291. // 弹出分享框
  292. openShare: function (e) {
  293. console.log(this.data.authorAvatar)
  294. console.log(this.data.author)
  295. console.log(this.data.iconImg)
  296. console.log(this.data.title)
  297. console.log(this.data.id)
  298. if (this.data.authorAvatar && this.data.author && this.data.iconImg && this.data.title && this.data.id) {
  299. this.shareDialog = this.selectComponent("#share-dialog");
  300. const data = {
  301. avatar: this.data.authorAvatar,
  302. author: this.data.author,
  303. iconImg: this.data.iconImg,
  304. title: this.data.title,
  305. path: `pages/social/works/works`,
  306. scene: this.data.id,
  307. productId: this.data.productId
  308. // tip: this.data.tip,
  309. }
  310. // console.log(data)
  311. this.setData({
  312. noScroll: 'noScroll'
  313. })
  314. this.shareDialog.share(data);
  315. }
  316. },
  317. // 分享框关闭
  318. shareDialogClose: function (e) {
  319. this.setData({
  320. noScroll: ''
  321. })
  322. },
  323. videoPlay: function (event) {
  324. console.log(11111, this.videoPlayTime)
  325. if (this.data.readIsRisky === 'DEL') {
  326. wx.showModal({
  327. title: '提示',
  328. content: '作品还在审核中,请稍后收听(一分钟内)。',
  329. confirmText: '我知道了',
  330. showCancel: false,
  331. success(res) {
  332. console.log('用户点击确定')
  333. }
  334. })
  335. return false;
  336. }
  337. if (this.innerAudioContext) {
  338. this.innerAudioContext.volume = 1;
  339. if (this.videoPlayTime) {
  340. this.innerAudioContext.seek(this.videoPlayTime);
  341. }
  342. }
  343. console.log('============', this.data.goBackHome)
  344. // 视频开始 先结束 再开始
  345. // this.innerAudioContext.play();
  346. // this.innerAudioContext.pause();
  347. // wx.showToast({
  348. // title: '加载中',
  349. // icon: 'loading',
  350. // duration: 600
  351. // })
  352. // setTimeout(() => {
  353. this.innerAudioContext.play();
  354. // }, 800)
  355. // httpRequestApi.playWorks(this.uid, this.data.id).success(() => {
  356. // console.log('容个错')
  357. // });
  358. },
  359. // 视频播放完毕销毁录音
  360. videoEnd: function (e) {
  361. console.log(e)
  362. this.innerAudioContext.stop();
  363. },
  364. videoPause: function (event) {
  365. console.log('视频暂停')
  366. console.log('暂停', event)
  367. this.innerAudioContext.pause();
  368. this.innerAudioContext.volume = 0;
  369. },
  370. videoWaiting: function () {
  371. console.log('视频缓冲')
  372. this.innerAudioContext.pause();
  373. },
  374. videoProgress: function (e) {
  375. if (e.detail.buffered <= 10) {
  376. this.innerAudioContext.pause();
  377. } else {
  378. this.innerAudioContext.play();
  379. }
  380. },
  381. videoTimeupdate: function (e) {
  382. this.videoPlayTime = e.detail.currentTime
  383. // if (e.detail.currentTime - this.innerAudioContext.currentTime >= 1) {
  384. // this.innerAudioContext.seek(e.detail.currentTime - 0.1);
  385. // }
  386. },
  387. goToReading: function () {
  388. // this.setData({
  389. // isModalShow: true
  390. // })
  391. // return
  392. const classId = this.data.classId;
  393. if (this.innerAudioContext && this.videoCtx) {
  394. this.videoCtx.pause();
  395. this.innerAudioContext.pause();
  396. this.innerAudioContext.volume = 0;
  397. console.log('关闭音频')
  398. }
  399. getOpenidSessionKey((res) => {
  400. httpRequestApi.getUserAuth().success(res => {
  401. if (res.data.data) {
  402. wx.authorize({
  403. scope: 'scope.record',
  404. success() {
  405. // 用户已经同意小程序使用录音功能,后续调用 wx.startRecord 接口不会弹窗询问
  406. console.log('成功')
  407. wx.navigateTo({
  408. url: `../../reading/reading?id=${classId}`
  409. })
  410. },
  411. fail() {
  412. wx.showModal({
  413. title: '录音前请打开麦克风权限',
  414. content: '点击右上角浮点...,选择:设置-麦克风,点击/打开。',
  415. confirmText: '我知道了',
  416. showCancel: false,
  417. success(res) {
  418. console.log('用户点击确定')
  419. }
  420. })
  421. }
  422. })
  423. } else {
  424. if (this.data.isIOS) {
  425. wx.navigateTo({
  426. url: `../../vipPage/wechat/wechat`
  427. })
  428. } else {
  429. this.setData({
  430. modalType: 'androidVIP',
  431. isModalShow: true
  432. })
  433. }
  434. }
  435. })
  436. }, (error) => {
  437. this.setData({
  438. hide: !this.data.hide
  439. })
  440. return;
  441. });
  442. },
  443. onShareAppMessage: function () {
  444. console.log(this.data.productId);
  445. const data = {
  446. shareTypeEnum: 'LINK',
  447. shareContentEnum: 'READ',
  448. productId: this.data.productId
  449. }
  450. httpRequestApi.shareRecord(data).success((res) => {
  451. console.log(res)
  452. })
  453. return {
  454. title: '一样的课文,不一样的味道!我的配音表演已开始,求各位大咖围观、点评!',
  455. path: `pages/social/works/works?id=${this.data.id}&title=${this.data.title}&shareCard=true`,
  456. imageUrl: `https://efunbox.lingjiao.cn/reader/resource/share/read_${this.data.productId}.jpg`,
  457. }
  458. },
  459. follow: function () {
  460. let followUid = this.data.authorUid;
  461. if (this.data.isFans) {
  462. httpRequestApi.cancerFollow(this.uid, followUid).success((res) => {
  463. this.setData({
  464. isFans: false
  465. })
  466. wx.showToast({
  467. title: '取消关注',
  468. icon: 'success',
  469. duration: 1000
  470. })
  471. });
  472. } else {
  473. httpRequestApi.followUser(this.uid, followUid).success((res) => {
  474. this.setData({
  475. isFans: true
  476. })
  477. wx.showToast({
  478. title: '关注啦',
  479. icon: 'success',
  480. duration: 1000
  481. })
  482. });
  483. }
  484. },
  485. // 点赞评论
  486. likeCommend: function (e) {
  487. console.log(e);
  488. // let uid = wx.getStorageSync('uid');
  489. let followUid = e.currentTarget.dataset.id;
  490. let index = e.currentTarget.dataset.index;
  491. httpRequestApi.likeCommend(this.uid, followUid).success(res => {
  492. console.log(res);
  493. const str = `replyList[${index}].likes`;
  494. const strImg = `replyList[${index}].isLike`;
  495. this.setData({
  496. [str]: res.data.data.favors,
  497. [strImg]: true
  498. })
  499. });
  500. },
  501. // 去用户主页
  502. goToUsers: function (e) {
  503. let uid = e.currentTarget.dataset.uid;
  504. wx.navigateTo({
  505. url: `../../user/myworks/myworks?uid=${uid}`
  506. });
  507. },
  508. // 去其他用户的作品页
  509. goToOthers: function (e) {
  510. this.data.stackSize++;
  511. console.log(this.data.stackSize)
  512. if (this.data.stackSize >= 3) {
  513. console.log('跳转', this.data.stackSize)
  514. wx.redirectTo({
  515. url: `../../social/works/works?id=${e.currentTarget.dataset.uid}&title=${e.currentTarget.dataset.title}&stackSize=${this.data.stackSize}`
  516. })
  517. } else {
  518. console.log('下一个页面', this.data.stackSize)
  519. wx.navigateTo({
  520. url: `../../social/works/works?id=${e.currentTarget.dataset.uid}&title=${e.currentTarget.dataset.title}&stackSize=${this.data.stackSize}`
  521. })
  522. }
  523. },
  524. // 查询回复
  525. getReply: function () {
  526. // let uid = wx.getStorageSync('uid');
  527. let columnId = this.data.id;
  528. console.log(123123123, columnId)
  529. let pageNo = this.data.pageNo;
  530. let pageSize = this.data.pageSize;
  531. httpRequestApi.getReply(this.uid, columnId, pageNo, pageSize).success((res) => {
  532. const replyList = res.data.data.list;
  533. // const replyTemp = [];
  534. replyList.forEach((item) => {
  535. const temp = {};
  536. temp.nickName = item.user.wechatName;
  537. temp.avatar = item.user.avatar;
  538. temp.profession = item.user.profession;
  539. temp.uid = item.user.uid;
  540. // temp.text = decodeURI(item.detailDesc);
  541. temp.text = item.detailDesc;
  542. temp.id = item.id;
  543. temp.replyCount = item.replyCount;
  544. temp.time = formatDate(item.gmtCreated, 3);
  545. temp.likes = item.postsAttributeInfo.favors || 0;
  546. temp.isLike = item.isLike;
  547. if (item.isRisky === 'NORMAL') {
  548. this.data.replyList.push(temp);
  549. }
  550. });
  551. this.setData({
  552. replyList: this.data.replyList,
  553. total: this.data.replyList.length,
  554. totalPage: res.data.data.totalNo
  555. })
  556. });
  557. },
  558. // 打开回复详情页
  559. goToDetail: function (e) {
  560. let id = e.currentTarget.dataset.id;
  561. // let count = e.currentTarget.dataset.count;
  562. wx.navigateTo({
  563. url: `../../social/replyDetail/replyDetail?id=${id}&productId=${this.data.productId}`
  564. })
  565. },
  566. // 绑定输入框内容
  567. inputValue: function (e) {
  568. this.setData({
  569. inputValue: e.detail.value
  570. });
  571. },
  572. // 发布回复
  573. sendHandler: function () {
  574. console.log(this.data.productId)
  575. if (this.data.inputValue !== '') {
  576. // let uid = wx.getStorageSync('uid');
  577. let data = {
  578. "columnId": this.data.id,
  579. colunmNames: 'what',
  580. // "detailDesc": encodeURI(this.data.inputValue)
  581. "detailDesc": this.data.inputValue,
  582. productId: this.data.productId
  583. }
  584. httpRequestApi.postReply(this.uid, data).success(res => {
  585. console.log(res)
  586. this.setData({
  587. inputValue: '',
  588. pageNo: 1,
  589. replyList: [],
  590. flowerNum: res.data.count
  591. })
  592. this.getReply();
  593. if (res.data.count > 0) {
  594. this.flowerAnimationHandler();
  595. }
  596. });
  597. // 评论成功后刷新数据
  598. }
  599. },
  600. flowerAnimationHandler: function () {
  601. this.flowerBox = this.selectComponent("#flower-box");
  602. this.flowerBox.comeOut();
  603. },
  604. // 触底加载
  605. onReachBottom: function () {
  606. // 当前在推荐页面 加载推荐
  607. if (this.data.pageNo <= this.data.totalPage) {
  608. this.setData({
  609. pageNo: this.data.pageNo + 1
  610. }, () => {
  611. this.getReply();
  612. })
  613. }
  614. },
  615. // 设置点击时的id
  616. setSBId: function (e) {
  617. this.setData({
  618. replySBId: e.currentTarget.dataset.id,
  619. replyModal: true,
  620. replyIndex: e.currentTarget.dataset.index
  621. })
  622. },
  623. // 回复某个评论
  624. replySB: function () {
  625. const data = {
  626. postsId: this.data.replySBId,
  627. content: this.data.inputSBValue,
  628. productId: this.data.productId
  629. }
  630. httpRequestApi.postReplyComment(this.uid, data).success(res => {
  631. const replyWho = this.data.replyList[this.data.replyIndex];
  632. const indexStr = `replyList[${this.data.replyIndex}]`;
  633. replyWho.replyCount++;
  634. this.setData({
  635. replyModal: false,
  636. [indexStr]: replyWho
  637. })
  638. });
  639. },
  640. // 获取回复楼中楼的内容
  641. inputSBValue: function (e) {
  642. this.setData({
  643. inputSBValue: e.detail.value
  644. });
  645. },
  646. // 选择金额
  647. setMoney: function (e) {
  648. this.setData({
  649. howMuch: e.currentTarget.dataset.money
  650. })
  651. },
  652. reward: function () {
  653. if (this.data.isIOS) {
  654. return
  655. };
  656. this.setData({
  657. ifReward: true
  658. })
  659. },
  660. quitReward: function () {
  661. this.setData({
  662. ifReward: false
  663. })
  664. },
  665. // 奖励
  666. rewardMoney: function () {
  667. const data = {
  668. targetUid: this.data.authorUid,
  669. amount: this.data.howMuch
  670. }
  671. // let uid = wx.getStorageSync('uid');
  672. httpRequestApi.rewardMoney(this.uid, data).success(res => {
  673. if (res.data.message) {
  674. wx.showModal({
  675. title: '提示',
  676. content: res.data.message,
  677. success(res) {
  678. if (res.confirm) {
  679. console.log('用户点击确定')
  680. } else if (res.cancel) {
  681. console.log('用户点击取消')
  682. }
  683. }
  684. })
  685. return false;
  686. }
  687. this.payMoney(res.data.data);
  688. })
  689. },
  690. //支付
  691. payMoney: function (orderInfo) {
  692. if (this.data.haveTapMoney) {
  693. return false
  694. }
  695. this.setData({
  696. haveTapMoney: true
  697. })
  698. wx.requestPayment({
  699. 'appId': orderInfo.appId,
  700. 'timeStamp': orderInfo.timeStamp,
  701. 'nonceStr': orderInfo.nonceStr,
  702. 'package': orderInfo.package,
  703. 'signType': orderInfo.signType,
  704. 'paySign': orderInfo.sign,
  705. 'success': res => {
  706. this.setData({
  707. modalType: 'image',
  708. isModalShow: true,
  709. modalCloseShow: false,
  710. modalBtnText: '确定',
  711. haveTapMoney: false,
  712. ifReward: false
  713. })
  714. // wx.showModal({
  715. // title: '提示',
  716. // content: '支付成功',
  717. // success(res) {
  718. // if (res.confirm) {
  719. // this.setData({
  720. // ifReward: false
  721. // })
  722. // } else if (res.cancel) {
  723. // this.setData({
  724. // ifReward: false
  725. // })
  726. // }
  727. // }
  728. // })
  729. },
  730. 'fail': res => {
  731. this.setData({
  732. haveTapMoney: false,
  733. })
  734. console.log('支付失败', res)
  735. }
  736. })
  737. },
  738. // 回到首页
  739. goBackHome: function () {
  740. wx.redirectTo({
  741. url: '../../index/index'
  742. })
  743. },
  744. modalConfirmHandler: function () {
  745. this.setData({
  746. isModalShow: false
  747. })
  748. if (this.data.isIOS) {
  749. // wx.navigateTo({
  750. // url: `../../vipPage/vipCode/vipCode`
  751. // })
  752. wx.navigateTo({
  753. url: `../../vipPage/wechat/wechat`
  754. })
  755. } else {
  756. wx.navigateTo({
  757. url: `../../vipPage/vip/vip`
  758. })
  759. }
  760. },
  761. modalCloseHandler: function () {
  762. this.setData({
  763. isModalShow: false
  764. })
  765. },
  766. jurisdiction: function () {
  767. //隐藏弹框
  768. this.setData({
  769. hide: !this.data.hide
  770. })
  771. //登录页信息
  772. // this.onLoad(this.data.onLoadOption);
  773. this.goToReading();
  774. },
  775. goToClass: function () {
  776. if (!this.data.isIOS && this.videoCtx) {
  777. this.innerAudioContext.stop();
  778. this.innerAudioContext.destroy();
  779. this.videoCtx.stop();
  780. this.setData({
  781. videoLoad: false
  782. })
  783. }
  784. setTimeout(() => {
  785. wx.navigateTo({
  786. url: `../../main/class/class?id=${this.data.classId}`
  787. })
  788. }, 100)
  789. }
  790. })