C端小程序
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

854 rader
24 KiB

  1. var config = require("../../../config/config.js");
  2. var app = getApp();
  3. const Http = require("../../../utils/HttpBasics");
  4. const util = require("../../../utils/util");
  5. const imgurl = require("../../../utils/imgurl");
  6. Page({
  7. data: {
  8. fenxiangUrl: imgurl.fenxiang.url,
  9. clockUrl: imgurl.clock.url,
  10. teljpgUrl: imgurl.teljpg.url,
  11. closedUrl: imgurl.closed.url,
  12. quesGouUrl: imgurl.ques_gou.url,
  13. headbgUrl: imgurl.headbg.url,
  14. quesBgUrl: imgurl.ques_bg.url,
  15. close02: imgurl.close02.url,
  16. share01: imgurl.share01.url,
  17. fail: imgurl.fail.url,
  18. share01: imgurl.share01.url,
  19. wmhome: imgurl.wmhome.url,
  20. hidden: "hidden",
  21. height: "",
  22. more: "点击查看更多",
  23. showMore: true,
  24. data: {
  25. title: null
  26. },
  27. showPage: false,
  28. questions1: null,
  29. questions2: null,
  30. carList: [],
  31. couponChannelId: null,
  32. orderId: "",
  33. hour: null,
  34. day: null,
  35. month: null,
  36. year: null,
  37. minute: "",
  38. tempFilePaths: null,
  39. userInfo: {},
  40. hasUserInfo: false,
  41. canIUse: wx.canIUse('button.open-type.getUserInfo'),
  42. id: null,
  43. result: [],
  44. end_time: null,
  45. checked: false,
  46. questionnaire: {},
  47. questionId: null,
  48. widthScreen: null,
  49. moveData: null,
  50. rotateData: null,
  51. alphaData: null,
  52. scaleData: null,
  53. skewData: null,
  54. matrixData: null,
  55. opacity: 0,
  56. queueData: null,
  57. zIndex: 11,
  58. display: "none",
  59. showbutton: false,
  60. cardData: null,
  61. showCardOffer: false,
  62. isSamePeople: true,
  63. statusText: '',
  64. isReceived: false,
  65. receivedDisabled: false,
  66. clock: "结束",
  67. day: "00",
  68. hour: "00",
  69. min: "00",
  70. sec: "00",
  71. clock02: "00",
  72. day02: "00",
  73. hour02: "00",
  74. min02: "00",
  75. sec02: "00",
  76. countdown: "",
  77. showbutton1:false
  78. },
  79. phone: function(e) {
  80. let that = this;
  81. wx.makePhoneCall({
  82. phoneNumber: e.target.dataset.merchantlinkphone
  83. });
  84. },
  85. // 点击查看更多
  86. more: function() {
  87. let that = this;
  88. if (that.data.more == '点击查看更多') {
  89. this.setData({
  90. hidden: "",
  91. height: that.data.data.merchantVoList.length * 140 + 'rpx',
  92. more: "点击收起",
  93. showMore: true
  94. })
  95. } else {
  96. this.setData({
  97. hidden: "hidden",
  98. height: 4 * 140 + 'rpx',
  99. more: "点击查看更多",
  100. showMore: true
  101. })
  102. }
  103. },
  104. //获取当前登录用户信息
  105. getUserInfo: function() {
  106. let that = this;
  107. // 获取用户信息
  108. Http.get({
  109. url: config.api.getScore,
  110. data: {}
  111. })
  112. .then(res => {
  113. console.log(res)
  114. that.getQueryCardStatus()
  115. if (that.data.cardData.cuserId != res.data.id) {
  116. console.log(2222, 6666)
  117. that.setData({
  118. isSamePeople: false
  119. })
  120. }
  121. })
  122. },
  123. //获取卡转赠状态
  124. getQueryCardStatus() {
  125. let that = this;
  126. let param = {
  127. id: this.data.cardData.couponOrderId,
  128. cUserId: this.data.cardData.cuserId,
  129. updateDate: util.formatTime(Number(that.data.cardData.updateDate), "yyyy-MM-dd hh:mm:ss")
  130. }
  131. Http.get({
  132. url: config.api.queryCardStatus,
  133. data: param
  134. })
  135. .then(res => {
  136. console.log(res, 333333333333)
  137. })
  138. .catch(err => {
  139. that.setData({
  140. isReceived: true,
  141. statusText: err.message
  142. })
  143. })
  144. },
  145. receiveCard() {
  146. let that = this;
  147. let param = {
  148. id: this.data.cardData.couponOrderId,
  149. cUserId: this.data.cardData.cuserId,
  150. updateDate: util.formatTime(Number(this.data.cardData.updateDate), "yyyy-MM-dd hh:mm:ss")
  151. }
  152. this.setData({
  153. receivedDisabled: true
  154. })
  155. Http.post({
  156. url: config.api.cardAccept,
  157. data: param
  158. })
  159. .then(res => {
  160. wx.showToast({
  161. title: '领取成功!',
  162. icon: 'none',
  163. duration: 2000,
  164. mask: false
  165. });
  166. wx.reLaunch({
  167. url: '/pages/complete/index?couponOrderId=' + this.data.cardData.couponOrderId,
  168. })
  169. })
  170. .catch(err => {
  171. wx.showToast({
  172. title: err.message,
  173. icon: 'none',
  174. duration: 2000,
  175. mask: false
  176. });
  177. that.setData({
  178. receivedDisabled: false
  179. })
  180. })
  181. },
  182. closeAlert() {
  183. this.setData({
  184. showCardOffer: false
  185. })
  186. },
  187. goback: function() {
  188. wx.switchTab({
  189. url: '/pages/main/index',
  190. })
  191. },
  192. /**
  193. * 点击提交问题单选
  194. */
  195. formSubmit: function(e) {
  196. console.log(e);
  197. let that = this;
  198. /**
  199. * 多选
  200. */
  201. if (e.currentTarget.dataset.flags == 'multi') {
  202. if (that.data.anwserId.length == 0) {
  203. var answserIs = null
  204. } else {
  205. var answserIs = that.data.anwserId.join(",");
  206. }
  207. } else if (e.currentTarget.dataset.flags == 'single') {
  208. var answserIs = e.detail.value;
  209. }
  210. console.log(answserIs)
  211. console.log(e.currentTarget.dataset.questionid)
  212. Http.post({
  213. url: config.api.answerQuestion,
  214. data: {
  215. answer: answserIs,
  216. questionId: e.currentTarget.dataset.questionid
  217. }
  218. })
  219. .then(res => {
  220. that.closeQuestion();
  221. })
  222. .catch(err => {
  223. wx.showToast({
  224. title: err.message,
  225. icon: 'none',
  226. duration: 2000,
  227. mask: false
  228. });
  229. })
  230. },
  231. /**
  232. * 多选
  233. */
  234. checkboxChange: function(e) {
  235. console.log(e)
  236. this.setData({
  237. anwserId: e.detail.value
  238. })
  239. },
  240. closeQuestion: function() {
  241. let that = this;
  242. that.setData({
  243. display: "none",
  244. zIndex: 11,
  245. opacity: 0
  246. })
  247. setTimeout(function() {
  248. that.orderFunc();
  249. }, 500)
  250. },
  251. /**
  252. * gotopay
  253. */
  254. gotopay: function(e) {
  255. let that = this;
  256. let formId = e.detail.formId;
  257. var discount = e.currentTarget.dataset.discount;
  258. that.setData({
  259. queueData: null,
  260. showbutton: true,
  261. formId: formId
  262. })
  263. Http.get({
  264. url: config.api.getQuestion,
  265. data: {
  266. couponType: JSON.stringify(that.data.data.type)
  267. }
  268. })
  269. .then(res => {
  270. console.log(res);
  271. if (res.data == undefined) {
  272. that.orderFunc(discount);
  273. that.setData({
  274. flag: false
  275. })
  276. } else if (res.data) {
  277. var animation = wx.createAnimation({});
  278. animation.translate((that.data.widthScreen - that.data.widthScreen), 0).scale(1).opacity(1).step({
  279. duration: 500
  280. })
  281. that.setData({
  282. queueData: animation.export(),
  283. zIndex: 9,
  284. opacity: 1,
  285. display: "block",
  286. questionnaire: JSON.parse(res.data.content),
  287. questionId: res.data.id
  288. });
  289. }
  290. })
  291. .catch(err => {
  292. wx.showToast({
  293. title: err.message,
  294. icon: 'none',
  295. duration: 2000,
  296. mask: false
  297. });
  298. })
  299. },
  300. setIntervalTime(end_time) {
  301. let that = this;
  302. var EndTime = end_time;
  303. var NowTime = new Date().getTime();
  304. var total_micro_second = EndTime - NowTime || [];
  305. // 渲染倒计时时钟
  306. let obj = that.dateformat(total_micro_second);
  307. if (total_micro_second > 0) {
  308. that.setData({
  309. clock: obj,
  310. day: obj.a1,
  311. hour: obj.b1,
  312. min: obj.c1,
  313. sec: obj.d1,
  314. })
  315. } else {
  316. that.setData({
  317. clock: "00",
  318. day: "00",
  319. hour: "00",
  320. min: "00",
  321. sec: "00",
  322. })
  323. //如果倒计时结束,需要重新查询一下券的状态
  324. // 给getDetail一个标识
  325. that.getDetail(that.data.couponChannelId,'endclock');
  326. }
  327. total_micro_second -= 1000;
  328. },
  329. countdown: function(end_time) {
  330. let that = this;
  331. that.setIntervalTime(end_time);
  332. that.data.setInterval = setInterval(function() {
  333. that.setIntervalTime(end_time);
  334. }, 1000)
  335. },
  336. // 时间格式化输出,如11:03 25:19 每1s都会调用一次
  337. dateformat(micro_second) {
  338. // 总秒数
  339. var second = Math.floor(micro_second / 1000);
  340. // 天数
  341. var day = Math.floor(second / 3600 / 24) < 10 ? "0" + Math.floor(second / 3600 / 24) : Math.floor(second / 3600 / 24);
  342. // 小时
  343. var hr = Math.floor(second / 3600 % 24) < 10 ? "0" + Math.floor(second / 3600 % 24) : Math.floor(second / 3600 % 24);
  344. // 分钟
  345. var min = Math.floor(second / 60 % 60) < 10 ? "0" + Math.floor(second / 60 % 60) : Math.floor(second / 60 % 60);
  346. // 秒
  347. var sec = Math.floor(second % 60) < 10 ? "0" + Math.floor(second % 60) : Math.floor(second % 60);
  348. // return day + "天" + hr + "小时" + min + "分钟" + sec + "秒";
  349. return {
  350. a1: day,
  351. b1: hr,
  352. c1: min,
  353. d1: sec
  354. }
  355. },
  356. /**
  357. * 获取用户信息
  358. */
  359. onLoad(options) {
  360. let that = this;
  361. wx.showLoading({
  362. title: "加载中..."
  363. });
  364. that.setData({
  365. onshow:false
  366. })
  367. that.getDetail(options.couponChannelId,'notendclock');
  368. /**
  369. * 转赠判断
  370. */
  371. if (options.cuserId) {
  372. this.setData({
  373. showCardOffer: true,
  374. cardData: options
  375. })
  376. this.getUserInfo()
  377. }
  378. that.setData({
  379. couponChannelId: options.couponChannelId,
  380. title: that.data.data.title ? that.data.data.title : '',
  381. });
  382. if (options.cardType) {
  383. that.setData({
  384. cardType: options.cardType
  385. })
  386. }
  387. },
  388. getDetail: function (couponChannelId, flag) {
  389. let that = this;
  390. var parmer = {
  391. url: config.api.couponDetail,
  392. data: {
  393. couponChannelId: couponChannelId
  394. }
  395. };
  396. Http.get(parmer)
  397. .then(res => {
  398. that.setData({
  399. couponId: res.data.couponId
  400. })
  401. if (res.code == 200) {
  402. that.setData({
  403. showPage: true
  404. })
  405. }
  406. if (res.data.type == 100) {
  407. wx.setNavigationBarTitle({
  408. title: "卡详情"
  409. })
  410. }
  411. var EndTime = res.data.validStartDate;
  412. var NowTime = new Date().getTime();
  413. console.log(flag);
  414. if (res.data.endTime && res.data.beginTime) {
  415. that.setData({
  416. begin_time: res.data.beginTime,
  417. end_time: res.data.endTime,
  418. })
  419. //activityStatus==0 活动未开始
  420. //activityStatus==1 活动已开始
  421. // flag == endclock 说明倒计时已经结束
  422. if (res.data.activityStatus == 0 && flag != 'endclock') {
  423. that.countdown(res.data.beginTime);
  424. } else if (res.data.activityStatus != 0 && flag != 'endclock'){
  425. that.countdown(res.data.endTime);
  426. }else{
  427. clearInterval(that.data.setInterval)
  428. }
  429. if (res.data.activityStatus == 0) {
  430. var beginTime = util.formatTime(res.data.beginTime, "yyyy-MM-dd hh:mm:ss");
  431. if (util.timechuo(beginTime).indexOf('-') == 0) {
  432. that.setData({
  433. beginTime: "活动已结束",
  434. });
  435. } else {
  436. that.setData({
  437. beginTime: util.timechuo(beginTime)
  438. });
  439. }
  440. } else {
  441. var endTime = util.formatTime(res.data.endTime, "yyyy-MM-dd hh:mm:ss");
  442. if (util.timechuo(endTime).indexOf('-') == 0) {
  443. that.setData({
  444. endtime: "活动已结束",
  445. });
  446. } else {
  447. that.setData({
  448. endtime: util.timechuo(endTime)
  449. });
  450. }
  451. }
  452. }
  453. wx.hideLoading();
  454. that.setData({
  455. data: res.data
  456. });
  457. if (that.data.data.merchantVoList && that.data.data.merchantVoList.length <= 4) {
  458. that.setData({
  459. height: that.data.data.merchantVoList.length * 140 + 'rpx',
  460. showMore: false
  461. })
  462. } else if (that.data.data.merchantVoList && that.data.data.merchantVoList.length > 4) {
  463. that.setData({
  464. height: 4 * 140 + 'rpx'
  465. })
  466. }
  467. if (res.data.validType == 1) {
  468. that.setData({
  469. validStartDate: util.formatTime(res.data.validStartDate, "yyyy-MM-dd"),
  470. validEndDate: util.formatTime(res.data.validEndDate, "yyyy-MM-dd"),
  471. });
  472. } else {
  473. if (res.data.validDays) {
  474. that.setData({
  475. validDays: res.data.validDays
  476. });
  477. }
  478. }
  479. }).catch(err => {
  480. wx.showToast({
  481. title: err.message,
  482. icon: 'none',
  483. duration: 2000,
  484. mask: false
  485. });
  486. })
  487. },
  488. /**
  489. * 邀请好友继续砍价
  490. */
  491. inviteFriend: function() {
  492. let that = this;
  493. that.orderFunc("discount");
  494. that.setData({
  495. showbutton1: true
  496. })
  497. },
  498. /**
  499. * 支付订单更新
  500. */
  501. payOrderUpdate: (orderId, payOrderId, status, reason, type, _this) => {
  502. let that = this;
  503. // 支付成功
  504. Http.post({
  505. url: config.api.payOrderUpdate,
  506. data: {
  507. payOrderId: payOrderId,
  508. orderId: orderId,
  509. status: status,
  510. reason: reason
  511. }
  512. })
  513. .then(res => {
  514. wx.hideLoading()
  515. // 有价券
  516. if (!type && type != 'free') {
  517. wx.navigateTo({
  518. url: `/pages/order/detail/index?orderId=${
  519. orderId
  520. }&cardIf=true`
  521. });
  522. } else if (type == 'free') {
  523. wx.navigateTo({
  524. url: `/pages/order/detail/index?orderId=${
  525. orderId
  526. }`
  527. });
  528. }
  529. })
  530. .catch(err => {
  531. console.log(err);
  532. if (!type) {
  533. setTimeout(function() {
  534. _this.payOrderUpdate(orderId, payOrderId, status, reason, type, _this);
  535. }, 2000)
  536. }
  537. })
  538. },
  539. checkPhoneStatus: function() {
  540. let that = this;
  541. Http.get({
  542. url: config.api.checkPhoneStatus,
  543. data: {}
  544. })
  545. .then(res => {
  546. console.log(666, '授权成功!')
  547. that.receiveCard()
  548. })
  549. .catch(err => {
  550. if (err.code == 11005) {
  551. // 用户手机未授权
  552. /**
  553. * 将值传到用户手机号授权的页面
  554. *
  555. */
  556. wx.redirectTo({
  557. url: "/pages/getphoneInfo/index?path=index&cuserId=" + that.data.cardData.cuserId + "&couponChannelId=" + that.data.cardData.couponChannelId + "&userName=" + that.data.cardData.userName + "&coverImg=" + that.data.cardData.coverImg + "&avatarUrl=" + that.data.cardData.avatarUrl + "&couponOrderId=" + that.data.cardData.couponOrderId + "&updateDate=" + that.data.cardData.updateDate,
  558. });
  559. } else if (err.code == 11006) {
  560. // 用户手机已加密
  561. wx.redirectTo({
  562. url: "/pages/phoneinput/phoneinput?path=index&cuserId=" + that.data.cardData.cuserId + "&couponChannelId=" + that.data.cardData.couponChannelId + "&userName=" + that.data.cardData.userName + "&coverImg=" + that.data.cardData.coverImg + "&avatarUrl=" + that.data.cardData.avatarUrl + "&couponOrderId=" + that.data.cardData.couponOrderId + "&updateDate=" + that.data.cardData.updateDate,
  563. });
  564. } else {
  565. wx.showToast({
  566. title: err.message,
  567. icon: 'none',
  568. duration: 2000,
  569. mask: false
  570. });
  571. }
  572. })
  573. },
  574. /**
  575. * 发起支付
  576. */
  577. orderFunc(discount) {
  578. console.log(discount)
  579. var that = this;
  580. Http.get({
  581. url: config.api.checkPhoneStatus,
  582. data: {}
  583. })
  584. .then(res => {
  585. if (discount == 'discount') {
  586. var data = {
  587. couponChannelId: "" + that.data.couponChannelId,
  588. couponId: "" + that.data.couponId,
  589. formId: "" + that.data.formId,
  590. press: true
  591. }
  592. } else if (discount == 'discount1') {
  593. var data = {
  594. couponChannelId: "" + that.data.couponChannelId,
  595. couponId: "" + that.data.couponId,
  596. formId: "" + that.data.formId,
  597. press: false
  598. }
  599. } else if (that.data.couponChannelId == null) {
  600. var data = {
  601. couponId: "" + that.data.couponId,
  602. formId: "" + that.data.formId,
  603. };
  604. } else {
  605. var data = {
  606. couponChannelId: "" + that.data.couponChannelId,
  607. couponId: "" + that.data.couponId,
  608. formId: "" + that.data.formId,
  609. }
  610. }
  611. /**
  612. * orderSave 下单
  613. */
  614. return Http.post({
  615. url: config.api.orderSave,
  616. data: data
  617. });
  618. })
  619. .catch(err => {
  620. console.log(err);
  621. that.setData({
  622. showbutton: false,
  623. showbutton1: false
  624. })
  625. if (err.code == 2011) {
  626. wx.showToast({
  627. title: "商户信息没找到",
  628. image: './../../../assets/images/fail.png',
  629. duration: 2000,
  630. mask: false
  631. });
  632. } else if (err.code == 2013) {
  633. wx.showToast({
  634. title: "商户信息禁用",
  635. image: './../../../assets/images/fail.png',
  636. duration: 2000,
  637. mask: false
  638. });
  639. } else if (err.code == 3000) {
  640. wx.showToast({
  641. title: "库存不足",
  642. image: './../../../assets/images/fail.png',
  643. duration: 2000,
  644. mask: false
  645. });
  646. } else if (err.code == 3001) {
  647. wx.showToast({
  648. title: "超过限购条件",
  649. image: './../../../assets/images/fail.png',
  650. duration: 2000,
  651. mask: false
  652. });
  653. } else if (err.code == 3002) {
  654. wx.showToast({
  655. title: "订单失败",
  656. image: './../../../assets/images/fail.png',
  657. duration: 2000,
  658. mask: false
  659. });
  660. } else if (err.code == 3003) {
  661. wx.showToast({
  662. title: "订单不存在",
  663. image: './../../../assets/images/fail.png',
  664. duration: 2000,
  665. mask: false
  666. });
  667. } else if (err.code == 3004) {
  668. wx.showToast({
  669. title: "订单不存在",
  670. image: './../../../assets/images/fail.png',
  671. duration: 2000,
  672. mask: false
  673. });
  674. } else if (err.code == 4003) {
  675. wx.showToast({
  676. title: "卡券已作废",
  677. image: './../../../assets/images/fail.png',
  678. duration: 2000,
  679. mask: false
  680. });
  681. } else if (err.code == 11005) {
  682. /**
  683. * 将值传到用户手机号授权的页面
  684. *
  685. */
  686. wx.redirectTo({
  687. url: "/pages/getphoneInfo/index?couponChannelId=" +
  688. that.data.couponChannelId
  689. });
  690. } else if (err.code == 11006) {
  691. // 用户手机已加密
  692. wx.redirectTo({
  693. url: "/pages/phoneinput/phoneinput?couponChannelId=" +
  694. that.data.couponChannelId
  695. });
  696. } else {
  697. wx.showToast({
  698. title: err.message,
  699. icon: 'none',
  700. duration: 2000,
  701. mask: false
  702. });
  703. }
  704. })
  705. .then(res => {
  706. console.log(res)
  707. if (discount != 'discount') {
  708. if (typeof(res) != "undefined") {
  709. let orderId = "" + res.data.id;
  710. that.setData({
  711. orderId: orderId
  712. });
  713. if (res.data.payment > 0) {
  714. // 支付金额不为0
  715. /**
  716. * 支付订单创建
  717. */
  718. Http.post({
  719. url: config.api.payOrderCreate,
  720. data: {
  721. orderId: orderId
  722. }
  723. })
  724. .then(res => {
  725. var payOrderId = "" + res.data.payOrderId;
  726. wx.hideLoading();
  727. wx.requestPayment({
  728. timeStamp: res.data.timeStamp,
  729. nonceStr: res.data.nonceStr,
  730. package: res.data.package,
  731. signType: (res.data.signType) ? res.data.signType : "MD5",
  732. paySign: res.data.paySign,
  733. success: res => {
  734. wx.showLoading({
  735. title: '订单正在处理中...',
  736. })
  737. setTimeout(function() {
  738. wx.hideLoading()
  739. }, 5000)
  740. that.payOrderUpdate(that.data.orderId, payOrderId, 1, '', '', that);
  741. if (res.errMsg == "requestPayment:ok") {
  742. setTimeout(function() {
  743. wx.hideLoading();
  744. }, 2000);
  745. /**
  746. * 用户支付成功以后跳转到券包列表
  747. */
  748. if (that.data.cardType == 100) {
  749. wx.setStorage({
  750. key: 'couponNum2',
  751. data: "couponNum2"
  752. })
  753. } else if (that.data.data.type != 5) {
  754. wx.setStorage({
  755. key: 'couponNum',
  756. data: "couponNum"
  757. })
  758. }
  759. }
  760. },
  761. fail: res => {
  762. /**
  763. * 支付失败,需要更新订单的状态
  764. */
  765. that.payOrderUpdate(that.data.orderId, payOrderId, 2, '', 'fail', that);
  766. that.setData({
  767. showbutton: false
  768. })
  769. return;
  770. },
  771. complete: res => {}
  772. });
  773. /// End payment --------
  774. })
  775. .catch(err => {
  776. wx.showToast({
  777. title: err.message,
  778. icon: 'none',
  779. duration: 2000,
  780. mask: false
  781. });
  782. })
  783. } else {
  784. console.log(that.data.type)
  785. // 免费券
  786. that.payOrderUpdate(orderId, "0", 1, '', 'free');
  787. if (that.data.cardType == 100) {
  788. wx.setStorage({
  789. key: 'couponNum2',
  790. data: "couponNum2"
  791. })
  792. } else if (that.data.data.type != "5") {
  793. wx.setStorage({
  794. key: 'couponNum',
  795. data: "couponNum"
  796. })
  797. }
  798. }
  799. }
  800. } else {
  801. if (res) {
  802. wx.navigateTo({
  803. url: `/pages/bargain/bargainDatail/bargainDatail?orderId=${res.data.id}`,
  804. })
  805. }
  806. }
  807. })
  808. },
  809. onShow() {
  810. this.setData({
  811. showbutton: false,
  812. showbutton1:false
  813. })
  814. if(this.data.end_time){
  815. this.countdown(this.data.end_time)
  816. }
  817. },
  818. onUnload:function(){
  819. let that = this;
  820. clearInterval(that.data.setInterval)
  821. },
  822. onHide: function () {
  823. let that = this;
  824. clearInterval(that.data.setInterval)
  825. },
  826. onShareAppMessage: function(options) {
  827. var that = this;
  828. var shareObj = {
  829. title: that.data.data.title,
  830. path: `/pages/index/index?couponChannelId=${that.data.couponChannelId}`,
  831. success: function(res) {
  832. if (res.errMsg == 'shareAppMessage:ok') {}
  833. },
  834. fail: function(error) {
  835. if (res.errMsg == 'shareAppMessage:fail cancel') {} else if (res.errMsg == 'shareAppMessage:fail') {}
  836. }
  837. };
  838. // 来自页面内的按钮的转发
  839. if (options.from == 'button') {
  840. var eData = options.target.dataset.id;
  841. shareObj.path = `/pages/index/index?couponChannelId=${eData}`;
  842. }
  843. // 返回shareObj
  844. return shareObj;
  845. },
  846. // 下拉刷新
  847. onPullDownRefresh: function() {
  848. this.getDetail(this.data.couponChannelId);
  849. wx.stopPullDownRefresh()
  850. }
  851. });