C端小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

160 line
3.6 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. /**
  34. * 拼团状态字段转换
  35. */
  36. changeSatus(status){
  37. console.log(spellStatus,8888888)
  38. return spellStatus.filter(item=>item.value==status)[0].name;
  39. },
  40. // 时间格式化输出,如11:03 25:19 每1s都会调用一次
  41. dateformat(micro_second) {
  42. // 总秒数
  43. var second = Math.floor(micro_second / 1000);
  44. // 天数
  45. var day = Math.floor(second / 3600 / 24) < 10 ? "0" + Math.floor(second / 3600 / 24) : Math.floor(second / 3600 / 24);
  46. // 小时
  47. var hr = Math.floor(second / 3600 % 24) < 10 ? "0" + Math.floor(second / 3600 % 24) : Math.floor(second / 3600 % 24);
  48. // 分钟
  49. var min = Math.floor(second / 60 % 60) < 10 ? "0" + Math.floor(second / 60 % 60) : Math.floor(second / 60 % 60);
  50. // 秒
  51. var sec = Math.floor(second % 60) < 10 ? "0" + Math.floor(second % 60) : Math.floor(second % 60);
  52. // return day + "天" + hr + "小时" + min + "分钟" + sec + "秒";
  53. return {
  54. a1: day,
  55. b1: hr,
  56. c1: min,
  57. d1: sec
  58. }
  59. },
  60. countdown(end_time) {
  61. let that = this;
  62. var EndTime = end_time;
  63. var NowTime = new Date().getTime();
  64. var total_micro_second = EndTime - NowTime || [];
  65. // 渲染倒计时时钟
  66. let obj = that.dateformat(total_micro_second);
  67. if (total_micro_second > 0) {
  68. that.setData({
  69. clock: obj,
  70. day: obj.a1,
  71. hour: obj.b1,
  72. min: obj.c1,
  73. sec: obj.d1,
  74. })
  75. } else {
  76. that.setData({
  77. clock: "00",
  78. day: "00",
  79. hour: "00",
  80. min: "00",
  81. sec: "00",
  82. })
  83. }
  84. setTimeout(function () {
  85. total_micro_second -= 1000;
  86. that.countdown(end_time);
  87. }, 1000)
  88. },
  89. getDetail(){
  90. let that = this;
  91. Http.get({
  92. url: config.api.queryOrderGroupStatus,
  93. data: {
  94. orderId: this.data.paramData.orderId,
  95. couponId: this.data.paramData.couponId,
  96. id: this.data.paramData.orderGroupId
  97. }
  98. }).then(res => {
  99. console.log(res,555555555)
  100. let data=res.data;
  101. data.statustext=that.changeSatus(data.status);
  102. that.countdown(data.expiredDate);
  103. data.salePrice = (data.salePrice/100).toFixed(2)
  104. that.setData({
  105. data:res.data
  106. })
  107. });
  108. },
  109. /**
  110. * 生命周期函数--监听页面初次渲染完成
  111. */
  112. onReady: function () {
  113. },
  114. /**
  115. * 生命周期函数--监听页面显示
  116. */
  117. onShow: function () {
  118. },
  119. /**
  120. * 生命周期函数--监听页面隐藏
  121. */
  122. onHide: function () {
  123. },
  124. /**
  125. * 生命周期函数--监听页面卸载
  126. */
  127. onUnload: function () {
  128. },
  129. /**
  130. * 页面相关事件处理函数--监听用户下拉动作
  131. */
  132. onPullDownRefresh: function () {
  133. },
  134. /**
  135. * 页面上拉触底事件的处理函数
  136. */
  137. onReachBottom: function () {
  138. },
  139. /**
  140. * 用户点击右上角分享
  141. */
  142. onShareAppMessage: function () {
  143. }
  144. })