C端小程序
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

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