修改进入详情页的默认选中规格
This commit is contained in:
parent
b70b3a40df
commit
ec51286a1e
@ -317,34 +317,35 @@ import {
|
|||||||
} from "../../../utils";
|
} from "../../../utils";
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
picUrl,
|
picUrl,
|
||||||
top: "",
|
top: "",
|
||||||
localHeight: "",
|
localHeight: "",
|
||||||
carNum: "",
|
carNum: "",
|
||||||
prevCarNum: "",
|
prevCarNum: "",
|
||||||
currentNum: "0", //当前商品的数量
|
currentNum: "0", //当前商品的数量
|
||||||
type: "error",
|
type: "error",
|
||||||
boxshadow1: false,
|
boxshadow1: false,
|
||||||
boxshadow2: false,
|
boxshadow2: false,
|
||||||
id: "184",
|
id: "184",
|
||||||
info: "",
|
info: "",
|
||||||
currentIndex: "1", //当前轮播图
|
currentIndex: "1", //当前轮播图
|
||||||
|
|
||||||
currentGG: "", //当前选中规格
|
currentGG: "", //当前选中规格
|
||||||
currentGGIndex: "", //当前规格index
|
currentGGIndex: "", //当前规格index
|
||||||
|
|
||||||
carOrderList: [],
|
carOrderList: [],
|
||||||
// 新增评论数据
|
// 新增评论数据
|
||||||
showReviewPopup: false,
|
showReviewPopup: false,
|
||||||
comments: [],
|
comments: [],
|
||||||
show: false,
|
show: false,
|
||||||
showSize: false,
|
showSize: false,
|
||||||
|
|
||||||
changeImg: "",
|
changeImg: "",
|
||||||
changeName: "",
|
changeName: "",
|
||||||
changePrice: "",
|
changePrice: "",
|
||||||
};
|
selectedGoods: null, // 保存传入的商品规格信息
|
||||||
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
changeIndex(e) {
|
changeIndex(e) {
|
||||||
@ -454,10 +455,21 @@ export default {
|
|||||||
}
|
}
|
||||||
this.info = res;
|
this.info = res;
|
||||||
console.log("this.info", this.info.commodity_goods_info_list);
|
console.log("this.info", this.info.commodity_goods_info_list);
|
||||||
// {{info.commodity_goods_info_list[currentGGIndex].cart_count.count}}
|
|
||||||
this.currentGG = res.commodity_goods_info_list[0];
|
// 检查是否有传入的选中商品信息,如果有则设置为默认选中
|
||||||
|
let selectedIndex = 0;
|
||||||
|
if (this.selectedGoods) {
|
||||||
|
for (let i = 0; i < res.commodity_goods_info_list.length; i++) {
|
||||||
|
if (res.commodity_goods_info_list[i].id === this.selectedGoods.id) {
|
||||||
|
selectedIndex = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.currentGG = res.commodity_goods_info_list[selectedIndex];
|
||||||
console.log("this.currentGG", this.currentGG);
|
console.log("this.currentGG", this.currentGG);
|
||||||
this.currentGGIndex = 0;
|
this.currentGGIndex = selectedIndex;
|
||||||
|
|
||||||
this.changeImg = picUrl + this.currentGG.commodity_pic[0]
|
this.changeImg = picUrl + this.currentGG.commodity_pic[0]
|
||||||
this.changeName = this.currentGG.goods_alias
|
this.changeName = this.currentGG.goods_alias
|
||||||
@ -480,7 +492,6 @@ export default {
|
|||||||
|
|
||||||
// 切换规格
|
// 切换规格
|
||||||
changeGG(item, index) {
|
changeGG(item, index) {
|
||||||
console.log("🚀 ~ changeGG ~ item:", item);
|
|
||||||
this.currentGG = item;
|
this.currentGG = item;
|
||||||
this.currentGGIndex = index;
|
this.currentGGIndex = index;
|
||||||
if (this.currentGG.cart_count) {
|
if (this.currentGG.cart_count) {
|
||||||
@ -622,15 +633,15 @@ export default {
|
|||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},onLoad(options) {
|
||||||
onLoad(options) {
|
|
||||||
console.log(JSON.parse(decodeURIComponent(options.item)));
|
|
||||||
const itemObj = JSON.parse(decodeURIComponent(options.item));
|
const itemObj = JSON.parse(decodeURIComponent(options.item));
|
||||||
const meun = menuButtonInfo();
|
const meun = menuButtonInfo();
|
||||||
this.top = meun.top;
|
this.top = meun.top;
|
||||||
this.localHeight = meun.height;
|
this.localHeight = meun.height;
|
||||||
|
|
||||||
this.id = itemObj.id;
|
|
||||||
|
this.id = itemObj.commodity_id ? itemObj.commodity_id : itemObj.id;
|
||||||
|
this.selectedGoods = itemObj; // 保存传入的完整商品信息
|
||||||
},
|
},
|
||||||
onReachBottom() { },
|
onReachBottom() { },
|
||||||
onShow() {
|
onShow() {
|
||||||
|
|||||||
@ -152,7 +152,7 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="GGList" v-if="items.isShow">
|
<view class="GGList" v-if="items.isShow">
|
||||||
<view class="GGItem" v-for="ite in items.commodity_goods_info_list" :key="ite.id" @click="goods(items)">
|
<view class="GGItem" v-for="ite in items.commodity_goods_info_list" :key="ite.id" @click="goods(ite,items)">
|
||||||
<view class="GGItem_Image">
|
<view class="GGItem_Image">
|
||||||
<view class="tag tag-img" v-if="ite.is_same_day">当日达</view>
|
<view class="tag tag-img" v-if="ite.is_same_day">当日达</view>
|
||||||
<image :src="picUrl + ite.commodity_pic" mode="aspectFill"></image>
|
<image :src="picUrl + ite.commodity_pic" mode="aspectFill"></image>
|
||||||
@ -362,9 +362,8 @@ export default {
|
|||||||
NavgateTo("../search/index");
|
NavgateTo("../search/index");
|
||||||
},
|
},
|
||||||
//商品详情页
|
//商品详情页
|
||||||
goods(e) {
|
goods(ite,items) {
|
||||||
NavgateTo(`../goods/index?item=${JSON.stringify(e)}`);
|
NavgateTo(`../goods/index?item=${JSON.stringify(ite)}`);
|
||||||
// NavgateTo("../goods/index");
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// 购物车
|
// 购物车
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user