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.

194 lignes
4.5 KiB

  1. // pages/spellDetail/index.js
  2. var config = require("../../config/config.js");
  3. const Http = require("../../utils/HttpBasics");
  4. const imgurl = require("../../utils/imgurl");
  5. const {spellStatus} = require("../../utils/spell");
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. tuanzhang: imgurl.tuanzhang.url,
  12. spellBg: imgurl.spellBg.url,
  13. position: imgurl.position.url,
  14. paramData:null,
  15. data:null,
  16. clock: "00",
  17. day: "00",
  18. hour: "00",
  19. min: "00",
  20. sec: "00",
  21. spellStatusList: spellStatus
  22. },
  23. /**
  24. * 生命周期函数--监听页面加载
  25. */
  26. onLoad: function (options) {
  27. console.log(this.data.spellStatusList,7777777)
  28. this.setData({
  29. paramData:options
  30. })
  31. this.getDetail(options);
  32. // 关闭来自于左上角的分享
  33. wx.hideShareMenu()
  34. },
  35. /**
  36. * 去使用
  37. */
  38. gotoUse() {
  39. wx.navigateTo({
  40. url: `/pages/couponorder/index/index`
  41. });
  42. },
  43. /**
  44. * 拼团状态字段转换
  45. */
  46. changeSatus(status){
  47. console.log(spellStatus,8888888)
  48. return spellStatus.filter(item=>item.value==status)[0].name;
  49. },
  50. // 时间格式化输出,如11:03 25:19 每1s都会调用一次
  51. dateformat(micro_second) {
  52. // 总秒数
  53. var second = Math.floor(micro_second / 1000);
  54. // 天数
  55. var day = Math.floor(second / 3600 / 24) < 10 ? "0" + Math.floor(second / 3600 / 24) : Math.floor(second / 3600 / 24);
  56. // 小时
  57. var hr = Math.floor(second / 3600 % 24) < 10 ? "0" + Math.floor(second / 3600 % 24) : Math.floor(second / 3600 % 24);
  58. // 分钟
  59. var min = Math.floor(second / 60 % 60) < 10 ? "0" + Math.floor(second / 60 % 60) : Math.floor(second / 60 % 60);
  60. // 秒
  61. var sec = Math.floor(second % 60) < 10 ? "0" + Math.floor(second % 60) : Math.floor(second % 60);
  62. // return day + "天" + hr + "小时" + min + "分钟" + sec + "秒";
  63. return {
  64. a1: day,
  65. b1: hr,
  66. c1: min,
  67. d1: sec
  68. }
  69. },
  70. countdown(end_time) {
  71. let that = this;
  72. var EndTime = end_time;
  73. var NowTime = new Date().getTime();
  74. var total_micro_second = EndTime - NowTime || [];
  75. // 渲染倒计时时钟
  76. let obj = that.dateformat(total_micro_second);
  77. if (total_micro_second > 0) {
  78. that.setData({
  79. clock: obj,
  80. day: obj.a1,
  81. hour: obj.b1,
  82. min: obj.c1,
  83. sec: obj.d1,
  84. })
  85. } else {
  86. that.setData({
  87. clock: "00",
  88. day: "00",
  89. hour: "00",
  90. min: "00",
  91. sec: "00",
  92. })
  93. }
  94. setTimeout(function () {
  95. total_micro_second -= 1000;
  96. that.countdown(end_time);
  97. }, 1000)
  98. },
  99. getDetail(){
  100. let that = this;
  101. Http.get({
  102. url: config.api.queryOrderGroupStatus,
  103. data: {
  104. orderId: this.data.paramData.orderId,
  105. couponId: this.data.paramData.couponId,
  106. id: this.data.paramData.orderGroupId
  107. }
  108. }).then(res => {
  109. console.log(res,555555555)
  110. let data=res.data;
  111. data.statustext=that.changeSatus(data.status);
  112. if(data.status!=11){
  113. that.countdown(data.expiredDate);
  114. }
  115. data.salePrice = (data.salePrice/100).toFixed(2)
  116. for (let i = 0; i < data.remainPeople;i++){
  117. let a={};
  118. data.userList.push(a)
  119. }
  120. that.setData({
  121. data:res.data
  122. })
  123. });
  124. },
  125. /**
  126. * 生命周期函数--监听页面初次渲染完成
  127. */
  128. onReady: function () {
  129. },
  130. /**
  131. * 生命周期函数--监听页面显示
  132. */
  133. onShow: function () {
  134. },
  135. /**
  136. * 生命周期函数--监听页面隐藏
  137. */
  138. onHide: function () {
  139. },
  140. /**
  141. * 生命周期函数--监听页面卸载
  142. */
  143. onUnload: function () {
  144. },
  145. /**
  146. * 页面相关事件处理函数--监听用户下拉动作
  147. */
  148. onPullDownRefresh: function () {
  149. },
  150. /**
  151. * 页面上拉触底事件的处理函数
  152. */
  153. onReachBottom: function () {
  154. },
  155. /**
  156. * 用户点击右上角分享
  157. */
  158. // paramData
  159. onShareAppMessage: function (res) {
  160. if (res.from === 'button') {
  161. console.log(res, 3333333333333333333333)
  162. // 来自页面内转发按钮
  163. let _this = this;
  164. return {
  165. title: '拼团',
  166. path: `/pages/index/index?couponId=${_this.data.data.couponId}&orderGroupId=${_this.data.data.orderGroupId}&couponChannelId=${_this.data.paramData.couponChannelId}&orderId=${_this.data.data.orderId}`,
  167. imageUrl: _this.data.data.coverImg,
  168. success: function (res) {
  169. // 转发成功
  170. },
  171. fail: function (res) {
  172. // 转发失败
  173. }
  174. }
  175. } else {
  176. console.log(res, 444444444444444444)
  177. }
  178. }
  179. })