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.

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