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.

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