groupcheck.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. var util = require('../../../utils/util.js');
  2. var api = require('../../../config/api.js');
  3. var app = getApp();
  4. var dateArray = [];
  5. Page({
  6. data: {
  7. groupId: 0,
  8. openId: 0,
  9. number: 1,
  10. productId: 0,
  11. productVo: {},
  12. goodsVo: {},
  13. addressVo: {},
  14. postscript: '',
  15. goodsPrice: 0.00, //商品总价
  16. freightPrice: 0.00, //快递费
  17. orderPrice: 0.00, //订单总价
  18. actualPrice: 0.00, //实际需要支付的总价
  19. delivery_remark: '尽快送达',
  20. multiArray: [],
  21. multiIndex: [0],
  22. timeArray: util.getNowTimeArray()
  23. },
  24. bindMultiPickerColumnChange: function (e) {
  25. let that = this;
  26. console.log('修改的列为', e.detail.column, ',值为', e.detail.value);
  27. var data = {
  28. multiArray: this.data.multiArray,
  29. multiIndex: this.data.multiIndex
  30. };
  31. data.multiIndex[e.detail.column] = e.detail.value
  32. let timeArray = that.data.timeArray;
  33. if (data.multiIndex[0] == 1) {
  34. timeArray = util.timeArray.slice(0);
  35. } else {
  36. timeArray = util.getNowTimeArray();
  37. }
  38. data.timeArray = timeArray;
  39. data.multiArray[0] = timeArray;
  40. this.setData(data)
  41. },
  42. bindMultiPickerChange: function (e) {
  43. let that = this;
  44. console.log('picker发送选择改变,携带值为', e.detail.value)
  45. this.setData({
  46. multiIndex: e.detail.value,
  47. delivery_remark: e.detail.value[0] == 0 ? that.data.timeArray[e.detail.value[0]] : that.data.timeArray[e.detail.value[0]]
  48. })
  49. },
  50. initPicker() {
  51. let that = this;
  52. this.setData({
  53. 'multiArray[0]': that.data.timeArray,
  54. })
  55. },
  56. onLoad: function (options) {
  57. // 页面初始化 options为页面跳转所带来的参数
  58. this.setData({
  59. groupId: options.groupId,
  60. number: options.number,
  61. productId: options.productId,
  62. openId: options.openId ? options.openId:0,
  63. });
  64. wx.showLoading({
  65. title: '加载中...',
  66. })
  67. this.getGoodsInfo();
  68. },
  69. getGoodsInfo: function () {
  70. let that = this;
  71. util.request(api.GroupCheckInfo, {
  72. groupId: that.data.groupId,
  73. number: that.data.number, productId: that.data.productId
  74. }).then(function (res) {
  75. if (res.errno === 0) {
  76. console.log(res.data);
  77. that.setData({
  78. productVo: res.data.productVo,
  79. goodsVo: res.data.goodsVo,
  80. number: res.data.number,
  81. addressVo: res.data.addressVo,
  82. actualPrice: res.data.actualPrice,
  83. freightPrice: res.data.freightPrice,
  84. goodsPrice: res.data.goodsPrice,
  85. orderPrice: res.data.orderPrice
  86. });
  87. }
  88. wx.hideLoading();
  89. });
  90. },
  91. selectAddress() {
  92. wx.navigateTo({
  93. url: '/pages/shopping/address/address',
  94. })
  95. },
  96. addAddress() {
  97. wx.navigateTo({
  98. url: '/pages/shopping/addressAdd/addressAdd',
  99. })
  100. },
  101. onReady: function () {
  102. // 页面渲染完成
  103. },
  104. onShow: function () {
  105. // 页面显示
  106. console.log(this.data.addressVo);
  107. this.initPicker()
  108. },
  109. onHide: function () {
  110. // 页面隐藏
  111. },
  112. onUnload: function () {
  113. // 页面关闭
  114. },
  115. bindPostscriptBlur(e) {
  116. let postscript = e.detail.value;
  117. this.setData({
  118. postscript: postscript
  119. });
  120. },
  121. submitOrder: function () {
  122. // wx.redirectTo({
  123. // url: '/pages/payResult/payResult?status=1&orderId=' + 88,
  124. // })
  125. if (!this.data.addressVo) {
  126. util.showErrorToast('请选择收货地址');
  127. return false;
  128. }
  129. let that = this;
  130. if (null != that.data.openId && that.data.openId != 0) {
  131. util.request(api.AttendGroup, {
  132. addressVo: that.data.addressVo,
  133. openId: that.data.openId,
  134. productId: that.data.productId,
  135. postscript: that.data.postscript,
  136. number: that.data.number,
  137. addressId: that.data.addressVo.id,
  138. delivery_remark: that.data.delivery_remark
  139. }, 'POST').then(function (res) {
  140. if (res.errno === 0) {
  141. wx.redirectTo({
  142. url: '/pages/pay/pay?orderId=' + res.data.orderInfo.id + '&actualPrice=' + res.data.orderInfo.actual_price
  143. })
  144. } else {
  145. util.showErrorToast(res.errmsg);
  146. }
  147. });
  148. } else {
  149. util.request(api.OpenGroup, {
  150. addressVo: that.data.addressVo,
  151. groupId: that.data.groupId,
  152. productId: that.data.productId,
  153. postscript: that.data.postscript,
  154. number: that.data.number,
  155. addressId: that.data.addressVo.id,
  156. delivery_remark: that.data.delivery_remark
  157. }, 'POST').then(function (res) {
  158. if (res.errno === 0) {
  159. wx.redirectTo({
  160. url: '/pages/pay/pay?orderId=' + res.data.orderInfo.id + '&actualPrice=' + res.data.orderInfo.actual_price
  161. })
  162. } else {
  163. util.showErrorToast(res.errmsg);
  164. }
  165. });
  166. }
  167. }
  168. })