|
@@ -33,8 +33,9 @@
|
|
|
<view class="info">
|
|
|
<text>尺码:{{ sizeItem }}</text>
|
|
|
<text class="basecolor">¥{{ item.money }}/{{ item.unit }} </text>
|
|
|
+ <text class="basecolor" v-show="item.name == '红色贺岁款(精装版)'">剩余:{{ item.storage[sizeIndex] }}{{ item.unit }}</text>
|
|
|
</view>
|
|
|
- <NumInput :value="item.cart[sizeIndex]" :args="[index, sizeIndex]" :num="item.step"
|
|
|
+ <NumInput :value="item.cart[sizeIndex]" :args="[index, sizeIndex]" :num="item.step" :max="item.storage[sizeIndex]" :name="item.name"
|
|
|
@change="numChange" />
|
|
|
</view>
|
|
|
</view>
|
|
@@ -84,7 +85,8 @@
|
|
|
} from '@/common/util/index.js'
|
|
|
import {
|
|
|
_API_GoodList,
|
|
|
- GetGoodStatus
|
|
|
+ GetGoodStatus,
|
|
|
+ GetLimitGood
|
|
|
} from '@/apis/good.js'
|
|
|
import {
|
|
|
_API_GetallGift,
|
|
@@ -163,7 +165,7 @@
|
|
|
}
|
|
|
},
|
|
|
onShow() {
|
|
|
- console.log(this.$store.state.cart.list)
|
|
|
+ this.getLimitNum()
|
|
|
const cartinfo = this.$store.state.cart.list
|
|
|
for (var i = 0; i < cartinfo.length; i++) {
|
|
|
// cartinfo[i].goods_num= sum(cartinfo[i].cart)
|
|
@@ -184,7 +186,7 @@
|
|
|
cartinfo[i].goods_num = newArr.reduce((p, e) => p + e.num, 0);
|
|
|
cartinfo[i].goods_money = cartinfo[i].goods_num * cartinfo[i].money
|
|
|
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
console.log(cartinfo)
|
|
|
// if (this.$store.getters['cart/shopcarNum']) {
|
|
@@ -211,6 +213,20 @@
|
|
|
// }
|
|
|
// })
|
|
|
// },
|
|
|
+ // 新款商品剩余数量
|
|
|
+ getLimitNum() {
|
|
|
+ let storage = [0,0,0,0,0,0,0,0,0,0,0,0,0,0] // 剩余数量
|
|
|
+ GetLimitGood().then(res => {
|
|
|
+ if (res.data.length) {
|
|
|
+ storage = res.data.map(item => (item.limit_num - item.num)) // 剩余数量 = 限制购买数量 - 已购买数量
|
|
|
+ }
|
|
|
+ const arr = this.$store.state.cart.list
|
|
|
+ const i = arr.findIndex(item => item.name == '红色贺岁款(精装版)')
|
|
|
+ if (i != -1) {
|
|
|
+ this.$store.commit('cart/GETNEWGOODSNUM', storage)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
getAllGift() {
|
|
|
this.giftList = []
|
|
|
_API_GetallGift().then(res => {
|
|
@@ -222,9 +238,18 @@
|
|
|
numChange(value, index, sizeIndex) { // 购物车数量发生变化
|
|
|
if (value) {
|
|
|
const cartinfo = this.$store.state.cart.list
|
|
|
+ // const storage = cartinfo[index].storage[sizeIndex]
|
|
|
+ // if (value > storage) {
|
|
|
+ // uni.showToast({
|
|
|
+ // title: '库存不足!',
|
|
|
+ // icon: 'none'
|
|
|
+ // })
|
|
|
+ // return
|
|
|
+ // }
|
|
|
cartinfo[index].cart[sizeIndex] = value
|
|
|
cartinfo[index].goods_num = sum(cartinfo[index].cart)
|
|
|
cartinfo[index].goods_money = sum(cartinfo[index].cart) * cartinfo[index].money
|
|
|
+
|
|
|
this.$store.commit('cart/COUNTCHANGE', {
|
|
|
value,
|
|
|
index,
|