feat:商品加入购物车接口联调

This commit is contained in:
2025-05-22 17:52:37 +08:00
parent 6d4dcca5e8
commit e6cb80c043
2 changed files with 75 additions and 25 deletions

View File

@@ -79,12 +79,33 @@
"secondBrokerageProportion": 0
})
const buyBtn = () => {
console.log('跳转到购物车')
//添加物品
const buyBtn = async () => {
try {
const res = await request({
url: '/app-api/trade/cart/add',
showLoading: true,
method:'post',
data:{
skuId:commodityDetails.value.id,
count:'1'
}
})
if (res.code === 0 || res.code === 200) {
uni.navigateTo({
url: '/pages/shoppingCart/shoppingCart'
})
} else {
throw new Error(res.msg || '数据异常')
}
}
catch (err) {
console.error('获取商场数据失败:', err)
}
}
const getCommodityDetail = async (id) => {
try {
const res = await request({