Jelajahi Sumber

增加全选范围

gcz 2 tahun lalu
induk
melakukan
8d0ef2763b
1 mengubah file dengan 10 tambahan dan 1 penghapusan
  1. 10 1
      shopping/cart.vue

+ 10 - 1
shopping/cart.vue

@@ -85,7 +85,7 @@
 		<view class="cart-bottom">
 			<view class="inner u-flex u-row-between">
 				<view class="left u-flex">
-					<view class="checkbox">
+					<view class="checkbox" @click="checkboxClick" style="padding: 10px;">
 						<u-checkbox-group @change="allCheckboxChange">
 							<u-checkbox shape="circle" :checked="allChecked" :name="allCheckbox.name" label="全选"></u-checkbox>
 						</u-checkbox-group>
@@ -258,6 +258,14 @@
 					}
 				})
 			},
+			checkboxClick(){
+				// console.log('checkboxClick',this.allChecked);
+				this.dataList.forEach(item => {
+					if(item.quantity<=item.stock){
+						item.checked = !this.allChecked
+					}
+				})
+			},
 			checkboxChange(n){
 				// console.log('checkboxChange',n);
 			},
@@ -447,6 +455,7 @@
 		right: 0;
 		bottom: 0;
 		padding: 0 20rpx;
+		padding-left: 0;
 		.total-price{
 			font-size: 30rpx;
 			color: #333;