Ver código fonte

fix(购物车): 修复左滑删除混乱问题并添加canReduce条件

修复iOS上左滑删除多个商品时出现的混乱问题,添加touchstart事件处理只允许滑动一个商品
在减钱按钮上添加canReduce条件控制显示
移除订单状态中已废弃的退款状态
ylong 2 semanas atrás
pai
commit
f97880934d

+ 1 - 3
pages-car/components/buy-order-item.vue

@@ -148,15 +148,13 @@
                 })
             },
             getStatusText(order) {
-                //订单状态:1-待付款 2-待发货 3-待收货 4-已完成 5-已取消 6-退款中 7-已退款
+                //订单状态:1-待付款 2-待发货 3-待收货 4-已完成 5-已取消
                 const map = {
                     '1': '待付款',
                     '2': '待发货',
                     '3': '待收货',
                     '4': '已完成',
                     '5': '已取消',
-                    '6': '退款中',
-                    '7': '已退款'
                 }
                 return map[order.status] || '未知状态'
             },

+ 1 - 1
pages-car/components/cart-item.vue

@@ -56,7 +56,7 @@
                 </view>
 
                 <!-- 去减钱按钮 -->
-                <view class="reduce-btn" v-if="item.canInvite == 1" @click.stop="handleReduce">
+                <view class="reduce-btn" v-if="item.canInvite == 1 && canReduce" @click.stop="handleReduce">
                     <text>去减钱</text>
                 </view>
 

+ 8 - 1
pages-car/pages/index.vue

@@ -3,7 +3,7 @@
         <!-- 购物车列表 -->
         <view class="cart-list">
             <u-swipe-action :show="item.show" :index="index" v-for="(item, index) in cartList" :key="item.id"
-                @click="clickAction" @open="openAction" :options="actionOptions">
+                @click="clickAction" @open="openAction" @touchstart="swipeStart" :options="actionOptions">
                 <cart-item :item="item" @check="handleCheck" @changeNum="handleChangeNum" @reduce="handleReduce"
                     @selectCondition="onSelectCondition"></cart-item>
             </u-swipe-action>
@@ -181,6 +181,13 @@
             }
         },
         methods: {
+            swipeStart(index) {
+                this.cartList.forEach((item, idx) => {
+                    if (index !== idx) {
+                        item.show = false;
+                    }
+                });
+            },
             clickAction(index, index1) {
                 if (this.actionOptions[index1].text == '删除') {
                     const item = this.cartList[index];

+ 10 - 1
uview-ui/components/u-swipe-action/u-swipe-action.vue

@@ -143,6 +143,10 @@ export default {
 		close() {
 			this.moveX = 0;
 			this.status = false;
+			// 添加微小的偏移量以强制更新(解决iOS上由于数据未变化导致视图不更新的问题)
+			this.$nextTick(() => {
+				this.moveX = 101;
+			});
 		},
 		// 打开按钮的状态
 		open() {
@@ -196,7 +200,9 @@ export default {
 			this.$emit('close', this.index);
 		},
 		// 开始触摸
-		touchstart() {},
+		touchstart() {
+			this.$emit('touchstart', this.index);
+		},
 		getActionRect() {
 			this.$uGetRect('.u-swipe-action').then(res => {
 				this.movableAreaWidth = res.width;
@@ -212,6 +218,9 @@ export default {
 			if (this.status == true) {
 				this.status = 'close';
 				this.moveX = 0;
+				this.$nextTick(() => {
+					this.moveX = 101;
+				});
 			}
 			this.$emit('content-click', this.index);
 		}