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.

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