|
@@ -124,15 +124,20 @@
|
|
<image :src="nuberImg"></image>
|
|
<image :src="nuberImg"></image>
|
|
<view class="right">
|
|
<view class="right">
|
|
<text class="price" style="font-size: 36upx;color: #303133">{{datalist.goods_price}}</text>
|
|
<text class="price" style="font-size: 36upx;color: #303133">{{datalist.goods_price}}</text>
|
|
- <view class="selected" v-if="specSelected.length > 0">
|
|
|
|
- <text class="selected-text" v-for="(sItem, sIndex) in specSelected" :key="sIndex">
|
|
|
|
- {{sItem.value_name}}X {{shopnumber}}
|
|
|
|
- </text>
|
|
|
|
- </view>
|
|
|
|
- <view class="selected" v-else>
|
|
|
|
- <text class="selected-text">
|
|
|
|
- 请选择规格数量
|
|
|
|
- </text>
|
|
|
|
|
|
+ <view v-if="datalist.spec_list.length > 0 ">
|
|
|
|
+ <view class="selected" v-if="specSelected.length > 0 ">
|
|
|
|
+ <text class="selected-text" v-for="(sItem, sIndex) in specSelected" :key="sIndex">
|
|
|
|
+ {{sItem.value_name}}X {{shopnumber}}
|
|
|
|
+ </text>
|
|
|
|
+ </view>
|
|
|
|
+ <view class="selected" v-else>
|
|
|
|
+ <text class="selected-text">
|
|
|
|
+ 请选择规格数量
|
|
|
|
+ </text>
|
|
|
|
+ </view>
|
|
|
|
+ </view>
|
|
|
|
+ <view v-else>
|
|
|
|
+ X {{shopnumber}}
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view @click="closeCar" style="position: absolute;right: 10%;">
|
|
<view @click="closeCar" style="position: absolute;right: 10%;">
|
|
@@ -195,14 +200,14 @@
|
|
cartnumber: 0, // 购物车数量
|
|
cartnumber: 0, // 购物车数量
|
|
changnumber: 100,
|
|
changnumber: 100,
|
|
ismax: false, // 输入狂禁止数量
|
|
ismax: false, // 输入狂禁止数量
|
|
- goods_storage: 0, // 规格商品参数
|
|
|
|
|
|
+ goods_storage: '', // 规格商品参数
|
|
nuberImg:'',
|
|
nuberImg:'',
|
|
shopnumber: 1,
|
|
shopnumber: 1,
|
|
pictureUrl: this.pictureUrl,
|
|
pictureUrl: this.pictureUrl,
|
|
datalist: {},
|
|
datalist: {},
|
|
store_id: 0, // 酒店id
|
|
store_id: 0, // 酒店id
|
|
goodId: 0, // 商品公共id
|
|
goodId: 0, // 商品公共id
|
|
- goods_id: 0, // 商品相信id
|
|
|
|
|
|
+ goods_id: 0, // 商品规格id
|
|
windowHeight: 0, // 窗口高度
|
|
windowHeight: 0, // 窗口高度
|
|
iScrolltop: 1,
|
|
iScrolltop: 1,
|
|
active: 0,
|
|
active: 0,
|
|
@@ -275,23 +280,29 @@
|
|
},
|
|
},
|
|
// 获取商品详情
|
|
// 获取商品详情
|
|
getshopdetail() {
|
|
getshopdetail() {
|
|
- let _this = this;
|
|
|
|
let params = {};
|
|
let params = {};
|
|
- params.goods_commonid =_this.goodId;
|
|
|
|
- params.store_id = _this.store_id;
|
|
|
|
|
|
+ params.goods_commonid =this.goodId;
|
|
|
|
+ params.store_id = this.store_id;
|
|
this.request({
|
|
this.request({
|
|
url:'/v2/goods/detail',
|
|
url:'/v2/goods/detail',
|
|
method:'POST',
|
|
method:'POST',
|
|
data: params,
|
|
data: params,
|
|
- success: function(res) {
|
|
|
|
|
|
+ success: (res)=> {
|
|
let { data } = res.data;
|
|
let { data } = res.data;
|
|
- _this.cartnumber = data.cart;
|
|
|
|
- _this.has_collected = data.has_collected;
|
|
|
|
|
|
+ this.cartnumber = data.cart;
|
|
|
|
+ this.has_collected = data.has_collected;
|
|
let array = data;
|
|
let array = data;
|
|
- array.spec_list[0].value_list.forEach( (item,idx) => {
|
|
|
|
- item.goods_storage = data.goods_list[idx].goods_storage;
|
|
|
|
- })
|
|
|
|
- _this.datalist = array;
|
|
|
|
|
|
+ if(array.spec_list.length == 0) {
|
|
|
|
+ this.datalist = data;
|
|
|
|
+ this.goods_id = data.goods_list[0].goods_id;
|
|
|
|
+ this.goods_storage = data.goods_storage;
|
|
|
|
+ }else {
|
|
|
|
+ array.spec_list[0].value_list.forEach( (item,idx) => {
|
|
|
|
+ item.goods_storage = data.goods_list[idx].goods_storage;
|
|
|
|
+ })
|
|
|
|
+ this.datalist = array;
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
})
|
|
})
|
|
},
|
|
},
|
|
@@ -346,8 +357,7 @@
|
|
// 加入购物车
|
|
// 加入购物车
|
|
addCar() {
|
|
addCar() {
|
|
if(this.hasLogin) {
|
|
if(this.hasLogin) {
|
|
-
|
|
|
|
- if(this.specSelected.length == 0) {
|
|
|
|
|
|
+ if(this.specSelected.length == 0 && this.datalist.spec_list.length != 0) {
|
|
this.specClass = 'show';
|
|
this.specClass = 'show';
|
|
this.$msg("请选择规格数量");
|
|
this.$msg("请选择规格数量");
|
|
return;
|
|
return;
|
|
@@ -384,6 +394,7 @@
|
|
},
|
|
},
|
|
//选择规格
|
|
//选择规格
|
|
selectSpec(index, pid,value_name,goods_storage){
|
|
selectSpec(index, pid,value_name,goods_storage){
|
|
|
|
+ this.specSelected = [];
|
|
if(goods_storage == 0) {
|
|
if(goods_storage == 0) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -395,38 +406,58 @@
|
|
this.$set(item, 'selected', false);
|
|
this.$set(item, 'selected', false);
|
|
}
|
|
}
|
|
})
|
|
})
|
|
- let obj = {};
|
|
|
|
- obj.firstId = index;
|
|
|
|
- obj.pid = pid;
|
|
|
|
- this.arrayId.push(obj);
|
|
|
|
- let arr = this.arrayId;
|
|
|
|
- for(var i=0; i<arr.length; i++){
|
|
|
|
- for(var j=i+1; j<arr.length; j++){
|
|
|
|
- if(arr[i].firstId==arr[j].firstId){
|
|
|
|
- arr.splice(j,1);
|
|
|
|
- j--;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- let newarray = []
|
|
|
|
- arr.forEach(item => {
|
|
|
|
- newarray.push(item.pid);
|
|
|
|
- })
|
|
|
|
- this.arrayId = arr;
|
|
|
|
- if(this.arrayId.length == 0) {
|
|
|
|
- this.scopemapId = newarray.toString(); ;
|
|
|
|
- }else {
|
|
|
|
- this.scopemapId = newarray.join("_");
|
|
|
|
|
|
+ let array = [];
|
|
|
|
+ for(let i = 0; i < this.datalist.spec_list.length; i++) {
|
|
|
|
+ for(let j = 0; j<this.datalist.spec_list[i].value_list.length;j++) {
|
|
|
|
+ if(this.datalist.spec_list[i].value_list[j].selected) {
|
|
|
|
+ array.push(this.datalist.spec_list[i].value_list[j].value_id);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ this.arrayId = array;
|
|
|
|
+ if(this.arrayId.length == this.datalist.spec_list.length) {
|
|
|
|
+ console.log("进来了")
|
|
|
|
+ this.scopemapId = array.join("_");
|
|
|
|
+ let goodId = this.datalist.spec_map[this.scopemapId]; //
|
|
|
|
+ let items = this.datalist.goods_list[goodId]
|
|
|
|
+ items.value_name = value_name;
|
|
|
|
+ this.nuberImg = items.spec_img;
|
|
|
|
+ this.specSelected.push(items)
|
|
|
|
+ this.goods_storage = items.goods_storage;
|
|
|
|
+ this.goods_id = items.goods_id;
|
|
}
|
|
}
|
|
- this.datalist.spec_list[index].value_list = list;
|
|
|
|
- let goodId = this.datalist.spec_map[this.scopemapId]; //
|
|
|
|
- let items = this.datalist.goods_list[goodId]
|
|
|
|
- items.value_name = value_name;
|
|
|
|
- this.nuberImg = items.spec_img;
|
|
|
|
- this.specSelected = [];
|
|
|
|
- this.specSelected.push(items)
|
|
|
|
- this.goods_storage = items.goods_storage;
|
|
|
|
- this.goods_id = items.goods_id;
|
|
|
|
|
|
+
|
|
|
|
+ // if(this.arrayId.length == this.datalist.spec_list.length) {
|
|
|
|
+
|
|
|
|
+ // }
|
|
|
|
+
|
|
|
|
+ // let obj = {};
|
|
|
|
+ // obj.firstId = index;
|
|
|
|
+ // obj.pid = pid;
|
|
|
|
+ // this.arrayId.push(obj);
|
|
|
|
+ // console.log(this.arrayId)
|
|
|
|
+ // let arr = this.arrayId;
|
|
|
|
+ // for(var i=0; i<arr.length; i++){
|
|
|
|
+ // for(var j=i+1; j<arr.length; j++){
|
|
|
|
+ // if(arr[i].firstId==arr[j].firstId){
|
|
|
|
+ // arr.splice(j,1);
|
|
|
|
+ // j--;
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ // let newarray = []
|
|
|
|
+ // arr.forEach(item => {
|
|
|
|
+ // newarray.push(item.pid);
|
|
|
|
+ // })
|
|
|
|
+ // this.arrayId = arr;
|
|
|
|
+ // if(this.arrayId.length == 0) {
|
|
|
|
+ // this.scopemapId = newarray.toString(); ;
|
|
|
|
+ // }else {
|
|
|
|
+ // this.scopemapId = newarray.join("_");
|
|
|
|
+ // }
|
|
|
|
+ // console.log(this.scopemapId);
|
|
|
|
+ //this.datalist.spec_list[index].value_list = list;
|
|
|
|
+
|
|
|
|
|
|
},
|
|
},
|
|
// 滚动到顶部
|
|
// 滚动到顶部
|