首页加入购物车

This commit is contained in:
liaoanqi
2022-08-29 10:32:27 +08:00
parent 63433830fc
commit 827770ab40
2 changed files with 49 additions and 8 deletions

View File

@@ -71,13 +71,6 @@ Page({
})
},
//跳转公告列表页面
onNewsPage: function() {
wx.navigateTo({
url: '/pages/recent-news/recent-news',
})
},
//跳转限时特惠页面
toLimitedTimeOffer: function(e) {
wx.showToast({
@@ -86,6 +79,13 @@ Page({
})
},
//跳转公告列表页面
onNewsPage: function() {
wx.navigateTo({
url: '/pages/recent-news/recent-news',
})
},
onShow: function() {
},
getAllData() {
@@ -125,6 +125,47 @@ Page({
http.request(params);
},
/**
* 加入购物车
*/
addToCart(e) {
const prodId = e.currentTarget.dataset.prodid
const ths = this
wx.showLoading();
var params = {
url: "/prod/prodInfo",
method: "GET",
data: {
prodId
},
callBack: (res) => {
var params = {
url: "/p/shopCart/changeItem",
method: "POST",
data: {
basketId: 0,
count: 1,
prodId: res.prodId,
shopId: res.shopId,
skuId: res.skuList[0].skuId
},
callBack: function(res) {
ths.setData({
totalCartNum: ths.data.totalCartNum + ths.data.prodNum
});
wx.hideLoading();
wx.showToast({
title: "加入购物车成功",
icon: "none"
})
}
};
http.request(params);
}
};
http.request(params);
},
// 加载商品标题分组列表
getTag() {

View File

@@ -139,7 +139,7 @@
<text class='small-num'>.{{wxs.parsePrice(prod.price)[1]}}</text>
</view>
<!-- <view class='go-to-buy'>立即购买</view> -->
<image src='../../images/tabbar/basket-sel.png' class='basket-img'></image>
<image src='../../images/tabbar/basket-sel.png' class='basket-img' data-prodid="{{prod.prodId}}" catchtap="addToCart"></image>
</view>
</view>
</view>