Переглянути джерело

购物车删除改为滑动删除

xiaohaizhao 2 роки тому
батько
коміт
b3706c5507

+ 24 - 12
pages/index/collect/index.js

@@ -17,7 +17,7 @@ Component({
 		sa_brandid: null, //当前选中品牌id
 		classList: [], //生成订单时所选
 		sum: 0, //价格合
-		allBrandList:[]
+		allBrandList: []
 	},
 	methods: {
 		init() {
@@ -223,19 +223,31 @@ Component({
 			const {
 				item
 			} = e.currentTarget.dataset;
-			_Http.basic({
-				"id": 20220924095202,
-				"content": {
-					"sa_shoppingcartids": [item.sa_shoppingcartid]
+			wx.showModal({
+				title: '提示',
+				content: `是否确认删除${item.itemname}?`,
+				complete: ({
+					confirm
+				}) => {
+					e.detail.instance.close();
+					if (confirm) _Http.basic({
+						"id": 20220924095202,
+						"content": {
+							"sa_shoppingcartids": [item.sa_shoppingcartid]
+						}
+					}).then(res => {
+						wx.showToast({
+							title: res.msg != '成功' ? res.msg : "删除成功",
+							icon: "none"
+						});
+						if (res.msg != '成功') return;
+						this.getList(true)
+						getApp().globalData.getCollectCount()
+					})
 				}
-			}).then(res => {
-				if (res.msg != '成功') return wx.showToast({
-					title: res.msg,
-					icon: "none"
-				});
-				this.getList(true)
-				getApp().globalData.getCollectCount()
 			})
+
+
 		},
 		/* 输入框失去焦点调整数量 */
 		inputBlur(e) {

+ 2 - 1
pages/index/collect/index.json

@@ -2,6 +2,7 @@
 	"component": true,
 	"usingComponents": {
 		"van-checkbox": "@vant/weapp/checkbox/index",
-		"van-stepper": "@vant/weapp/stepper/index"
+		"van-stepper": "@vant/weapp/stepper/index",
+		"van-swipe-cell": "@vant/weapp/swipe-cell/index"
 	}
 }

+ 15 - 7
pages/index/collect/index.scss

@@ -88,13 +88,9 @@ page {
 			align-items: center;
 			height: 100%;
 			width: 380rpx;
-
-			.label-class {
-				font-size: 24rpx;
-				font-family: PingFang SC-Regular, PingFang SC;
-				color: #999999;
-				margin-left: -6rpx;
-			}
+			font-size: 24rpx;
+			font-family: PingFang SC-Regular, PingFang SC;
+			color: #999999;
 		}
 
 		.input-class {
@@ -103,6 +99,18 @@ page {
 	}
 }
 
+.cell-right {
+	background-color: #E54D42;
+	display: flex;
+	align-items: center;
+	justify-content: center;
+	color: #fff;
+	font-weight: 700;
+	font-size: 28rpx;
+	width: 65px;
+	height: 100%;
+}
+
 .footer-box {
 	position: fixed;
 	bottom: 0;

+ 26 - 25
pages/index/collect/index.wxml

@@ -1,35 +1,36 @@
 <view class="head" />
 <Yl_ListBox id='ListBox' bind:getlist='getList'>
-	<view url="#" wx:for="{{list}}" wx:key="itemid" class="item-box">
-		<view class="top" bindtap="changeResults" data-item="{{item}}">
-			<view class="image">
-				<van-image width="100%" height="100%" fit="cover" src="{{item.attinfos[0].subfiles[0].url||item.attinfos[0].url||item.cover}}" use-loading-slot use-error-slot lazy-load>
-					<van-loading slot="loading" type="spinner" size="20" vertical />
-					<text slot="error">加载失败</text>
-				</van-image>
-			</view>
-			<view class="content">
-				<view class="title">
-					<text class="line-1">{{item.itemname}}</text>
-					<text class="iconfont icon-guanlian-shanchu" catchtap="deteleItem" data-item="{{item}}" />
+	<van-swipe-cell wx:for="{{list}}" wx:key="itemid" id="swipe-cell" right-width="{{ 65 }}" async-close data-item="{{item}}" bind:close="deteleItem">
+		<view url="#" class="item-box">
+			<view class="top" bindtap="changeResults" data-item="{{item}}">
+				<view class="image">
+					<van-image width="100%" height="100%" fit="cover" src="{{item.attinfos[0].subfiles[0].url||item.attinfos[0].url||item.cover}}" use-loading-slot use-error-slot lazy-load>
+						<van-loading slot="loading" type="spinner" size="20" vertical />
+						<text slot="error">加载失败</text>
+					</van-image>
+				</view>
+				<view class="content">
+					<view class="title">
+						<text class="line-1">{{item.itemname}}</text>
+						<van-checkbox shape='square' disabled="{{sa_brandid && sa_brandid!=item.sa_brandid}}" icon-size='24rpx' value="{{ decide.checked(item.sa_shoppingcartid,results) }}" />
+					</view>
+					<view class="exp">编号:{{item.itemno}}</view>
+					<view class="exp">规格:{{item.spec ||" --"}}</view>
+					<view class="exp">型号:{{item.model ||" --"}}</view>
+					<view class="exp">品牌:{{item.brandname ||" --"}}</view>
+					<view class="exp">领域:{{item.tradefield_shoppingcart ||" --"}}</view>
+					<view class="price">{{item.showPrice}}/{{item.unitname}}</view>
 				</view>
-				<view class="exp">编号:{{item.itemno}}</view>
-				<view class="exp">规格:{{item.spec ||" --"}}</view>
-				<view class="exp">型号:{{item.model ||" --"}}</view>
-				<view class="exp">品牌:{{item.brandname ||" --"}}</view>
-				<view class="exp">领域:{{item.tradefield_shoppingcart ||" --"}}</view>
-				<view class="price">{{item.showPrice}}/{{item.unitname}}</view>
 			</view>
-		</view>
-		<view class="bottom">
-			<view class="check" bindtap="changeResults" data-item="{{item}}">
-				<van-checkbox shape='square' disabled="{{sa_brandid && sa_brandid!=item.sa_brandid}}" icon-size='24rpx' label-class='label-class' value="{{ decide.checked(item.sa_shoppingcartid,results) }}" bind:change="onChange">
+			<view class="bottom">
+				<view class="check label-class">
 					起订量:{{item.orderminqty}},增减量:{{item.orderaddqty}}
-				</van-checkbox>
+				</view>
+				<van-stepper value="{{ item.qty }}" min="{{item.orderminqty}}" step="{{item.orderaddqty}}" input-class='input-class' data-index="{{index}}" bind:minus='stepperChange' bind:plus='stepperChange' bind:blur='inputBlur' />
 			</view>
-			<van-stepper value="{{ item.qty }}" min="{{item.orderminqty}}" step="{{item.orderaddqty}}" input-class='input-class' data-index="{{index}}" bind:minus='stepperChange' bind:plus='stepperChange' bind:blur='inputBlur' />
 		</view>
-	</view>
+		<view slot="right" class="cell-right">删 除</view>
+	</van-swipe-cell>
 	<Yl_Empty wx:if="{{list.length === 0}}" />
 	<view style="height: 200px;" />
 </Yl_ListBox>