index.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. // pages/join-pink/index.js
  2. var app = getApp();
  3. var wxh = require('../../utils/wxh.js');
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. pinkKId:0,
  10. pinkId:0,
  11. count:0,
  12. currentPinkOrder: '',
  13. isOk: 0,
  14. pinkAll: [],
  15. pinkBool: 0,
  16. pinkT: [],
  17. storeInfo: [],
  18. storeCombination: [],
  19. storeCombinationHost: [],
  20. userBool: 0,
  21. url: app.globalData.urlImages,
  22. countDownHour: "00",
  23. countDownMinute: "00",
  24. countDownSecond: "00"
  25. },
  26. /**
  27. * 生命周期函数--监听页面加载
  28. */
  29. onLoad: function (options) {
  30. app.setBarColor();
  31. app.globalData.openPages = '/pages/join-pink/index?id=' + options.id;
  32. app.setUserInfo();
  33. if (options.id){
  34. this.setData({
  35. pinkId: options.id
  36. })
  37. this.getPinkList();
  38. }else{
  39. wx.showToast({
  40. title: '参数错误',
  41. icon: 'none',
  42. duration: 1000,
  43. })
  44. setTimeout(function(){
  45. wx.navigateBack({})
  46. },1200)
  47. }
  48. },
  49. goPinkOrder:function(e){
  50. var that = this;
  51. wx.request({
  52. url: app.globalData.url + '/routine/auth_api/get_form_id?uid=' + app.globalData.uid,
  53. method: 'GET',
  54. data: {
  55. formId: e.detail.formId
  56. },
  57. success: function (res) { }
  58. })
  59. wx.request({
  60. url: app.globalData.url + '/routine/auth_api/now_buy?uid=' + app.globalData.uid,
  61. method: 'GET',
  62. data: {
  63. productId: that.data.storeCombination.product_id,
  64. cartNum: that.data.pinkT.total_num,
  65. uniqueId: '',
  66. combinationId: that.data.storeCombination.id,
  67. secKillId: 0
  68. },
  69. success: function (res) {
  70. if (res.data.code == 200) {
  71. wx.navigateTo({ //跳转至指定页面并关闭其他打开的所有页面(这个最好用在返回至首页的的时候)
  72. url: '/pages/order-confirm/order-confirm?id=' + res.data.data.cartId + '&pinkId=' + that.data.pinkT.id
  73. })
  74. } else {
  75. wx.showToast({
  76. title: res.data.msg,
  77. icon: 'none',
  78. duration: 2000
  79. })
  80. }
  81. }
  82. })
  83. },
  84. getPinkList:function(){
  85. var that = this;
  86. wx.request({
  87. url: app.globalData.url + '/routine/auth_api/get_pink?uid=' + app.globalData.uid,
  88. data: {
  89. id: that.data.pinkId
  90. },
  91. method: 'GET',
  92. dataType: 'json',
  93. success: function(res) {
  94. console.log(res);
  95. if(res.data.code == 200){
  96. that.setData({
  97. count: res.data.data.count,
  98. currentPinkOrder: res.data.data.current_pink_order,
  99. isOk: res.data.data.is_ok,
  100. pinkAll: res.data.data.pinkAll,
  101. pinkBool: res.data.data.pinkBool,
  102. pinkT: res.data.data.pinkT,
  103. storeInfo: res.data.data.storeInfo,
  104. storeCombination: res.data.data.store_combination,
  105. storeCombinationHost: res.data.data.store_combination_host,
  106. userBool: res.data.data.userBool
  107. })
  108. var timeStamp = that.data.pinkT.stop_time;
  109. wxh.time(timeStamp, that);
  110. console.log(that.data.pinkId);
  111. console.log(that.data.storeCombinationHost);
  112. }
  113. },
  114. })
  115. },
  116. /**
  117. * 生命周期函数--监听页面初次渲染完成
  118. */
  119. onReady: function () {
  120. },
  121. /**
  122. * 生命周期函数--监听页面显示
  123. */
  124. onShow: function () {
  125. },
  126. /**
  127. * 生命周期函数--监听页面隐藏
  128. */
  129. onHide: function () {
  130. },
  131. /**
  132. * 生命周期函数--监听页面卸载
  133. */
  134. onUnload: function () {
  135. },
  136. /**
  137. * 页面相关事件处理函数--监听用户下拉动作
  138. */
  139. onPullDownRefresh: function () {
  140. },
  141. /**
  142. * 页面上拉触底事件的处理函数
  143. */
  144. onReachBottom: function () {
  145. },
  146. /**
  147. * 用户点击右上角分享
  148. */
  149. onShareAppMessage: function () {
  150. var that = this;
  151. return {
  152. title: that.data.storeCombination.userInfo.nickname + '邀请您参团',
  153. path: '/pages/join-pink/index?id=' + that.data.pinkId,
  154. imageUrl: that.data.url + that.data.storeCombination.image,
  155. success: function () {
  156. wx.showToast({
  157. title: '分享成功',
  158. icon: 'success',
  159. duration: 2000
  160. })
  161. }
  162. }
  163. }
  164. })