Skip to content

Commit

Permalink
增加订单详情加入购物车功能
Browse files Browse the repository at this point in the history
  • Loading branch information
412102420ts committed Mar 29, 2022
1 parent ed66156 commit 6ba1ec7
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
41 changes: 41 additions & 0 deletions mall4m/pages/order-detail/order-detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Page({
transfee: '',
reduceAmount: '',
actualTotal: '',
prodid: '',
shopId: '',
prodid: ''
},

Expand Down Expand Up @@ -62,6 +64,7 @@ Page({
transfee: res.transfee,
reduceAmount: res.reduceAmount,
actualTotal: res.actualTotal,
shopId: res.shopId
});
wx.hideLoading();
}
Expand All @@ -70,6 +73,44 @@ Page({

},

/**
* 加入购物车
*/
addToCart: function(event) {
let index = event.currentTarget.dataset.index
// if (!this.orderItemDtos) {
// console.log(1213)
// return;
// }
var ths = this;
wx.showLoading({
mask: true
});
var params = {
url: "/p/shopCart/changeItem",
method: "POST",
data: {
basketId: 0,
count: this.data.orderItemDtos[index].prodCount,
prodId: this.data.orderItemDtos[index].prodId,
shopId: this.data.shopId,
skuId: this.data.orderItemDtos[index].skuId
},
callBack: function(res) {
//console.log(res);
wx.hideLoading();
wx.showToast({
title: "加入购物车成功",
icon: "none"
})
wx.switchTab({
url: '/pages/basket/basket',
})
}
};
http.request(params);
},


/**
* 生命周期函数--监听页面初次渲染完成
Expand Down
2 changes: 1 addition & 1 deletion mall4m/pages/order-detail/order-detail.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<text class='small-num'>.{{wxs.parsePrice(item.price)[1]}}</text></text>
<view class='btn-box'>
<text class='btn'>申请售后</text>
<text class='btn'>加购物车</text>
<text class='btn' data-index='{{index}}' catchtap='addToCart'>加购物车</text>
</view>
</view>
</view>
Expand Down

0 comments on commit 6ba1ec7

Please sign in to comment.