fourth commit

master
李庚 5 months ago
parent 01112011d9
commit f45ace8d4f

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

@ -1,8 +1,15 @@
<view class="cart"> <view class="cart">
<view class="list" wx:for="{{ cartData }}" wx:key="index"> <view class="list" wx:for="{{ cartData }}" wx:key="index">
<van-swipe-cell right-width="{{ 65 }}"> <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> <view data-id="{{ item.id }}" bindtap="delCartHandle" slot="right" class="van-swipe-cell-right">删除</view>
</van-swipe-cell> </van-swipe-cell>
</view> </view>
</view> </view>

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

Loading…
Cancel
Save