多选按钮

This commit is contained in:
jqtmviyu@gmail.com 2021-03-04 23:30:56 +08:00
parent 3024e8be90
commit ce2539f983

View File

@ -15,7 +15,7 @@
<!-- 底部结算栏 -->
<view class="bottom">
<radio :checked="true" color="#E03440" class="select_btn" />
<radio :checked="selectAll" color="#E03440" class="select_btn" />
<text class="select_text">全选</text>
<text class="total_text">合计</text>
<text class="price">3999</text>
@ -28,12 +28,14 @@
export default {
data(){
return {
cartList: []
cartList: [],
selectAll: false
}
},
onShow() {
const cartList = uni.getStorageSync("cartList") || [];
this.cartList = cartList
this.selectAll = this.cartList.every(item=>item.goods_select === true)
},
methods: {
//
@ -42,6 +44,9 @@ export default {
// this.cartList[index].goods_select = !this.cartList[index].goods_select
const index = this.cartList.findIndex(item=>item.goods_id === goods_id)
this.cartList[index].goods_select = !this.cartList[index].goods_select
//
this.selectAll = this.cartList.every(item=>item.goods_select === true)
}
},
}