C端小程序
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

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