C端小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

855 lines
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. console.log(e)
  257. let formId = e.detail.formId;
  258. var discount = e.currentTarget.dataset.discount;
  259. that.setData({
  260. queueData: null,
  261. showbutton: true,
  262. formId: formId
  263. })
  264. Http.get({
  265. url: config.api.getQuestion,
  266. data: {
  267. couponType: JSON.stringify(that.data.data.type)
  268. }
  269. })
  270. .then(res => {
  271. console.log(res);
  272. if (res.data == undefined) {
  273. that.orderFunc(discount);
  274. that.setData({
  275. flag: false
  276. })
  277. } else if (res.data) {
  278. var animation = wx.createAnimation({});
  279. animation.translate((that.data.widthScreen - that.data.widthScreen), 0).scale(1).opacity(1).step({
  280. duration: 500
  281. })
  282. that.setData({
  283. queueData: animation.export(),
  284. zIndex: 9,
  285. opacity: 1,
  286. display: "block",
  287. questionnaire: JSON.parse(res.data.content),
  288. questionId: res.data.id
  289. });
  290. }
  291. })
  292. .catch(err => {
  293. wx.showToast({
  294. title: err.message,
  295. icon: 'none',
  296. duration: 2000,
  297. mask: false
  298. });
  299. })
  300. },
  301. setIntervalTime(end_time) {
  302. let that = this;
  303. var EndTime = end_time;
  304. var NowTime = new Date().getTime();
  305. var total_micro_second = EndTime - NowTime || [];
  306. // 渲染倒计时时钟
  307. let obj = that.dateformat(total_micro_second);
  308. if (total_micro_second > 0) {
  309. that.setData({
  310. clock: obj,
  311. day: obj.a1,
  312. hour: obj.b1,
  313. min: obj.c1,
  314. sec: obj.d1,
  315. })
  316. } else {
  317. that.setData({
  318. clock: "00",
  319. day: "00",
  320. hour: "00",
  321. min: "00",
  322. sec: "00",
  323. })
  324. //如果倒计时结束,需要重新查询一下券的状态
  325. // 给getDetail一个标识
  326. that.getDetail(that.data.couponChannelId,'endclock');
  327. }
  328. total_micro_second -= 1000;
  329. },
  330. countdown: function(end_time) {
  331. let that = this;
  332. that.setIntervalTime(end_time);
  333. that.data.setInterval = setInterval(function() {
  334. that.setIntervalTime(end_time);
  335. }, 1000)
  336. },
  337. // 时间格式化输出,如11:03 25:19 每1s都会调用一次
  338. dateformat(micro_second) {
  339. // 总秒数
  340. var second = Math.floor(micro_second / 1000);
  341. // 天数
  342. var day = Math.floor(second / 3600 / 24) < 10 ? "0" + Math.floor(second / 3600 / 24) : Math.floor(second / 3600 / 24);
  343. // 小时
  344. var hr = Math.floor(second / 3600 % 24) < 10 ? "0" + Math.floor(second / 3600 % 24) : Math.floor(second / 3600 % 24);
  345. // 分钟
  346. var min = Math.floor(second / 60 % 60) < 10 ? "0" + Math.floor(second / 60 % 60) : Math.floor(second / 60 % 60);
  347. // 秒
  348. var sec = Math.floor(second % 60) < 10 ? "0" + Math.floor(second % 60) : Math.floor(second % 60);
  349. // return day + "天" + hr + "小时" + min + "分钟" + sec + "秒";
  350. return {
  351. a1: day,
  352. b1: hr,
  353. c1: min,
  354. d1: sec
  355. }
  356. },
  357. /**
  358. * 获取用户信息
  359. */
  360. onLoad(options) {
  361. let that = this;
  362. wx.showLoading({
  363. title: "加载中..."
  364. });
  365. that.setData({
  366. onshow:false
  367. })
  368. that.getDetail(options.couponChannelId,'notendclock');
  369. /**
  370. * 转赠判断
  371. */
  372. if (options.cuserId) {
  373. this.setData({
  374. showCardOffer: true,
  375. cardData: options
  376. })
  377. this.getUserInfo()
  378. }
  379. that.setData({
  380. couponChannelId: options.couponChannelId,
  381. title: that.data.data.title ? that.data.data.title : '',
  382. });
  383. if (options.cardType) {
  384. that.setData({
  385. cardType: options.cardType
  386. })
  387. }
  388. },
  389. getDetail: function (couponChannelId, flag) {
  390. let that = this;
  391. var parmer = {
  392. url: config.api.couponDetail,
  393. data: {
  394. couponChannelId: couponChannelId
  395. }
  396. };
  397. Http.get(parmer)
  398. .then(res => {
  399. that.setData({
  400. couponId: res.data.couponId
  401. })
  402. if (res.code == 200) {
  403. that.setData({
  404. showPage: true
  405. })
  406. }
  407. if (res.data.type == 100) {
  408. wx.setNavigationBarTitle({
  409. title: "卡详情"
  410. })
  411. }
  412. var EndTime = res.data.validStartDate;
  413. var NowTime = new Date().getTime();
  414. console.log(flag);
  415. if (res.data.endTime && res.data.beginTime) {
  416. that.setData({
  417. begin_time: res.data.beginTime,
  418. end_time: res.data.endTime,
  419. })
  420. //activityStatus==0 活动未开始
  421. //activityStatus==1 活动已开始
  422. // flag == endclock 说明倒计时已经结束
  423. if (res.data.activityStatus == 0 && flag != 'endclock') {
  424. that.countdown(res.data.beginTime);
  425. } else if (res.data.activityStatus != 0 && flag != 'endclock'){
  426. that.countdown(res.data.endTime);
  427. }else{
  428. clearInterval(that.data.setInterval)
  429. }
  430. if (res.data.activityStatus == 0) {
  431. var beginTime = util.formatTime(res.data.beginTime, "yyyy-MM-dd hh:mm:ss");
  432. if (util.timechuo(beginTime).indexOf('-') == 0) {
  433. that.setData({
  434. beginTime: "活动已结束",
  435. });
  436. } else {
  437. that.setData({
  438. beginTime: util.timechuo(beginTime)
  439. });
  440. }
  441. } else {
  442. var endTime = util.formatTime(res.data.endTime, "yyyy-MM-dd hh:mm:ss");
  443. if (util.timechuo(endTime).indexOf('-') == 0) {
  444. that.setData({
  445. endtime: "活动已结束",
  446. });
  447. } else {
  448. that.setData({
  449. endtime: util.timechuo(endTime)
  450. });
  451. }
  452. }
  453. }
  454. wx.hideLoading();
  455. that.setData({
  456. data: res.data
  457. });
  458. if (that.data.data.merchantVoList && that.data.data.merchantVoList.length <= 4) {
  459. that.setData({
  460. height: that.data.data.merchantVoList.length * 140 + 'rpx',
  461. showMore: false
  462. })
  463. } else if (that.data.data.merchantVoList && that.data.data.merchantVoList.length > 4) {
  464. that.setData({
  465. height: 4 * 140 + 'rpx'
  466. })
  467. }
  468. if (res.data.validType == 1) {
  469. that.setData({
  470. validStartDate: util.formatTime(res.data.validStartDate, "yyyy-MM-dd"),
  471. validEndDate: util.formatTime(res.data.validEndDate, "yyyy-MM-dd"),
  472. });
  473. } else {
  474. if (res.data.validDays) {
  475. that.setData({
  476. validDays: res.data.validDays
  477. });
  478. }
  479. }
  480. }).catch(err => {
  481. wx.showToast({
  482. title: err.message,
  483. icon: 'none',
  484. duration: 2000,
  485. mask: false
  486. });
  487. })
  488. },
  489. /**
  490. * 邀请好友继续砍价
  491. */
  492. inviteFriend: function() {
  493. let that = this;
  494. that.orderFunc("discount");
  495. that.setData({
  496. showbutton1: true
  497. })
  498. },
  499. /**
  500. * 支付订单更新
  501. */
  502. payOrderUpdate: (orderId, payOrderId, status, reason, type, _this) => {
  503. let that = this;
  504. // 支付成功
  505. Http.post({
  506. url: config.api.payOrderUpdate,
  507. data: {
  508. payOrderId: payOrderId,
  509. orderId: orderId,
  510. status: status,
  511. reason: reason
  512. }
  513. })
  514. .then(res => {
  515. wx.hideLoading()
  516. // 有价券
  517. if (!type && type != 'free') {
  518. wx.navigateTo({
  519. url: `/pages/order/detail/index?orderId=${
  520. orderId
  521. }&cardIf=true`
  522. });
  523. } else if (type == 'free') {
  524. wx.navigateTo({
  525. url: `/pages/order/detail/index?orderId=${
  526. orderId
  527. }`
  528. });
  529. }
  530. })
  531. .catch(err => {
  532. console.log(err);
  533. if (!type) {
  534. setTimeout(function() {
  535. _this.payOrderUpdate(orderId, payOrderId, status, reason, type, _this);
  536. }, 2000)
  537. }
  538. })
  539. },
  540. checkPhoneStatus: function() {
  541. let that = this;
  542. Http.get({
  543. url: config.api.checkPhoneStatus,
  544. data: {}
  545. })
  546. .then(res => {
  547. console.log(666, '授权成功!')
  548. that.receiveCard()
  549. })
  550. .catch(err => {
  551. if (err.code == 11005) {
  552. // 用户手机未授权
  553. /**
  554. * 将值传到用户手机号授权的页面
  555. *
  556. */
  557. wx.redirectTo({
  558. 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,
  559. });
  560. } else if (err.code == 11006) {
  561. // 用户手机已加密
  562. wx.redirectTo({
  563. 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,
  564. });
  565. } else {
  566. wx.showToast({
  567. title: err.message,
  568. icon: 'none',
  569. duration: 2000,
  570. mask: false
  571. });
  572. }
  573. })
  574. },
  575. /**
  576. * 发起支付
  577. */
  578. orderFunc(discount) {
  579. console.log(discount)
  580. var that = this;
  581. Http.get({
  582. url: config.api.checkPhoneStatus,
  583. data: {}
  584. })
  585. .then(res => {
  586. if (discount == 'discount') {
  587. var data = {
  588. couponChannelId: "" + that.data.couponChannelId,
  589. couponId: "" + that.data.couponId,
  590. formId: "" + that.data.formId,
  591. press: true
  592. }
  593. } else if (discount == 'discount1') {
  594. var data = {
  595. couponChannelId: "" + that.data.couponChannelId,
  596. couponId: "" + that.data.couponId,
  597. formId: "" + that.data.formId,
  598. press: false
  599. }
  600. } else if (that.data.couponChannelId == null) {
  601. var data = {
  602. couponId: "" + that.data.couponId,
  603. formId: "" + that.data.formId,
  604. };
  605. } else {
  606. var data = {
  607. couponChannelId: "" + that.data.couponChannelId,
  608. couponId: "" + that.data.couponId,
  609. formId: "" + that.data.formId,
  610. }
  611. }
  612. /**
  613. * orderSave 下单
  614. */
  615. return Http.post({
  616. url: config.api.orderSave,
  617. data: data
  618. });
  619. })
  620. .catch(err => {
  621. console.log(err);
  622. that.setData({
  623. showbutton: false,
  624. showbutton1: false
  625. })
  626. if (err.code == 2011) {
  627. wx.showToast({
  628. title: "商户信息没找到",
  629. image: './../../../assets/images/fail.png',
  630. duration: 2000,
  631. mask: false
  632. });
  633. } else if (err.code == 2013) {
  634. wx.showToast({
  635. title: "商户信息禁用",
  636. image: './../../../assets/images/fail.png',
  637. duration: 2000,
  638. mask: false
  639. });
  640. } else if (err.code == 3000) {
  641. wx.showToast({
  642. title: "库存不足",
  643. image: './../../../assets/images/fail.png',
  644. duration: 2000,
  645. mask: false
  646. });
  647. } else if (err.code == 3001) {
  648. wx.showToast({
  649. title: "超过限购条件",
  650. image: './../../../assets/images/fail.png',
  651. duration: 2000,
  652. mask: false
  653. });
  654. } else if (err.code == 3002) {
  655. wx.showToast({
  656. title: "订单失败",
  657. image: './../../../assets/images/fail.png',
  658. duration: 2000,
  659. mask: false
  660. });
  661. } else if (err.code == 3003) {
  662. wx.showToast({
  663. title: "订单不存在",
  664. image: './../../../assets/images/fail.png',
  665. duration: 2000,
  666. mask: false
  667. });
  668. } else if (err.code == 3004) {
  669. wx.showToast({
  670. title: "订单不存在",
  671. image: './../../../assets/images/fail.png',
  672. duration: 2000,
  673. mask: false
  674. });
  675. } else if (err.code == 4003) {
  676. wx.showToast({
  677. title: "卡券已作废",
  678. image: './../../../assets/images/fail.png',
  679. duration: 2000,
  680. mask: false
  681. });
  682. } else if (err.code == 11005) {
  683. /**
  684. * 将值传到用户手机号授权的页面
  685. *
  686. */
  687. wx.redirectTo({
  688. url: "/pages/getphoneInfo/index?couponChannelId=" +
  689. that.data.couponChannelId
  690. });
  691. } else if (err.code == 11006) {
  692. // 用户手机已加密
  693. wx.redirectTo({
  694. url: "/pages/phoneinput/phoneinput?couponChannelId=" +
  695. that.data.couponChannelId
  696. });
  697. } else {
  698. wx.showToast({
  699. title: err.message,
  700. icon: 'none',
  701. duration: 2000,
  702. mask: false
  703. });
  704. }
  705. })
  706. .then(res => {
  707. console.log(res)
  708. if (discount != 'discount') {
  709. if (typeof(res) != "undefined") {
  710. let orderId = "" + res.data.id;
  711. that.setData({
  712. orderId: orderId
  713. });
  714. if (res.data.payment > 0) {
  715. // 支付金额不为0
  716. /**
  717. * 支付订单创建
  718. */
  719. Http.post({
  720. url: config.api.payOrderCreate,
  721. data: {
  722. orderId: orderId
  723. }
  724. })
  725. .then(res => {
  726. var payOrderId = "" + res.data.payOrderId;
  727. wx.hideLoading();
  728. wx.requestPayment({
  729. timeStamp: res.data.timeStamp,
  730. nonceStr: res.data.nonceStr,
  731. package: res.data.package,
  732. signType: (res.data.signType) ? res.data.signType : "MD5",
  733. paySign: res.data.paySign,
  734. success: res => {
  735. wx.showLoading({
  736. title: '订单正在处理中...',
  737. })
  738. setTimeout(function() {
  739. wx.hideLoading()
  740. }, 5000)
  741. that.payOrderUpdate(that.data.orderId, payOrderId, 1, '', '', that);
  742. if (res.errMsg == "requestPayment:ok") {
  743. setTimeout(function() {
  744. wx.hideLoading();
  745. }, 2000);
  746. /**
  747. * 用户支付成功以后跳转到券包列表
  748. */
  749. if (that.data.cardType == 100) {
  750. wx.setStorage({
  751. key: 'couponNum2',
  752. data: "couponNum2"
  753. })
  754. } else if (that.data.data.type != 5) {
  755. wx.setStorage({
  756. key: 'couponNum',
  757. data: "couponNum"
  758. })
  759. }
  760. }
  761. },
  762. fail: res => {
  763. /**
  764. * 支付失败,需要更新订单的状态
  765. */
  766. that.payOrderUpdate(that.data.orderId, payOrderId, 2, '', 'fail', that);
  767. that.setData({
  768. showbutton: false
  769. })
  770. return;
  771. },
  772. complete: res => {}
  773. });
  774. /// End payment --------
  775. })
  776. .catch(err => {
  777. wx.showToast({
  778. title: err.message,
  779. icon: 'none',
  780. duration: 2000,
  781. mask: false
  782. });
  783. })
  784. } else {
  785. console.log(that.data.type)
  786. // 免费券
  787. that.payOrderUpdate(orderId, "0", 1, '', 'free');
  788. if (that.data.cardType == 100) {
  789. wx.setStorage({
  790. key: 'couponNum2',
  791. data: "couponNum2"
  792. })
  793. } else if (that.data.data.type != "5") {
  794. wx.setStorage({
  795. key: 'couponNum',
  796. data: "couponNum"
  797. })
  798. }
  799. }
  800. }
  801. } else {
  802. if (res) {
  803. wx.navigateTo({
  804. url: `/pages/bargain/bargainDatail/bargainDatail?orderId=${res.data.id}`,
  805. })
  806. }
  807. }
  808. })
  809. },
  810. onShow() {
  811. this.setData({
  812. showbutton: false,
  813. showbutton1:false
  814. })
  815. if(this.data.end_time){
  816. this.countdown(this.data.end_time)
  817. }
  818. },
  819. onUnload:function(){
  820. let that = this;
  821. clearInterval(that.data.setInterval)
  822. },
  823. onHide: function () {
  824. let that = this;
  825. clearInterval(that.data.setInterval)
  826. },
  827. onShareAppMessage: function(options) {
  828. var that = this;
  829. var shareObj = {
  830. title: that.data.data.title,
  831. path: `/pages/index/index?couponChannelId=${that.data.couponChannelId}`,
  832. success: function(res) {
  833. if (res.errMsg == 'shareAppMessage:ok') {}
  834. },
  835. fail: function(error) {
  836. if (res.errMsg == 'shareAppMessage:fail cancel') {} else if (res.errMsg == 'shareAppMessage:fail') {}
  837. }
  838. };
  839. // 来自页面内的按钮的转发
  840. if (options.from == 'button') {
  841. var eData = options.target.dataset.id;
  842. shareObj.path = `/pages/index/index?couponChannelId=${eData}`;
  843. }
  844. // 返回shareObj
  845. return shareObj;
  846. },
  847. // 下拉刷新
  848. onPullDownRefresh: function() {
  849. this.getDetail(this.data.couponChannelId);
  850. wx.stopPullDownRefresh()
  851. }
  852. });