fourth commit

master
李庚 5 months ago
parent 01112011d9
commit f45ace8d4f

@ -1,5 +1,6 @@
const { getCart,delGoodsCart } = require("../../api/index.js")
//111111
Page({
/**
* 页面的初始数据
@ -13,8 +14,16 @@ const { getCart,delGoodsCart } = require("../../api/index.js")
onShow(){
this.http()
},
goDetail(e) {
const id = e.currentTarget.dataset.id;
wx.navigateTo({
url: `/pages/goodsDetails/goodsDetails?id=${id}`
});
},
// 根源
delCartHandle(e){
console.log("删除按钮被点击");
console.log(e.currentTarget.dataset.id);
/**
* 这里有两个ID
@ -25,21 +34,21 @@ const { getCart,delGoodsCart } = require("../../api/index.js")
if(res.data.status === 200){
wx.showToast({
title: '删除成功',
})
});
this.http()
}else{
wx.showToast({
title: '删除失败',
})
});
}
})
});
},
http(){
getCart().then(res =>{
console.log(res.data.data);
this.setData({
cartData:res.data.data
})
})
});
});
}
})

@ -1,8 +1,15 @@
<view class="cart">
<view class="list" wx:for="{{ cartData }}" wx:key="index">
<van-swipe-cell right-width="{{ 65 }}">
<van-card price="{{ item.price }}" title="{{ item.title }}" thumb="{{ item.image }}" />
<van-card
price="{{ item.price }}"
title="{{ item.title }}"
thumb="{{ item.image }}"
bindtap="goDetail"
data-id="{{ item.id }}"
/>
<view data-id="{{ item.id }}" bindtap="delCartHandle" slot="right" class="van-swipe-cell-right">删除</view>
</van-swipe-cell>
</view>
</view>

@ -4,10 +4,11 @@
.van-swipe-cell-right{
height: 100%;
width: 60px;
background-color: #f00;
background-color: rgb(255, 7, 7);
text-align: center;
color: #fff;
color: rgb(255, 255, 255);
font-size: 16px;
font-weight: 700;
padding-top: 40px;
display: block;
}
Loading…
Cancel
Save