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