|
|
@@ -348,49 +348,57 @@ export default {
|
|
|
// 获取普通商品信息
|
|
|
if (obj.goodsType == 0) {
|
|
|
goodsDetail({}, this.goodsid).then(function({ data }) {
|
|
|
- obj.list = data;
|
|
|
- console.log(obj.list, '普通商品数据');
|
|
|
- obj.good_list = data.good_list; //保存猜你喜欢列表
|
|
|
- obj.reply = data.reply; //保存评论列表
|
|
|
- let goods = data.storeInfo;
|
|
|
- if (goods.is_drop == 1) {
|
|
|
- obj.showAdd = false;
|
|
|
- obj.showDrop = true;
|
|
|
- obj.is_drop = true
|
|
|
- }
|
|
|
- obj.goodsObjact = goods;
|
|
|
- if (obj.goodsObjact.description != null) {
|
|
|
- obj.description = obj.goodsObjact.description.replace(/\<img/gi, '<img class="rich-img"');
|
|
|
- } //小程序商品详情图超出屏幕问题
|
|
|
- obj.imgList = goods.slider_image; //保存轮播图
|
|
|
- obj.specList = data.productAttr; //保存分类列表
|
|
|
- if (Array.isArray(data.productValue) != true) {
|
|
|
- obj.many = 2;
|
|
|
- obj.specList = data.productAttr; //保存产品属性
|
|
|
- obj.productValue = data.productValue; //保存属性值
|
|
|
- obj.specSelected = []; //初始化默认选择对象
|
|
|
- for (let i = 0; i < obj.specList.length; i++) {
|
|
|
- // 设置默认数据
|
|
|
- let attrValue = obj.specList[i].attr_value[0];
|
|
|
- attrValue.check = true;
|
|
|
- obj.specSelected.push(attrValue.attr);
|
|
|
+ try {
|
|
|
+ obj.list = data;
|
|
|
+ console.log(obj.list, '普通商品数据');
|
|
|
+ obj.good_list = data.good_list; //保存猜你喜欢列表
|
|
|
+ obj.reply = data.reply; //保存评论列表
|
|
|
+ let goods = data.storeInfo;
|
|
|
+ if (goods.is_drop == 1) {
|
|
|
+ obj.showAdd = false;
|
|
|
+ obj.showDrop = true;
|
|
|
+ obj.is_drop = true;
|
|
|
}
|
|
|
- let str = obj.specSelected.join(',');
|
|
|
- console.log(str, 'str');
|
|
|
- // 设置默认值
|
|
|
- obj.actionPrice = obj.productValue[str].price;
|
|
|
- obj.goodsNumberMax = obj.productValue[str].stock;
|
|
|
- obj.actionImage = obj.productValue[str].image;
|
|
|
- obj.uniqueId = obj.productValue[str].unique;
|
|
|
- obj.goodsStore = obj.productValue[str].stock;
|
|
|
- } else {
|
|
|
- obj.many = 1;
|
|
|
+ obj.goodsObjact = goods;
|
|
|
+ if (obj.goodsObjact.description != null) {
|
|
|
+ obj.description = obj.goodsObjact.description.replace(/\<img/gi, '<img class="rich-img"');
|
|
|
+ } //小程序商品详情图超出屏幕问题
|
|
|
+ obj.imgList = goods.slider_image; //保存轮播图
|
|
|
+ obj.specList = data.productAttr; //保存分类列表
|
|
|
+ if (Array.isArray(data.productValue) != true) {
|
|
|
+ obj.many = 2;
|
|
|
+ obj.specList = data.productAttr; //保存产品属性
|
|
|
+ obj.productValue = data.productValue; //保存属性值
|
|
|
+ obj.specSelected = []; //初始化默认选择对象
|
|
|
+ const str = ''; //保存当前选中的默认对象
|
|
|
+ for (let i = 0; i < obj.specList.length; i++) {
|
|
|
+ // 设置默认数据
|
|
|
+ const ls = obj.specList[i].attr_value;
|
|
|
+ for (let s = 0; s < ls.length; i++) {
|
|
|
+ if (ls[s].check) {
|
|
|
+ obj.specSelected.push(ls[s].attr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ console.log(str, 'str');
|
|
|
+ // 设置默认值
|
|
|
+ obj.actionPrice = obj.productValue[str].price;
|
|
|
+ obj.goodsNumberMax = obj.productValue[str].stock;
|
|
|
+ obj.actionImage = obj.productValue[str].image;
|
|
|
+ obj.uniqueId = obj.productValue[str].unique;
|
|
|
+ obj.goodsStore = obj.productValue[str].stock;
|
|
|
+ } else {
|
|
|
+ obj.many = 1;
|
|
|
+ }
|
|
|
+ obj.productValue = data.productValue; //保存分类查询数据
|
|
|
+ obj.actionPrice = goods.price; //保存默认选中商品价格
|
|
|
+ obj.actionImage = goods.image_base; //保存默认选中商品图片
|
|
|
+ obj.goodsNumberMax = goods.stock; //保存默认选中最大可购买商品数量
|
|
|
+ obj.shopId = data.mer_id; //保存商店id
|
|
|
+ } catch (e) {
|
|
|
+ console.log(e);
|
|
|
+ //TODO handle the exception
|
|
|
}
|
|
|
- obj.productValue = data.productValue; //保存分类查询数据
|
|
|
- obj.actionPrice = goods.price; //保存默认选中商品价格
|
|
|
- obj.actionImage = goods.image_base; //保存默认选中商品图片
|
|
|
- obj.goodsNumberMax = goods.stock; //保存默认选中最大可购买商品数量
|
|
|
- obj.shopId = data.mer_id; //保存商店id
|
|
|
});
|
|
|
}
|
|
|
// 获取秒杀商品信息
|