C端小程序
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

859 Zeilen
23 KiB

  1. // pages/spellGroup/mySpellGroup/index.js
  2. const navigationBarHeight = (getApp().statusBarHeight + 50) + 'px'
  3. var config = require("../../../config/config.js");
  4. const Http = require("../../../utils/HttpBasics");
  5. const imgurl = require("../../../utils/imgurl");
  6. const utils = require("../../../utils/util.js");
  7. let app = getApp();
  8. Page({
  9. /**
  10. * 页面的初始数据
  11. */
  12. data: {
  13. mouldType: 0,
  14. mouldConfig: {},
  15. navigationBarHeight,
  16. fenxiang: imgurl.fenxiang1.url,
  17. homeSelectedO: imgurl.homeSelectedO.url,
  18. isshowposter: false, //是否显示分享弹框
  19. teljpgUrl: imgurl.teljpg.url,
  20. wmhome: imgurl.wmhome.url,
  21. share01: imgurl.share01.url,
  22. close02: imgurl.close02.url,
  23. closedUrl: imgurl.closed.url,
  24. quesGouUrl: imgurl.ques_gou.url,
  25. headbgUrl: imgurl.headbg.url,
  26. quesBgUrl: imgurl.ques_bg.url,
  27. couponChannelId: '',
  28. couponId: '',
  29. data: null,
  30. spellData: null,
  31. canSpell: true,
  32. canBuyIf: true,
  33. clock: "00",
  34. day: "00",
  35. hour: "00",
  36. min: "00",
  37. sec: "00",
  38. detailPicture: [],
  39. coverPicture: [],
  40. swiperCurrent: 0,
  41. showTime: true,
  42. limitCondition: "",
  43. minLimit: 0,
  44. maxLimit: 0,
  45. spellGroupOrder: false,
  46. opacity: 0,
  47. queueData: null,
  48. zIndex: 11,
  49. display: "none",
  50. orderGroupId: '',
  51. merchantVoList: [],
  52. goHomeUrl: "",
  53. mallList: ''
  54. },
  55. /**
  56. * 生命周期函数--监听页面加载
  57. */
  58. onLoad: function (options) {
  59. this.setData({
  60. mouldType: app.globalData.mouldType,
  61. mouldConfig: app.globalData.mouldConfig,
  62. goHomeUrl: app.globalData.goHomeUrl,
  63. })
  64. Http.get({
  65. url: config.api.checkUserStatus,
  66. data: {
  67. token: app.globalData.token
  68. }
  69. }).then(res => {
  70. Http.get({
  71. url: config.api.checkPhoneStatus,
  72. data: {}
  73. }).then(res => {
  74. this.setData({
  75. couponChannelId: options.couponChannelId,
  76. couponId: options.couponId ? options.couponId : ''
  77. })
  78. if (options && options.couponChannelId) {
  79. this.getDetail(options.couponChannelId);
  80. }
  81. if (options && options.couponId) {
  82. this.getOneSpell(options.couponId)
  83. }
  84. }).catch(res => {
  85. wx.redirectTo({
  86. url: `/pages/getphoneInfo/index`
  87. });
  88. })
  89. }).catch(res => {
  90. wx.redirectTo({
  91. url: `/pages/getuserinfo/index`
  92. })
  93. })
  94. },
  95. /**
  96. * 显示分享海报
  97. */
  98. /* showPoster: function() {
  99. //跳转到海报生成页
  100. wx.navigateTo({
  101. url: `/pages/canvas/index?couponChannelId=${this.data.data.id}`
  102. })
  103. }, */
  104. showPoster: function () {
  105. console.log(this.data.data)
  106. let that = this;
  107. Http.get({
  108. url: config.api.checkUserStatus,
  109. data: {
  110. token: app.globalData.token
  111. }
  112. }).then(res => {
  113. wx.navigateTo({
  114. url: `/pages/canvas/index?couponChannelId=${that.data.data.id}`
  115. })
  116. }).catch(err => {
  117. console.log(err)
  118. if (err.code == 11004) {
  119. // 用户昵称未授权
  120. wx.redirectTo({
  121. url: `/pages/getuserinfo/index?couponChannelId=${that.data.data.id}&fromflag=poster`
  122. })
  123. }
  124. })
  125. //跳转到海报生成页
  126. },
  127. /**
  128. * 显示分享弹框
  129. */
  130. showshare: function () {
  131. this.setData({
  132. isshowposter: true,
  133. })
  134. },
  135. /**
  136. * 隐藏分享弹框
  137. */
  138. hidemodal: function () {
  139. this.setData({
  140. isshowposter: false,
  141. })
  142. },
  143. gotoIndex: function () {
  144. let this_ = this
  145. wx.switchTab({
  146. url: this_.data.goHomeUrl,
  147. })
  148. },
  149. /**
  150. * 拨打电话
  151. */
  152. phone: function (e) {
  153. let that = this;
  154. wx.makePhoneCall({
  155. phoneNumber: e.target.dataset.merchantlinkphone
  156. });
  157. },
  158. /**
  159. * 直接购买
  160. */
  161. gotoBuy(e) {
  162. let that = this;
  163. this.setData({
  164. canBuyIf: false,
  165. formId: e.detail.formId,
  166. queueData: null,
  167. orderGroupId: ''
  168. })
  169. that.getQuestions();
  170. },
  171. getQuestions(type) {
  172. let that = this;
  173. Http.get({
  174. url: config.api.getQuestion,
  175. data: {
  176. couponType: JSON.stringify(that.data.data.type)
  177. }
  178. })
  179. .then(res => {
  180. wx.hideLoading();
  181. if (res.data == undefined) {
  182. // 立即购买
  183. that.orderFunc(type);
  184. } else if (res.data) {
  185. var animation = wx.createAnimation({});
  186. animation.translate((that.data.widthScreen - that.data.widthScreen), 0).scale(1).opacity(1).step({
  187. duration: 500
  188. })
  189. that.setData({
  190. queueData: animation.export(),
  191. zIndex: 9,
  192. opacity: 1,
  193. display: "block",
  194. questionnaire: JSON.parse(res.data.content),
  195. questionId: res.data.id
  196. });
  197. }
  198. })
  199. .catch(err => {
  200. wx.hideLoading();
  201. wx.showToast({
  202. title: err.message,
  203. icon: 'none',
  204. duration: 2000,
  205. mask: false
  206. });
  207. })
  208. },
  209. /**
  210. * 点击提交问题单选
  211. */
  212. formSubmit: function (e) {
  213. console.log(e);
  214. let that = this;
  215. /**
  216. * 多选
  217. */
  218. if (e.currentTarget.dataset.flags == 'multi') {
  219. if (that.data.anwserId.length == 0) {
  220. var answserIs = null
  221. } else {
  222. var answserIs = that.data.anwserId.join(",");
  223. }
  224. } else if (e.currentTarget.dataset.flags == 'single') {
  225. var answserIs = e.detail.value;
  226. }
  227. console.log(answserIs)
  228. console.log(e.currentTarget.dataset.questionid)
  229. Http.post({
  230. url: config.api.answerQuestion,
  231. data: {
  232. answer: answserIs,
  233. questionId: e.currentTarget.dataset.questionid
  234. }
  235. })
  236. .then(res => {
  237. that.closeQuestion();
  238. })
  239. .catch(err => {
  240. wx.showToast({
  241. title: err.message,
  242. icon: 'none',
  243. duration: 2000,
  244. mask: false
  245. });
  246. })
  247. },
  248. /**
  249. * 多选
  250. */
  251. checkboxChange: function (e) {
  252. console.log(e)
  253. this.setData({
  254. anwserId: e.detail.value
  255. })
  256. },
  257. closeQuestion: function () {
  258. let that = this;
  259. that.setData({
  260. display: "none",
  261. zIndex: 11,
  262. opacity: 0
  263. })
  264. setTimeout(function () {
  265. that.orderFunc();
  266. }, 500)
  267. },
  268. // 时间格式化输出,如11:03 25:19 每1s都会调用一次
  269. dateformat(micro_second) {
  270. // 总秒数
  271. var second = Math.floor(micro_second / 1000);
  272. // 天数
  273. var day = Math.floor(second / 3600 / 24) < 10 ? "0" + Math.floor(second / 3600 / 24) : Math.floor(second / 3600 / 24);
  274. // 小时
  275. var hr = Math.floor(second / 3600 % 24) < 10 ? "0" + Math.floor(second / 3600 % 24) : Math.floor(second / 3600 % 24);
  276. // 分钟
  277. var min = Math.floor(second / 60 % 60) < 10 ? "0" + Math.floor(second / 60 % 60) : Math.floor(second / 60 % 60);
  278. // 秒
  279. var sec = Math.floor(second % 60) < 10 ? "0" + Math.floor(second % 60) : Math.floor(second % 60);
  280. // return day + "天" + hr + "小时" + min + "分钟" + sec + "秒";
  281. return {
  282. a1: day,
  283. b1: hr,
  284. c1: min,
  285. d1: sec
  286. }
  287. },
  288. countdown(time) {
  289. let that = this;
  290. var EndTime = time;
  291. if (that.data.spellData != null) {
  292. EndTime = that.data.spellData.expiredDate;
  293. }
  294. var NowTime = new Date().getTime();
  295. var total_micro_second = EndTime - NowTime || [];
  296. // 渲染倒计时时钟
  297. let obj = that.dateformat(total_micro_second);
  298. if (total_micro_second > 0) {
  299. that.setData({
  300. clock: obj,
  301. day: obj.a1,
  302. hour: obj.b1,
  303. min: obj.c1,
  304. sec: obj.d1,
  305. })
  306. } else {
  307. that.setData({
  308. clock: "00",
  309. day: "00",
  310. hour: "00",
  311. min: "00",
  312. sec: "00",
  313. })
  314. }
  315. if (that.data.showTime) {
  316. setTimeout(function () {
  317. total_micro_second -= 1000;
  318. that.countdown();
  319. }, 1000)
  320. }
  321. },
  322. // 获得未支付的订单
  323. getUnPaidOrder(couponId) {
  324. let that = this;
  325. Http.get({
  326. url: config.api.getUnPaidOrder,
  327. data: {
  328. couponId: couponId
  329. }
  330. }).then(res => {
  331. that.setData({
  332. disOrderNumber: res.data.orderNumber,
  333. couponChannelId: res.data.couponChannelId,
  334. orderGroupId: res.data.orderGroupId,
  335. composeOrderType: res.data.composeOrderType
  336. })
  337. // 拼团订单
  338. if (res.data.payment / 100 != Number(that.data.data.price)) {
  339. that.setData({
  340. spellGroupOrder: true
  341. })
  342. } else {
  343. // 原价购买订单
  344. that.setData({
  345. spellGroupOrder: false
  346. })
  347. }
  348. if (that.data.spellGroupOrder) {
  349. wx.showModal({
  350. title: '提示',
  351. content: "您有未支付拼团订单,请先进行支付",
  352. confirmText: "去支付",
  353. success: function (res1) {
  354. if (res1.confirm) {
  355. wx.navigateTo({
  356. url: `/pages/spellGroup/paySpellGroup/index?orderId=${res.data.composeOrderId}&couponChannelId=${that.data.couponChannelId}&couponId=${couponId}&orderGroupId={that.data.orderGroupId}&composeOrderType=${that.data.composeOrderType}`,
  357. })
  358. }
  359. }
  360. })
  361. } else {
  362. wx.showModal({
  363. title: '提示',
  364. content: '您有未支付订单,请先进行支付',
  365. confirmText: "去支付",
  366. success: function (res1) {
  367. if (res1.confirm) {
  368. wx.navigateTo({
  369. url: `/pages/order/detail/index?orderId=${res.data.composeOrderId}&composeOrderType=${that.data.composeOrderType}`,
  370. })
  371. }
  372. }
  373. })
  374. }
  375. }).catch(error => {
  376. console.log(error)
  377. wx.showToast({
  378. title: error.message,
  379. icon: "none",
  380. duration: 3000
  381. })
  382. })
  383. },
  384. /**
  385. * 发起拼团
  386. */
  387. gotoSpell(e) {
  388. app.globalData.previewFlag = false
  389. let that = this;
  390. that.setData({
  391. canSpell: false,
  392. formId: e.detail.formId,
  393. orderGroupId: 0
  394. })
  395. that.getQuestions(0);
  396. },
  397. //参与别人的拼团
  398. gotoPartner() {
  399. console.log(this.data.spellData.nickName, 'nickname');
  400. wx.navigateTo({
  401. url: `/pages/joinFrDpell/index?orderId=${this.data.spellData.orderId}&couponId=${this.data.spellData.couponId}&orderGroupId=${this.data.spellData.orderGroupId}&nickName=${this.data.spellData.nickName}&couponChannelId=${this.data.couponChannelId}&avatarUrl=${this.data.spellData.avatarUrl}`
  402. });
  403. },
  404. /**
  405. * 获取一个拼团信息
  406. */
  407. getOneSpell(couponId) {
  408. let that = this;
  409. Http.get({
  410. url: config.api.queryRemainOne,
  411. data: {
  412. couponId: couponId
  413. }
  414. }).then(res => {
  415. wx.stopPullDownRefresh();
  416. if (res.data) {
  417. that.countdown(res.data.expiredDate);
  418. that.setData({
  419. spellData: res.data
  420. });
  421. }
  422. });
  423. },
  424. /**
  425. * 获取券详情信息
  426. */
  427. getDetail(couponChannelId) {
  428. let that = this;
  429. Http.get({
  430. url: config.api.couponDetail,
  431. data: {
  432. couponChannelId: couponChannelId
  433. }
  434. }).then(res => {
  435. wx.stopPullDownRefresh();
  436. let data = res.data;
  437. if (res && res.data && res.data.detailPicture) {
  438. that.setData({
  439. detailPicture: JSON.parse(res.data.detailPicture)
  440. })
  441. }
  442. if (res && res.data && res.data.coverPicture) {
  443. that.setData({
  444. coverPicture: JSON.parse(res.data.coverPicture)
  445. })
  446. }
  447. if (res && res.data && res.data.conditions) {
  448. that.setData({
  449. limitCondition: JSON.parse(res.data.conditions).type
  450. })
  451. if (JSON.parse(res.data.conditions).type == 2 && (JSON.parse(res.data.conditions).min || JSON.parse(res.data.conditions).min == 0)) {
  452. that.setData({
  453. minLimit: JSON.parse(res.data.conditions).min
  454. })
  455. }
  456. if (JSON.parse(res.data.conditions).type == 2 && (JSON.parse(res.data.conditions).max) || JSON.parse(res.data.conditions).max == 0) {
  457. that.setData({
  458. maxLimit: JSON.parse(res.data.conditions).max
  459. })
  460. }
  461. }
  462. data.price = (data.price / 100).toFixed(2)
  463. data.salePrice = (data.salePrice / 100).toFixed(2);
  464. data.validStartDate = utils.formatTime(data.validStartDate, 'yyyy-MM-dd')
  465. data.validEndDate = utils.formatTime(data.validEndDate, 'yyyy-MM-dd')
  466. that.setData({
  467. data,
  468. // merchantVoList: data.merchantVoList
  469. });
  470. Http.get({
  471. url: config.api.couponMerchant,
  472. data: {
  473. couponChannelId: couponChannelId
  474. }
  475. }).then(res => {
  476. const keys = Object.keys(res.data)
  477. const mallList = []
  478. keys.forEach(item => {
  479. const arr = item.split('|')
  480. const obj = {
  481. tenantId: arr[0],
  482. mallName: arr[1],
  483. merchantVoList: res.data[item],
  484. expand: true
  485. }
  486. mallList.push(obj)
  487. })
  488. this.setData({
  489. mallList: mallList
  490. })
  491. console.log(this.data.mallList, 'mallList');
  492. })
  493. });
  494. },
  495. /**
  496. * 去拼团
  497. */
  498. goToOrderGroup(orderId, orderGroupId, _this) {
  499. let that = this;
  500. // 支付成功
  501. Http.post({
  502. url: config.api.toOrderGroup,
  503. data: {
  504. id: orderGroupId,
  505. orderId,
  506. couponId: _this.data.data.couponId
  507. }
  508. })
  509. .then(res => {
  510. wx.navigateTo({
  511. url: `/pages/spellDetail/index?orderId=${orderId}&couponId=${_this.data.data.couponId}&orderGroupId=${res.data.orderGroupId}&couponChannelId=${_this.data.couponChannelId}`
  512. });
  513. })
  514. .catch(err => {
  515. console.log(err);
  516. })
  517. },
  518. /**
  519. * 支付订单更新
  520. */
  521. payOrderUpdate: (orderId, payOrderId, status, reason, _this, orderGroupId) => {
  522. console.log(orderGroupId, 7777)
  523. let that = this;
  524. // 支付成功
  525. Http.post({
  526. url: config.api.payOrderUpdate,
  527. data: {
  528. payOrderId: payOrderId,
  529. composeOrderId: orderId,
  530. status: status,
  531. reason: reason
  532. }
  533. })
  534. .then(res => {
  535. wx.hideLoading()
  536. if (orderGroupId !== 0) {
  537. wx.navigateTo({
  538. url: '/pages/order/detail/index?orderId=' + res.data.mainOrderId,
  539. })
  540. } else {
  541. _this.goToOrderGroup(res.data.singleOrder.id, res.data.mainOrderId, _this)
  542. }
  543. })
  544. .catch(err => {
  545. if (err.code != 12002) {
  546. setTimeout(function () {
  547. _this.payOrderUpdate(orderId, payOrderId, status, reason, _this, orderGroupId);
  548. }, 2000)
  549. }
  550. })
  551. },
  552. /**
  553. * 发起支付
  554. */
  555. orderFunc() {
  556. let that = this;
  557. let orderGroupId = this.data.orderGroupId;
  558. let data = {
  559. couponChannelId: this.data.data.id,
  560. couponId: this.data.data.couponId,
  561. formId: this.data.formId
  562. }
  563. /**
  564. * 拼团订单
  565. */
  566. if (this.data.orderGroupId == 0) {
  567. data.orderGroupId = this.data.orderGroupId,
  568. that.setData({
  569. isFromSpell: true
  570. })
  571. } else {
  572. that.setData({
  573. isFromSpell: false
  574. })
  575. }
  576. Http.get({
  577. url: config.api.checkUserStatus,
  578. data: {
  579. token: app.globalData.token
  580. }
  581. }).then(res => {
  582. Http.get({
  583. url: config.api.checkPhoneStatus,
  584. data: {}
  585. }).then(res => {
  586. /**
  587. * orderSave 下单
  588. */
  589. return Http.post({
  590. url: config.api.orderSave,
  591. data: data
  592. });
  593. }).catch(err => {
  594. console.log(err);
  595. that.setData({
  596. showbutton: false,
  597. showbutton1: false,
  598. canSpell: true,
  599. canBuyIf: true
  600. })
  601. if (err.code == 2011) {
  602. wx.showToast({
  603. title: "商户信息没找到",
  604. image: './../../../assets/images/fail.png',
  605. duration: 2000,
  606. mask: false
  607. });
  608. } else if (err.code == 2013) {
  609. wx.showToast({
  610. title: "商户信息禁用",
  611. image: './../../../assets/images/fail.png',
  612. duration: 2000,
  613. mask: false
  614. });
  615. } else if (err.code == 3000) {
  616. wx.showToast({
  617. title: "库存不足",
  618. image: './../../../assets/images/fail.png',
  619. duration: 2000,
  620. mask: false
  621. });
  622. } else if (err.code == 3001) {
  623. wx.showToast({
  624. title: "您已超过限购",
  625. image: './../../../assets/images/fail.png',
  626. duration: 2000,
  627. mask: false
  628. });
  629. } else if (err.code == 3002) {
  630. wx.showToast({
  631. title: "订单失败",
  632. image: './../../../assets/images/fail.png',
  633. duration: 2000,
  634. mask: false
  635. });
  636. } else if (err.code == 3003) {
  637. wx.showToast({
  638. title: "订单不存在",
  639. image: './../../../assets/images/fail.png',
  640. duration: 2000,
  641. mask: false
  642. });
  643. } else if (err.code == 3004) {
  644. wx.showToast({
  645. title: "订单不存在",
  646. image: './../../../assets/images/fail.png',
  647. duration: 2000,
  648. mask: false
  649. });
  650. } else if (err.code == 4003) {
  651. wx.showToast({
  652. title: "卡券已作废",
  653. image: './../../../assets/images/fail.png',
  654. duration: 2000,
  655. mask: false
  656. });
  657. } else if (err.code == 3012) {
  658. // wx.showToast({
  659. // title: err.message,
  660. // icon: "none"
  661. // })
  662. that.getUnPaidOrder(that.data.data.couponId);
  663. } else if (err.code == 11005) {
  664. /**
  665. * 将值传到用户手机号授权的页面
  666. *
  667. */
  668. wx.redirectTo({
  669. url: `/pages/getphoneInfo/index?path=spell&couponChannelId=${that.data.couponChannelId}&couponId=${that.data.data.couponId}`
  670. });
  671. } else if (err.code == 11006) {
  672. // 用户手机已加密
  673. wx.redirectTo({
  674. url: `/pages/phoneinput/phoneinput?path=spell&couponChannelId=${that.data.couponChannelId}&couponId=${that.data.data.couponId}`
  675. });
  676. } else {
  677. wx.showToast({
  678. title: err.message,
  679. icon: 'none',
  680. duration: 2000,
  681. mask: false
  682. });
  683. }
  684. }).then(res => {
  685. console.log(res, "123")
  686. if (typeof (res) != "undefined") {
  687. let orderId = "" + res.data.mainOrderId;
  688. that.setData({
  689. orderId: orderId,
  690. composeOrderType: res.data.composeOrderType,
  691. canSpell: false,
  692. canBuyIf: true
  693. });
  694. // 支付金额不为0
  695. /**
  696. * 支付订单创建
  697. */
  698. Http.post({
  699. url: config.api.payOrderCreate,
  700. data: {
  701. orderId: orderId,
  702. composeOrderType: that.data.composeOrderType
  703. }
  704. }).then(res => {
  705. var payOrderId = "" + res.data.payOrderId;
  706. wx.hideLoading();
  707. wx.requestPayment({
  708. timeStamp: res.data.timeStamp,
  709. nonceStr: res.data.nonceStr,
  710. package: res.data.package,
  711. signType: (res.data.signType) ? res.data.signType : "MD5",
  712. paySign: res.data.paySign,
  713. success: res => {
  714. that.setData({
  715. canSpell: false
  716. })
  717. wx.showLoading({
  718. title: '订单正在处理中...',
  719. })
  720. // setTimeout(function() {
  721. // wx.hideLoading()
  722. // }, 5000)
  723. that.payOrderUpdate(that.data.orderId, payOrderId, 1, '', that, orderGroupId);
  724. if (res.errMsg == "requestPayment:ok") {
  725. setTimeout(function () {
  726. wx.hideLoading();
  727. }, 2000);
  728. }
  729. },
  730. fail: res => {
  731. /**
  732. * 支付失败,需要更新订单的状态
  733. */
  734. that.payOrderUpdate(that.data.orderId, payOrderId, 2, '', that, orderGroupId);
  735. that.setData({
  736. showbutton: false,
  737. canSpell: true,
  738. canBuyIf: true
  739. })
  740. return;
  741. },
  742. complete: res => { }
  743. });
  744. /// End payment --------
  745. })
  746. .catch(err => {
  747. that.setData({
  748. canSpell: true,
  749. canBuyIf: true
  750. })
  751. wx.showToast({
  752. title: err.message,
  753. icon: 'none',
  754. duration: 2000,
  755. mask: false
  756. });
  757. })
  758. }
  759. })
  760. })
  761. .catch(err => {
  762. console.log(err)
  763. if (err.code == 11004) {
  764. wx.redirectTo({
  765. url: `/pages/getuserinfo/index?fromflag=spellcoupondetail&couponChannelIdflag=${that.data.couponChannelId}`,
  766. })
  767. } else {
  768. wx.showToast({
  769. title: err.message,
  770. icon: "none",
  771. duration: 2500
  772. })
  773. }
  774. })
  775. },
  776. /**
  777. * 生命周期函数--监听页面显示
  778. */
  779. onShow() {
  780. this.setData({
  781. mouldType: app.globalData.mouldType,
  782. canSpell: true,
  783. canBuyIf: true,
  784. showTime: true,
  785. })
  786. if (this.data.spellData != null) {
  787. this.countdown()
  788. }
  789. },
  790. /**
  791. * 生命周期函数--监听页面隐藏
  792. */
  793. onHide: function () {
  794. this.setData({
  795. showTime: false
  796. })
  797. },
  798. /**
  799. * 生命周期函数--监听页面卸载
  800. */
  801. onUnload: function () {
  802. this.setData({
  803. showTime: false
  804. })
  805. },
  806. /**
  807. * 页面相关事件处理函数--监听用户下拉动作
  808. */
  809. onPullDownRefresh: function (e) {
  810. let that = this;
  811. console.log(this.data.couponId, 222)
  812. that.getDetail(that.data.couponChannelId);
  813. if (that.data.couponId) {
  814. that.getOneSpell(that.data.couponId)
  815. }
  816. },
  817. onShareAppMessage: function (options) {
  818. app.globalData.previewFlag = true
  819. console.log(options)
  820. var that = this;
  821. var shareObj = {
  822. title: that.data.data.title,
  823. path: `/pages/index/index?couponChannelId=${that.data.couponChannelId}&couponId=${that.data.data.couponId}&spellGroup=spellGroup`,
  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}&couponId=${that.data.data.couponId}&spellGroup=spellGroup&frommd=JC`;
  835. }
  836. console.log(shareObj)
  837. // 返回shareObj
  838. return shareObj;
  839. },
  840. })