confirmOrder.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. // pages/confirmOrder/confirmOrder.js
  2. const getReq = require('./../../config.js').getReq
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. goods_id: '',
  9. ifcart: '',
  10. num: '',
  11. datas: {},
  12. goods_list: []
  13. },
  14. /**
  15. * 生命周期函数--监听页面加载
  16. */
  17. onLoad: function (options) {
  18. let goods_id = options.goods_id || ''
  19. let iscart = options.iscart || ''
  20. let num = options.num || ''
  21. let cart_id = options.cart_id || ''
  22. this.setData({
  23. goods_id,
  24. ifcart: iscart,
  25. num
  26. })
  27. this.getDatas(goods_id, iscart, num, cart_id)
  28. console.log(options)
  29. },
  30. getDatas(goods_id, ifcart, num, cart_id) {
  31. wx.showLoading({
  32. title: '加载中',
  33. })
  34. var self = this
  35. let goods_datas = '';
  36. if (ifcart == 0) {
  37. goods_datas = goods_id + '|' + num;
  38. }
  39. else {
  40. goods_datas = cart_id;
  41. }
  42. getReq({
  43. act: 'member_buy',
  44. op: 'step_first',
  45. curpage: 1,
  46. cart_id: goods_datas,
  47. ifcart,
  48. }, function (res) {
  49. wx.hideLoading()
  50. console.log('++++')
  51. console.log(res)
  52. if (res.code == 200) {
  53. let datas = res.datas
  54. let goods_list = self.getGoodsList(datas.summary,datas.goods_list)
  55. self.setData({
  56. datas,
  57. goods_list
  58. })
  59. }
  60. else {
  61. wx.showToast({
  62. icon: 'none',
  63. title: res.message,
  64. duration: 2000
  65. })
  66. }
  67. })
  68. },
  69. getGoodsList(summary, goods_list) {
  70. let newGoodsList = []
  71. goods_list.map((item,index) => {
  72. summary.filter((list, key) => {
  73. if (item.goods_id == list.goods_id) {
  74. newGoodsList.push(list)
  75. return true
  76. }
  77. })
  78. })
  79. return newGoodsList
  80. },
  81. /**
  82. * 生命周期函数--监听页面初次渲染完成
  83. */
  84. onReady: function () {
  85. },
  86. /**
  87. * 生命周期函数--监听页面显示
  88. */
  89. onShow: function () {
  90. },
  91. /**
  92. * 生命周期函数--监听页面隐藏
  93. */
  94. onHide: function () {
  95. },
  96. /**
  97. * 生命周期函数--监听页面卸载
  98. */
  99. onUnload: function () {
  100. },
  101. /**
  102. * 页面相关事件处理函数--监听用户下拉动作
  103. */
  104. onPullDownRefresh: function () {
  105. },
  106. /**
  107. * 页面上拉触底事件的处理函数
  108. */
  109. onReachBottom: function () {
  110. },
  111. /**
  112. * 用户点击右上角分享
  113. */
  114. onShareAppMessage: function () {
  115. }
  116. })