works.js 27 KB

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