C端小程序
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

858 linhas
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. wx.navigateTo({
  400. url: `/pages/joinFrDpell/index?orderId=${this.data.spellData.orderId}&couponId=${this.data.spellData.couponId}&orderGroupId=${this.data.spellData.orderGroupId}&couponChannelId=${this.data.couponChannelId}&avatarUrl=${this.data.spellData.avatarUrl}&nickName=${this.data.spellData.nickName}`
  401. });
  402. },
  403. /**
  404. * 获取一个拼团信息
  405. */
  406. getOneSpell(couponId) {
  407. let that = this;
  408. Http.get({
  409. url: config.api.queryRemainOne,
  410. data: {
  411. couponId: couponId
  412. }
  413. }).then(res => {
  414. wx.stopPullDownRefresh();
  415. if (res.data) {
  416. that.countdown(res.data.expiredDate);
  417. that.setData({
  418. spellData: res.data
  419. });
  420. }
  421. });
  422. },
  423. /**
  424. * 获取券详情信息
  425. */
  426. getDetail(couponChannelId) {
  427. let that = this;
  428. Http.get({
  429. url: config.api.couponDetail,
  430. data: {
  431. couponChannelId: couponChannelId
  432. }
  433. }).then(res => {
  434. wx.stopPullDownRefresh();
  435. let data = res.data;
  436. if (res && res.data && res.data.detailPicture) {
  437. that.setData({
  438. detailPicture: JSON.parse(res.data.detailPicture)
  439. })
  440. }
  441. if (res && res.data && res.data.coverPicture) {
  442. that.setData({
  443. coverPicture: JSON.parse(res.data.coverPicture)
  444. })
  445. }
  446. if (res && res.data && res.data.conditions) {
  447. that.setData({
  448. limitCondition: JSON.parse(res.data.conditions).type
  449. })
  450. if (JSON.parse(res.data.conditions).type == 2 && (JSON.parse(res.data.conditions).min || JSON.parse(res.data.conditions).min == 0)) {
  451. that.setData({
  452. minLimit: JSON.parse(res.data.conditions).min
  453. })
  454. }
  455. if (JSON.parse(res.data.conditions).type == 2 && (JSON.parse(res.data.conditions).max) || JSON.parse(res.data.conditions).max == 0) {
  456. that.setData({
  457. maxLimit: JSON.parse(res.data.conditions).max
  458. })
  459. }
  460. }
  461. data.price = (data.price / 100).toFixed(2)
  462. data.salePrice = (data.salePrice / 100).toFixed(2);
  463. data.validStartDate = utils.formatTime(data.validStartDate, 'yyyy-MM-dd')
  464. data.validEndDate = utils.formatTime(data.validEndDate, 'yyyy-MM-dd')
  465. // that.setData({
  466. // data,
  467. // merchantVoList: data.merchantVoList
  468. // });
  469. Http.get({
  470. url: config.api.couponMerchant,
  471. data: {
  472. couponChannelId: couponChannelId
  473. }
  474. }).then(res => {
  475. const keys = Object.keys(res.data)
  476. const mallList = []
  477. keys.forEach(item => {
  478. const arr = item.split('|')
  479. const obj = {
  480. tenantId: arr[0],
  481. mallName: arr[1],
  482. merchantVoList: res.data[item],
  483. expand: true
  484. }
  485. mallList.push(obj)
  486. })
  487. this.setData({
  488. mallList: mallList
  489. })
  490. console.log(this.data.mallList, 'mallList');
  491. })
  492. });
  493. },
  494. /**
  495. * 去拼团
  496. */
  497. goToOrderGroup(orderId, orderGroupId, _this) {
  498. let that = this;
  499. // 支付成功
  500. Http.post({
  501. url: config.api.toOrderGroup,
  502. data: {
  503. id: orderGroupId,
  504. orderId,
  505. couponId: _this.data.data.couponId
  506. }
  507. })
  508. .then(res => {
  509. wx.navigateTo({
  510. url: `/pages/spellDetail/index?orderId=${orderId}&couponId=${_this.data.data.couponId}&orderGroupId=${res.data.orderGroupId}&couponChannelId=${_this.data.couponChannelId}`
  511. });
  512. })
  513. .catch(err => {
  514. console.log(err);
  515. })
  516. },
  517. /**
  518. * 支付订单更新
  519. */
  520. payOrderUpdate: (orderId, payOrderId, status, reason, _this, orderGroupId) => {
  521. console.log(orderGroupId, 7777)
  522. let that = this;
  523. // 支付成功
  524. Http.post({
  525. url: config.api.payOrderUpdate,
  526. data: {
  527. payOrderId: payOrderId,
  528. composeOrderId: orderId,
  529. status: status,
  530. reason: reason
  531. }
  532. })
  533. .then(res => {
  534. wx.hideLoading()
  535. if (orderGroupId !== 0) {
  536. wx.navigateTo({
  537. url: '/pages/order/detail/index?orderId=' + res.data.mainOrderId,
  538. })
  539. } else {
  540. _this.goToOrderGroup(res.data.singleOrder.id, res.data.mainOrderId, _this)
  541. }
  542. })
  543. .catch(err => {
  544. if (err.code != 12002) {
  545. setTimeout(function () {
  546. _this.payOrderUpdate(orderId, payOrderId, status, reason, _this, orderGroupId);
  547. }, 2000)
  548. }
  549. })
  550. },
  551. /**
  552. * 发起支付
  553. */
  554. orderFunc() {
  555. let that = this;
  556. let orderGroupId = this.data.orderGroupId;
  557. let data = {
  558. couponChannelId: this.data.data.id,
  559. couponId: this.data.data.couponId,
  560. formId: this.data.formId
  561. }
  562. /**
  563. * 拼团订单
  564. */
  565. if (this.data.orderGroupId == 0) {
  566. data.orderGroupId = this.data.orderGroupId,
  567. that.setData({
  568. isFromSpell: true
  569. })
  570. } else {
  571. that.setData({
  572. isFromSpell: false
  573. })
  574. }
  575. Http.get({
  576. url: config.api.checkUserStatus,
  577. data: {
  578. token: app.globalData.token
  579. }
  580. }).then(res => {
  581. Http.get({
  582. url: config.api.checkPhoneStatus,
  583. data: {}
  584. }).then(res => {
  585. /**
  586. * orderSave 下单
  587. */
  588. return Http.post({
  589. url: config.api.orderSave,
  590. data: data
  591. });
  592. }).catch(err => {
  593. console.log(err);
  594. that.setData({
  595. showbutton: false,
  596. showbutton1: false,
  597. canSpell: true,
  598. canBuyIf: true
  599. })
  600. if (err.code == 2011) {
  601. wx.showToast({
  602. title: "商户信息没找到",
  603. image: './../../../assets/images/fail.png',
  604. duration: 2000,
  605. mask: false
  606. });
  607. } else if (err.code == 2013) {
  608. wx.showToast({
  609. title: "商户信息禁用",
  610. image: './../../../assets/images/fail.png',
  611. duration: 2000,
  612. mask: false
  613. });
  614. } else if (err.code == 3000) {
  615. wx.showToast({
  616. title: "库存不足",
  617. image: './../../../assets/images/fail.png',
  618. duration: 2000,
  619. mask: false
  620. });
  621. } else if (err.code == 3001) {
  622. wx.showToast({
  623. title: "您已超过限购",
  624. image: './../../../assets/images/fail.png',
  625. duration: 2000,
  626. mask: false
  627. });
  628. } else if (err.code == 3002) {
  629. wx.showToast({
  630. title: "订单失败",
  631. image: './../../../assets/images/fail.png',
  632. duration: 2000,
  633. mask: false
  634. });
  635. } else if (err.code == 3003) {
  636. wx.showToast({
  637. title: "订单不存在",
  638. image: './../../../assets/images/fail.png',
  639. duration: 2000,
  640. mask: false
  641. });
  642. } else if (err.code == 3004) {
  643. wx.showToast({
  644. title: "订单不存在",
  645. image: './../../../assets/images/fail.png',
  646. duration: 2000,
  647. mask: false
  648. });
  649. } else if (err.code == 4003) {
  650. wx.showToast({
  651. title: "卡券已作废",
  652. image: './../../../assets/images/fail.png',
  653. duration: 2000,
  654. mask: false
  655. });
  656. } else if (err.code == 3012) {
  657. // wx.showToast({
  658. // title: err.message,
  659. // icon: "none"
  660. // })
  661. that.getUnPaidOrder(that.data.data.couponId);
  662. } else if (err.code == 11005) {
  663. /**
  664. * 将值传到用户手机号授权的页面
  665. *
  666. */
  667. wx.redirectTo({
  668. url: `/pages/getphoneInfo/index?path=spell&couponChannelId=${that.data.couponChannelId}&couponId=${that.data.data.couponId}`
  669. });
  670. } else if (err.code == 11006) {
  671. // 用户手机已加密
  672. wx.redirectTo({
  673. url: `/pages/phoneinput/phoneinput?path=spell&couponChannelId=${that.data.couponChannelId}&couponId=${that.data.data.couponId}`
  674. });
  675. } else {
  676. wx.showToast({
  677. title: err.message,
  678. icon: 'none',
  679. duration: 2000,
  680. mask: false
  681. });
  682. }
  683. }).then(res => {
  684. console.log(res, "123")
  685. if (typeof (res) != "undefined") {
  686. let orderId = "" + res.data.mainOrderId;
  687. that.setData({
  688. orderId: orderId,
  689. composeOrderType: res.data.composeOrderType,
  690. canSpell: false,
  691. canBuyIf: true
  692. });
  693. // 支付金额不为0
  694. /**
  695. * 支付订单创建
  696. */
  697. Http.post({
  698. url: config.api.payOrderCreate,
  699. data: {
  700. orderId: orderId,
  701. composeOrderType: that.data.composeOrderType
  702. }
  703. }).then(res => {
  704. var payOrderId = "" + res.data.payOrderId;
  705. wx.hideLoading();
  706. wx.requestPayment({
  707. timeStamp: res.data.timeStamp,
  708. nonceStr: res.data.nonceStr,
  709. package: res.data.package,
  710. signType: (res.data.signType) ? res.data.signType : "MD5",
  711. paySign: res.data.paySign,
  712. success: res => {
  713. that.setData({
  714. canSpell: false
  715. })
  716. wx.showLoading({
  717. title: '订单正在处理中...',
  718. })
  719. // setTimeout(function() {
  720. // wx.hideLoading()
  721. // }, 5000)
  722. that.payOrderUpdate(that.data.orderId, payOrderId, 1, '', that, orderGroupId);
  723. if (res.errMsg == "requestPayment:ok") {
  724. setTimeout(function () {
  725. wx.hideLoading();
  726. }, 2000);
  727. }
  728. },
  729. fail: res => {
  730. /**
  731. * 支付失败,需要更新订单的状态
  732. */
  733. that.payOrderUpdate(that.data.orderId, payOrderId, 2, '', that, orderGroupId);
  734. that.setData({
  735. showbutton: false,
  736. canSpell: true,
  737. canBuyIf: true
  738. })
  739. return;
  740. },
  741. complete: res => { }
  742. });
  743. /// End payment --------
  744. })
  745. .catch(err => {
  746. that.setData({
  747. canSpell: true,
  748. canBuyIf: true
  749. })
  750. wx.showToast({
  751. title: err.message,
  752. icon: 'none',
  753. duration: 2000,
  754. mask: false
  755. });
  756. })
  757. }
  758. })
  759. })
  760. .catch(err => {
  761. console.log(err)
  762. if (err.code == 11004) {
  763. wx.redirectTo({
  764. url: `/pages/getuserinfo/index?fromflag=spellcoupondetail&couponChannelIdflag=${that.data.couponChannelId}`,
  765. })
  766. } else {
  767. wx.showToast({
  768. title: err.message,
  769. icon: "none",
  770. duration: 2500
  771. })
  772. }
  773. })
  774. },
  775. /**
  776. * 生命周期函数--监听页面显示
  777. */
  778. onShow() {
  779. this.setData({
  780. mouldType: app.globalData.mouldType,
  781. canSpell: true,
  782. canBuyIf: true,
  783. showTime: true,
  784. })
  785. if (this.data.spellData != null) {
  786. this.countdown()
  787. }
  788. },
  789. /**
  790. * 生命周期函数--监听页面隐藏
  791. */
  792. onHide: function () {
  793. this.setData({
  794. showTime: false
  795. })
  796. },
  797. /**
  798. * 生命周期函数--监听页面卸载
  799. */
  800. onUnload: function () {
  801. this.setData({
  802. showTime: false
  803. })
  804. },
  805. /**
  806. * 页面相关事件处理函数--监听用户下拉动作
  807. */
  808. onPullDownRefresh: function (e) {
  809. let that = this;
  810. console.log(this.data.couponId, 222)
  811. that.getDetail(that.data.couponChannelId);
  812. if (that.data.couponId) {
  813. that.getOneSpell(that.data.couponId)
  814. }
  815. },
  816. onShareAppMessage: function (options) {
  817. app.globalData.previewFlag = true
  818. console.log(options)
  819. var that = this;
  820. var shareObj = {
  821. title: that.data.data.title,
  822. path: `/pages/index/index?couponChannelId=${that.data.couponChannelId}&couponId=${that.data.data.couponId}&spellGroup=spellGroup`,
  823. success: function (res) {
  824. if (res.errMsg == 'shareAppMessage:ok') { }
  825. },
  826. fail: function (error) {
  827. if (res.errMsg == 'shareAppMessage:fail cancel') { } else if (res.errMsg == 'shareAppMessage:fail') { }
  828. }
  829. };
  830. // 来自页面内的按钮的转发
  831. if (options.from == 'button') {
  832. var eData = options.target.dataset.id;
  833. shareObj.path = `/pages/index/index?couponChannelId=${eData}&couponId=${that.data.data.couponId}&spellGroup=spellGroup&frommd=JC`;
  834. }
  835. console.log(shareObj)
  836. // 返回shareObj
  837. return shareObj;
  838. },
  839. })