confirmOrder.js 2.3 KB

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