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.

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