|
@@ -23,7 +23,7 @@
|
|
|
</u-checkbox>
|
|
|
</view>
|
|
|
<view class="des">
|
|
|
- <view>满<text>{{item.goldLimit}}</text></view>
|
|
|
+ <view>商品乐豆合计满<text>{{item.goldLimit}}</text></view>
|
|
|
<u-image mode="scaleToFill" width="26rpx" height="26rpx" src="/static/ledou.png"></u-image>
|
|
|
<view>才可购买</view>
|
|
|
</view>
|
|
@@ -140,7 +140,8 @@
|
|
|
return this.$store.state.vuex_cartList
|
|
|
}
|
|
|
},
|
|
|
- onLoad() {
|
|
|
+ onShow() {
|
|
|
+ uni.$emit('getCartList')
|
|
|
this.hasCheckAll()
|
|
|
},
|
|
|
methods: {
|
|
@@ -168,28 +169,53 @@
|
|
|
})
|
|
|
arr.splice()
|
|
|
},
|
|
|
+ // 判断当前分类下的商品总和是否满足规则
|
|
|
+ hasZgjindu(item){
|
|
|
+ let ret = 0
|
|
|
+ let goldLimit = item.goldLimit
|
|
|
+ item.shoppingCartGoodsList.map(good=>{
|
|
|
+ ret = ret + good.goods.sellGold
|
|
|
+ })
|
|
|
+ console.log(ret , goldLimit)
|
|
|
+ return ret >= goldLimit
|
|
|
+ },
|
|
|
// 每个分类的全选
|
|
|
goodsClasChange(e){
|
|
|
console.log(e);
|
|
|
let index = this.cartList.findIndex(item => item.goodsTypeNo == e.name)
|
|
|
- this.cartList[index].checked = e.value
|
|
|
- this.cartList[index].shoppingCartGoodsList.map(goods=>{
|
|
|
- goods.checked = e.value
|
|
|
- })
|
|
|
- // 判断是否全选
|
|
|
- this.hasCheckAll()
|
|
|
+ let item = this.cartList[index]
|
|
|
+ if(this.hasZgjindu(item)){
|
|
|
+ item.checked = e.value
|
|
|
+ item.shoppingCartGoodsList.map(goods=>{
|
|
|
+ goods.checked = e.value
|
|
|
+ })
|
|
|
+ // 判断是否全选
|
|
|
+ this.hasCheckAll()
|
|
|
+ }else{
|
|
|
+ uni.showToast({
|
|
|
+ icon: 'none',
|
|
|
+ title: '此分类的商品乐豆合计需要满'+item.goldLimit+'乐豆才可以购买'
|
|
|
+ })
|
|
|
+ }
|
|
|
},
|
|
|
// 商品选择
|
|
|
goodsChange(e){
|
|
|
console.log(e)
|
|
|
let a = e.name.split('-')
|
|
|
let row = this.cartList[a[1]]
|
|
|
- let goodsIndex = row.shoppingCartGoodsList.findIndex(item => item.id == a[0])
|
|
|
- row.shoppingCartGoodsList[goodsIndex].checked = e.value
|
|
|
- // 判断当前分类是否全选
|
|
|
- this.clasGoodsHasCheckAll(a[1])
|
|
|
- // 判断是否全选
|
|
|
- this.hasCheckAll()
|
|
|
+ if(this.hasZgjindu(row)){
|
|
|
+ let goodsIndex = row.shoppingCartGoodsList.findIndex(item => item.id == a[0])
|
|
|
+ row.shoppingCartGoodsList[goodsIndex].checked = e.value
|
|
|
+ // 判断当前分类是否全选
|
|
|
+ this.clasGoodsHasCheckAll(a[1])
|
|
|
+ // 判断是否全选
|
|
|
+ this.hasCheckAll()
|
|
|
+ }else{
|
|
|
+ uni.showToast({
|
|
|
+ icon: 'none',
|
|
|
+ title: '此分类的商品乐豆合计需要满'+row.goldLimit+'乐豆才可以购买'
|
|
|
+ })
|
|
|
+ }
|
|
|
},
|
|
|
// 判断某个分类是否全选
|
|
|
clasGoodsHasCheckAll(index){
|