C端小程序
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

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