C端小程序
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

159 lignes
3.6 KiB

  1. // pages/spellGroup/mySpellGroup/index.js
  2. var config = require("../../../config/config.js");
  3. const Http = require("../../../utils/HttpBasics");
  4. const imgurl = require("../../../utils/imgurl");
  5. const utils = require("../../../utils/util.js")
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. teljpgUrl: imgurl.teljpg.url,
  12. wmhome: imgurl.wmhome.url,
  13. couponChannelId: '',
  14. couponId: '',
  15. data: null,
  16. spellData: null,
  17. canSpell: true,
  18. canBuyIf: true,
  19. clock: "00",
  20. day: "00",
  21. hour: "00",
  22. min: "00",
  23. sec: "00",
  24. showTime: true
  25. },
  26. /**
  27. * 生命周期函数--监听页面加载
  28. */
  29. onLoad: function (options) {
  30. this.setData({
  31. couponChannelId: options.couponChannelId,
  32. couponId: options.couponId
  33. })
  34. if (options && options.couponChannelId) {
  35. this.getDetail(options.couponChannelId);
  36. }
  37. },
  38. gotoIndex: function () {
  39. wx.switchTab({
  40. url: '/pages/main/index',
  41. })
  42. },
  43. /**
  44. * 拨打电话
  45. */
  46. phone: function (e) {
  47. let that = this;
  48. wx.makePhoneCall({
  49. phoneNumber: e.target.dataset.merchantlinkphone
  50. });
  51. },
  52. /**
  53. * 直接购买
  54. */
  55. gotoBuy(e) {
  56. console.log(22222)
  57. this.setData({
  58. canBuyIf: false
  59. })
  60. wx.navigateTo({
  61. url: '/pages/integralmall/payIntegcoupondetail/index?couponChannelId=' + this.data.couponChannelId + '&couponId=' + this.data.couponId,
  62. })
  63. },
  64. // 时间格式化输出,如11:03 25:19 每1s都会调用一次
  65. dateformat(micro_second) {
  66. // 总秒数
  67. var second = Math.floor(micro_second / 1000);
  68. // 天数
  69. var day = Math.floor(second / 3600 / 24) < 10 ? "0" + Math.floor(second / 3600 / 24) : Math.floor(second / 3600 / 24);
  70. // 小时
  71. var hr = Math.floor(second / 3600 % 24) < 10 ? "0" + Math.floor(second / 3600 % 24) : Math.floor(second / 3600 % 24);
  72. // 分钟
  73. var min = Math.floor(second / 60 % 60) < 10 ? "0" + Math.floor(second / 60 % 60) : Math.floor(second / 60 % 60);
  74. // 秒
  75. var sec = Math.floor(second % 60) < 10 ? "0" + Math.floor(second % 60) : Math.floor(second % 60);
  76. // return day + "天" + hr + "小时" + min + "分钟" + sec + "秒";
  77. return {
  78. a1: day,
  79. b1: hr,
  80. c1: min,
  81. d1: sec
  82. }
  83. },
  84. /**
  85. * 获取券详情信息
  86. */
  87. getDetail(couponChannelId) {
  88. let that = this;
  89. Http.get({
  90. url: config.api.couponDetail,
  91. data: {
  92. couponChannelId: couponChannelId
  93. }
  94. }).then(res => {
  95. wx.stopPullDownRefresh();
  96. let data = res.data;
  97. data.price = (data.price / 100).toFixed(2)
  98. data.salePrice = (data.salePrice / 100).toFixed(2);
  99. data.validStartDate = utils.formatTime(data.validStartDate, 'yyyy-MM-dd')
  100. data.validEndDate = utils.formatTime(data.validEndDate, 'yyyy-MM-dd')
  101. that.setData({
  102. data
  103. });
  104. });
  105. },
  106. /**
  107. * 生命周期函数--监听页面初次渲染完成
  108. */
  109. onReady: function () {
  110. },
  111. /**
  112. * 生命周期函数--监听页面显示
  113. */
  114. onShow: function () {
  115. this.setData({
  116. canSpell: true,
  117. canBuyIf: true,
  118. showTime: true
  119. })
  120. },
  121. /**
  122. * 生命周期函数--监听页面隐藏
  123. */
  124. onHide: function () {
  125. this.setData({
  126. showTime: false
  127. })
  128. },
  129. /**
  130. * 生命周期函数--监听页面卸载
  131. */
  132. onUnload: function () {
  133. this.setData({
  134. showTime: false
  135. })
  136. },
  137. /**
  138. * 页面相关事件处理函数--监听用户下拉动作
  139. */
  140. onPullDownRefresh: function (e) {
  141. let that = this;
  142. that.getDetail(that.data.couponChannelId);
  143. },
  144. /**
  145. * 页面上拉触底事件的处理函数
  146. */
  147. onReachBottom: function () {
  148. }
  149. })