|
@@ -58,7 +58,7 @@
|
|
|
return this.$store.state.userinfo
|
|
|
},
|
|
|
list() {
|
|
|
- const temp = this.goodsList
|
|
|
+ const temp = deepClone(this.goodsList)
|
|
|
temp.forEach(goodItem => {
|
|
|
goodItem.cart = Array(goodItem.size.length).fill(0)
|
|
|
const itemInCart = this.$store.state.cart.list.find(e => e.attr_id === goodItem.attr_id)
|
|
@@ -105,22 +105,25 @@
|
|
|
uni.showLoading({
|
|
|
mask: true
|
|
|
})
|
|
|
+ // 新款商品剩余数量
|
|
|
+ let residue = [0,0,0,0,0,0,0,0,0,0,0,0,0,0] // 剩余数量
|
|
|
+ GetLimitGood().then(res => {
|
|
|
+ if (res.data.length) {
|
|
|
+ residue = res.data.map(item => (item.limit_num - item.num)) // 剩余数量 = 限制购买数量 - 已购买数量
|
|
|
+ }
|
|
|
+ })
|
|
|
_API_GoodList().then(res => {
|
|
|
if (res.code === 200) {
|
|
|
- // let arr = res.data.list
|
|
|
- // if (arr.length) {
|
|
|
- // this.goodsList = arr.map(function(item) {
|
|
|
- // if (item.name == '红色贺岁款(精装版)') {
|
|
|
- // return {...item, storage: storage}
|
|
|
- // } else {
|
|
|
- // return item
|
|
|
- // }
|
|
|
- // })
|
|
|
- // } else {
|
|
|
- // this.status = '暂无商品'
|
|
|
- // }
|
|
|
- this.goodsList = res.data.list
|
|
|
- if (!this.goodsList.length) {
|
|
|
+ let arr = res.data.list
|
|
|
+ if (arr.length) {
|
|
|
+ this.goodsList = arr.map(function(item) {
|
|
|
+ if (item.name == '红色贺岁款(精装版)') {
|
|
|
+ return {...item, residue: residue}
|
|
|
+ } else {
|
|
|
+ return item
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
this.status = '暂无商品'
|
|
|
}
|
|
|
} else {
|
|
@@ -140,15 +143,15 @@
|
|
|
},
|
|
|
tapShopCar(item) {
|
|
|
// 新款商品剩余数量
|
|
|
- let storage = [0,0,0,0,0,0,0,0,0,0,0,0,0,0] // 剩余数量
|
|
|
+ let residue = [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)) // 剩余数量 = 限制购买数量 - 已购买数量
|
|
|
+ residue = 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)
|
|
|
+ this.$store.commit('cart/GETNEWGOODSNUM', residue)
|
|
|
}
|
|
|
this.$refs.addCart.show(deepClone(item))
|
|
|
})
|