C端小程序
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

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