|
|
@@ -81,12 +81,14 @@
|
|
|
</view>
|
|
|
<scroll-view scroll-y="true" class="scroll-view-css box-border-box plr-32">
|
|
|
<view class="" v-for="(item,i) in popData.spec_attr" :key="i">
|
|
|
- <view class="fs-32 fw-500 fc-0 mb-32">{{item.group_name}}</view>
|
|
|
- <view class="flex-wrap-wrap">
|
|
|
+ <view class="fs-32 fw-500 fc-0 mb-32">{{item.sku_name}}</view>
|
|
|
+ <view class="flex-wrap-wrap w-m">
|
|
|
<view class="spec-item text-align-center fs-28"
|
|
|
- :class="popData.spec_ids.indexOf(info.item_id)>=0?'s-item':'n-item'"
|
|
|
- v-for="(info,k) in item.spec_items" :key="k" @click="selectSpec(info,i)">
|
|
|
- {{info.spec_value}}
|
|
|
+ :class="popData.spec_ids.indexOf(info.spec_id)>=0?'s-item':'n-item'"
|
|
|
+ v-for="(info,k) in item.spec_list" :key="k" @click="selectSpec(info,i)">
|
|
|
+ {{info.spec_name}} <text class="fc-FB3D03 fs-26"
|
|
|
+ v-if="Number(info.spec_price) > 0"><text
|
|
|
+ class="plr-10">|</text>¥{{Number(info.spec_price).toFixed(2)}}</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
@@ -108,7 +110,7 @@
|
|
|
<view class="pop-buttom-left">
|
|
|
<view class="">
|
|
|
<span class="fw-600 fs-32 fc-ED301D">¥</span>
|
|
|
- <span class="fw-600 fs-48 fc-ED301D">{{popData.price}}</span>
|
|
|
+ <span class="fw-600 fs-48 fc-ED301D">{{Number(popData.price).toFixed(2)}}</span>
|
|
|
</view>
|
|
|
<view class="">
|
|
|
<span class="fw-400 fs-24 fc-9">已选规格:</span>
|
|
|
@@ -138,6 +140,7 @@
|
|
|
shopGoodsSpec
|
|
|
} from "@/api/shop";
|
|
|
import {
|
|
|
+ shoppingSave,
|
|
|
getShopIngList,
|
|
|
setShopIngAdd,
|
|
|
setShopIngDel,
|
|
|
@@ -204,7 +207,8 @@
|
|
|
},
|
|
|
methods: {
|
|
|
setSpecNum(type) {
|
|
|
- if (!this.popData.goods_spec_id) {
|
|
|
+ // this.popData.spec_ids
|
|
|
+ if (!this.popData.spec_key) {
|
|
|
console.log('被阻挡');
|
|
|
tools.error('请选择规格')
|
|
|
return;
|
|
|
@@ -212,7 +216,7 @@
|
|
|
if (type === 1) {
|
|
|
// 减
|
|
|
console.log('减');
|
|
|
- if (this.popData.num > 0) {
|
|
|
+ if (this.popData.num > 1) {
|
|
|
--this.popData.num;
|
|
|
this.$forceUpdate()
|
|
|
} else {
|
|
|
@@ -236,41 +240,47 @@
|
|
|
|
|
|
},
|
|
|
getShopGoodsSpec(item) {
|
|
|
+ console.log(item,'item');
|
|
|
shopGoodsSpec({
|
|
|
'goods_id': item.goods_id
|
|
|
}).then(res => {
|
|
|
+ console.log(item,'item');
|
|
|
this.popData.goodsItem = item
|
|
|
if (this.popData.goods_id !== item.goods_id) {
|
|
|
this.popData.goods_id = item.goods_id
|
|
|
this.popData.spec_name = []
|
|
|
- this.popData.price = '0.00'
|
|
|
+ // this.popData.price = '0.00'
|
|
|
+ this.popData.price = item.price
|
|
|
this.popData.line_price = ''
|
|
|
this.popData.spec_key = ''
|
|
|
this.popData.num = 1
|
|
|
this.popData.spec_ids = []
|
|
|
} else {
|
|
|
+ console.log('无');
|
|
|
this.popData.num = 1;
|
|
|
+ // this.popData.price = item.price
|
|
|
if (this.cartData.goods_list.length > 0) {
|
|
|
this.cartData.goods_list.forEach(item => {
|
|
|
- if (item.spec_sku_id === this.popData.spec_key) {
|
|
|
- this.popData.num = item.goods_number
|
|
|
+ if (item.goods_spec_id === this.popData.spec_key) {
|
|
|
+ this.popData.num = this.selectedSpecification.goods_number
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
- this.popData.spec_list = res.data.spec_list
|
|
|
- this.popData.spec_attr = res.data.spec_attr
|
|
|
- console.log(this.selectedSpecification, '+++++++++++++++++');
|
|
|
+ this.popData.spec_list = res.data
|
|
|
+ this.popData.spec_attr = res.data
|
|
|
+ console.log(this.selectedSpecification,'this.selectedSpecification');
|
|
|
this.selectedSpecification.forEach((v, k) => {
|
|
|
if (v.goods_id === item.goods_id) {
|
|
|
v.goodsItem = item
|
|
|
- v.spec_list = res.data.spec_list
|
|
|
- v.spec_attr = res.data.spec_attr
|
|
|
+ v.spec_list = res.data
|
|
|
+ v.spec_attr = res.data
|
|
|
+ v.num = v.goods_number
|
|
|
let data = JSON.parse(JSON.stringify(v))
|
|
|
this.popData = data
|
|
|
}
|
|
|
})
|
|
|
- console.log(this.popData, '********************');
|
|
|
+ console.log(this.popData,'this.popData');
|
|
|
this.$refs.popupGG.open();
|
|
|
this.setGoodsSpecPrice()
|
|
|
this.isAjax = false
|
|
|
@@ -286,30 +296,31 @@
|
|
|
spec_ids.sort((a, b) => a - b);
|
|
|
let spec_key = spec_ids.join('_')
|
|
|
this.popData.spec_key = spec_key
|
|
|
- console.log('this.popData.spec_list[spec_key]', this.popData.spec_list[spec_key])
|
|
|
- if (this.popData.spec_list[spec_key] !== undefined) {
|
|
|
- this.popData.price = this.popData.spec_list[spec_key].seckill_money > 0 ? this.popData.spec_list[
|
|
|
- spec_key].seckill_money : this.popData.spec_list[spec_key].price
|
|
|
- this.popData.line_price = this.popData.spec_list[spec_key].line_price
|
|
|
- if (this.popData.goods_spec_id !== this.popData.spec_list[spec_key].goods_spec_id + '') {
|
|
|
- this.popData.num = 1
|
|
|
- }
|
|
|
- this.popData.goods_spec_id = this.popData.spec_list[spec_key].goods_spec_id + ''
|
|
|
- let cartKey = this.cartData.goods_list.findIndex(row => this.popData.goods_spec_id * 1 === row
|
|
|
- .goods_spec_id * 1)
|
|
|
- if (cartKey >= 0) {
|
|
|
- this.popData.num = this.cartData.goods_list[cartKey].goods_number
|
|
|
- }
|
|
|
- } else {
|
|
|
- this.popData.line_price = '0.00'
|
|
|
- this.popData.price = '0.00'
|
|
|
- this.popData.num = 0
|
|
|
- this.popData.goods_spec_id = ''
|
|
|
- }
|
|
|
+ console.log(this.popData.spec_key, 'okokokokkoko');
|
|
|
+ console.log('this.popData.spec_attr[spec_key]', this.popData.spec_attr[spec_key])
|
|
|
+ // if (this.popData.spec_list[spec_key] !== undefined) {
|
|
|
+ // this.popData.price = this.popData.spec_list[spec_key].seckill_money > 0 ? this.popData.spec_list[
|
|
|
+ // spec_key].seckill_money : this.popData.spec_list[spec_key].price
|
|
|
+ // this.popData.line_price = this.popData.spec_list[spec_key].line_price
|
|
|
+ // if (this.popData.goods_spec_id !== this.popData.spec_list[spec_key].goods_spec_id + '') {
|
|
|
+ // this.popData.num = 1
|
|
|
+ // }
|
|
|
+ // this.popData.goods_spec_id = this.popData.spec_list[spec_key].goods_spec_id + ''
|
|
|
+ // let cartKey = this.cartData.goods_list.findIndex(row => this.popData.goods_spec_id * 1 === row
|
|
|
+ // .goods_spec_id * 1)
|
|
|
+ // if (cartKey >= 0) {
|
|
|
+ // this.popData.num = this.cartData.goods_list[cartKey].goods_number
|
|
|
+ // }
|
|
|
+ // } else {
|
|
|
+ // this.popData.line_price = '0.00'
|
|
|
+ // this.popData.price = '0.00'
|
|
|
+ // this.popData.num = 0
|
|
|
+ // this.popData.goods_spec_id = ''
|
|
|
+ // }
|
|
|
} else {
|
|
|
- this.popData.price = '0.00'
|
|
|
- this.popData.line_price = '0.00'
|
|
|
- this.popData.num = 0
|
|
|
+ // this.popData.price = '0.00'
|
|
|
+ // this.popData.line_price = '0.00'
|
|
|
+ this.popData.num = 1
|
|
|
this.popData.goods_spec_id = ''
|
|
|
}
|
|
|
},
|
|
|
@@ -327,7 +338,7 @@
|
|
|
let data = res.data
|
|
|
data.goods_list.forEach((v, k) => {
|
|
|
let ge = JSON.parse(JSON.stringify(v))
|
|
|
- ge.spec_ids = ge.spec_sku_id.split('_').map(item => Number(item.trim()))
|
|
|
+ ge.spec_ids = ge.goods_spec_id.split('_').map(item => Number(item.trim()))
|
|
|
ge.spec_name = ge.goods_attr.split(',').map(item => item.trim())
|
|
|
this.selectedSpecification.push(ge)
|
|
|
})
|
|
|
@@ -472,7 +483,8 @@
|
|
|
|
|
|
} else if (type === 3) {
|
|
|
// 选规格
|
|
|
- console.log(item)
|
|
|
+ console.log(item,'000000000')
|
|
|
+ console.log(this.selectedSpecification,'1111111111111');
|
|
|
this.selectedSpecification.forEach((v, k) => {
|
|
|
if (v.goods_id === item.goods_id) {
|
|
|
v.quota_num = item.quota_num
|
|
|
@@ -489,36 +501,31 @@
|
|
|
} else {
|
|
|
let data = JSON.parse(JSON.stringify(this.popData))
|
|
|
this.selectedSpecification.push(data)
|
|
|
- this.$refs.popupGG.close();
|
|
|
- console.log('this.popData.goods_spec_id')
|
|
|
- console.log(this.popData)
|
|
|
- console.log(this.selectedSpecification, 'this.___________________________');
|
|
|
- if (this.popData.goods_spec_id) {
|
|
|
- if (this.popData.is_infinite === 0 && this.popData.payNum > this.popData.stock) {
|
|
|
- tools.error('商品库存' + this.popData.stock + '件')
|
|
|
- this.popData.num = this.popData.stock
|
|
|
- } else if (this.popData.is_quota > 0 && this.popData.payNum > this.popData.quota_num) {
|
|
|
- tools.error('限购' + this.popData.quota_num + '件')
|
|
|
- this.popData.num = this.popData.quota_num
|
|
|
- } else {
|
|
|
- let cartKey = this.cartData.goods_list.findIndex(row => this.popData.goods_spec_id === row
|
|
|
- .goods_spec_id)
|
|
|
- console.log(cartKey)
|
|
|
- let addType = this.popData.num > 0 ? 2 : 1
|
|
|
- console.log('addType:' + addType)
|
|
|
- if (addType === 2 && cartKey < 0) {
|
|
|
- this.setShopIngAdd(this.popData.goods_id, this.popData.goodsItem.category_id, this.popData
|
|
|
- .goods_spec_id, this.popData.num)
|
|
|
- } else {
|
|
|
- this.setShopIngNumber(this.popData.goods_id, this.popData.goodsItem.category_id, type, this
|
|
|
- .popData
|
|
|
- .goods_spec_id, this.popData.num)
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
- console.log('无规格信息')
|
|
|
- }
|
|
|
+ console.log(this.popData, "666666666666666666")
|
|
|
+ console.log('1', this.popData.goods_id, this.shop_id, this.popData.goodsItem.category_id, this.popData.spec_key, this.popData.num);
|
|
|
+ this.setShoppingSave()
|
|
|
+ // if (this.popData.goods_spec_id) {
|
|
|
+ // if (this.popData.is_infinite === 0 && this.popData.payNum > this.popData.stock) {
|
|
|
+ // tools.error('商品库存' + this.popData.stock + '件')
|
|
|
+ // this.popData.num = this.popData.stock
|
|
|
+ // } else if (this.popData.is_quota > 0 && this.popData.payNum > this.popData.quota_num) {
|
|
|
+ // tools.error('限购' + this.popData.quota_num + '件')
|
|
|
+ // this.popData.num = this.popData.quota_num
|
|
|
+ // } else {
|
|
|
+ // let cartKey = this.cartData.goods_list.findIndex(row => this.popData.goods_spec_id === row.goods_spec_id)
|
|
|
+ // console.log(cartKey)
|
|
|
+ // let addType = this.popData.num > 0 ? 2 : 1
|
|
|
+ // console.log('addType:' + addType)
|
|
|
+ // if (addType === 2 && cartKey < 0) {
|
|
|
+ // this.setShopIngAdd(this.popData.goods_id, this.popData.goodsItem.category_id, this.popData
|
|
|
+ // .goods_spec_id, this.popData.num)
|
|
|
+ // } else {
|
|
|
+ // this.setShopIngNumber(this.popData.goods_id, this.popData.goodsItem.category_id, type, this.popData.goods_spec_id, this.popData.num)
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // } else {
|
|
|
+ // console.log('无规格信息')
|
|
|
+ // }
|
|
|
this.isAjax = false
|
|
|
}
|
|
|
},
|
|
|
@@ -533,6 +540,24 @@
|
|
|
this.setShopIngNumber(item.goods_id, item.category_id, type, '', 1, item)
|
|
|
}
|
|
|
},
|
|
|
+ setShoppingSave() {
|
|
|
+ shoppingSave({
|
|
|
+ type: 1,
|
|
|
+ goods_id: this.popData.goods_id,
|
|
|
+ shop_id: this.shop_id,
|
|
|
+ category_id: this.popData.goodsItem.category_id,
|
|
|
+ goods_spec_id: this.popData.spec_key,
|
|
|
+ number: this.popData.num
|
|
|
+ }).then((res) => {
|
|
|
+ if(res.code === 1) {
|
|
|
+ tools.success(res.msg)
|
|
|
+ this.$refs.popupGG.close();
|
|
|
+ this.getShopIngList()
|
|
|
+ } else {
|
|
|
+ tools.error(res.msg)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
setShopIngAdd(goodsId, categoryId, goodsSpecId, number, item) {
|
|
|
setShopIngAdd({
|
|
|
'type': 1,
|
|
|
@@ -604,20 +629,30 @@
|
|
|
setShopIngDel() {},
|
|
|
// -------弹窗选择规格-----------
|
|
|
selectSpec(info, groupKey) {
|
|
|
- let specKey = this.popData.spec_ids.indexOf(info.item_id)
|
|
|
+ let specKey = this.popData.spec_ids.indexOf(info.spec_id)
|
|
|
if (specKey >= 0) {
|
|
|
this.popData.spec_ids.splice(specKey, 1)
|
|
|
this.popData.spec_name.splice(specKey, 1)
|
|
|
+ if (Number(info.spec_price) > 0) {
|
|
|
+ this.popData.price = Number(this.popData.price) - Number(info.spec_price)
|
|
|
+ }
|
|
|
} else {
|
|
|
- this.popData.spec_ids.push(info.item_id)
|
|
|
- this.popData.spec_name.push(info.spec_value)
|
|
|
- for (const attrKey in this.popData.spec_attr[groupKey].spec_items) {
|
|
|
- if (this.popData.spec_attr[groupKey].spec_items[attrKey].item_id !== info.item_id) {
|
|
|
- let oldKey = this.popData.spec_ids.indexOf(this.popData.spec_attr[groupKey].spec_items[attrKey]
|
|
|
- .item_id)
|
|
|
+ this.popData.spec_ids.push(info.spec_id)
|
|
|
+ this.popData.spec_name.push(info.spec_name)
|
|
|
+ if (Number(info.spec_price) > 0) {
|
|
|
+ this.popData.price = Number(this.popData.price) + Number(info.spec_price)
|
|
|
+ }
|
|
|
+ for (const attrKey in this.popData.spec_attr[groupKey].spec_list) {
|
|
|
+ if (this.popData.spec_attr[groupKey].spec_list[attrKey].spec_id !== info.spec_id) {
|
|
|
+ let oldKey = this.popData.spec_ids.indexOf(this.popData.spec_attr[groupKey].spec_list[attrKey]
|
|
|
+ .spec_id)
|
|
|
if (oldKey >= 0) {
|
|
|
this.popData.spec_ids.splice(oldKey, 1)
|
|
|
this.popData.spec_name.splice(oldKey, 1)
|
|
|
+ if (Number(info.spec_price) > 0) {
|
|
|
+ this.popData.price = Number(this.popData.price) - Number(this.popData.spec_attr[
|
|
|
+ groupKey].spec_list[attrKey].spec_price)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -795,6 +830,10 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ .w-m {
|
|
|
+ width: calc(100% + 30rpx);
|
|
|
+ }
|
|
|
+
|
|
|
.spec-item {
|
|
|
min-width: 210rpx;
|
|
|
height: 66rpx;
|
|
|
@@ -805,9 +844,9 @@
|
|
|
padding: 0 10rpx;
|
|
|
}
|
|
|
|
|
|
- .spec-item:nth-child(3) {
|
|
|
- margin-right: 0rpx !important;
|
|
|
- }
|
|
|
+ // .spec-item:nth-child(3) {
|
|
|
+ // margin-right: 0rpx !important;
|
|
|
+ // }
|
|
|
|
|
|
.s-item {
|
|
|
background-color: #ECF7FE;
|