|
@@ -9,40 +9,55 @@ Page({
|
|
|
goods_id: '',
|
|
|
ifcart: '',
|
|
|
num: '',
|
|
|
- datas: {}
|
|
|
+ datas: {},
|
|
|
+ goods_list: []
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad: function (options) {
|
|
|
- let { goods_id, iscart, num } = options
|
|
|
+ let goods_id = options.goods_id || ''
|
|
|
+ let iscart = options.iscart || ''
|
|
|
+ let num = options.num || ''
|
|
|
+ let cart_id = options.cart_id || ''
|
|
|
this.setData({
|
|
|
goods_id,
|
|
|
ifcart: iscart,
|
|
|
num
|
|
|
})
|
|
|
- this.getDatas(goods_id, iscart, num)
|
|
|
+ this.getDatas(goods_id, iscart, num, cart_id)
|
|
|
console.log(options)
|
|
|
},
|
|
|
- getDatas(goods_id, ifcart, num) {
|
|
|
+ getDatas(goods_id, ifcart, num, cart_id) {
|
|
|
wx.showLoading({
|
|
|
title: '加载中',
|
|
|
})
|
|
|
var self = this
|
|
|
+ let goods_datas = '';
|
|
|
+ if (ifcart == 0) {
|
|
|
+ goods_datas = goods_id + '|' + num;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ goods_datas = cart_id;
|
|
|
+ }
|
|
|
getReq({
|
|
|
act: 'member_buy',
|
|
|
op: 'step_first',
|
|
|
curpage: 1,
|
|
|
- cart_id: `${goods_id}|${num}`,
|
|
|
+ cart_id: goods_datas,
|
|
|
ifcart,
|
|
|
}, function (res) {
|
|
|
wx.hideLoading()
|
|
|
+ console.log('++++')
|
|
|
console.log(res)
|
|
|
if (res.code == 200) {
|
|
|
let datas = res.datas
|
|
|
+ let goods_list = self.getGoodsList(datas.summary,datas.goods_list)
|
|
|
+
|
|
|
self.setData({
|
|
|
- datas
|
|
|
+ datas,
|
|
|
+ goods_list
|
|
|
})
|
|
|
|
|
|
}
|
|
@@ -55,52 +70,65 @@ Page({
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
+ getGoodsList(summary, goods_list) {
|
|
|
+ let newGoodsList = []
|
|
|
+ goods_list.map((item,index) => {
|
|
|
+ summary.filter((list, key) => {
|
|
|
+ if (item.goods_id == list.goods_id) {
|
|
|
+ newGoodsList.push(list)
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ return newGoodsList
|
|
|
+
|
|
|
+ },
|
|
|
/**
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
*/
|
|
|
onReady: function () {
|
|
|
-
|
|
|
+
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面显示
|
|
|
*/
|
|
|
onShow: function () {
|
|
|
-
|
|
|
+
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
*/
|
|
|
onHide: function () {
|
|
|
-
|
|
|
+
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
*/
|
|
|
onUnload: function () {
|
|
|
-
|
|
|
+
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
*/
|
|
|
onPullDownRefresh: function () {
|
|
|
-
|
|
|
+
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
*/
|
|
|
onReachBottom: function () {
|
|
|
-
|
|
|
+
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 用户点击右上角分享
|
|
|
*/
|
|
|
onShareAppMessage: function () {
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
})
|