Commit 0de878e9 authored by Xuguangxing's avatar Xuguangxing

'增加trycache'

parent af0ee5be
...@@ -213,52 +213,56 @@ export default { ...@@ -213,52 +213,56 @@ export default {
}, },
async init(detailParam) { async init(detailParam) {
const [res] = await goods.detailInfo(detailParam); const [res] = await goods.detailInfo(detailParam);
firstGroupShare(
{
...this.$route.query,
skuName: res.goodsName,
skuImg: res.thumbImageUrl
},
2
);
if (res.groupBuyInfo.groupId) {
// localStorage.set('groupBuyGroupId', res.groupBuyInfo.groupId || ''); // 设置groupBuyGroupId,用于下单
this.groupId = +res.groupBuyInfo.groupId || '';
}
if (res.saleCount && res.activitySkuTotalCount) {
const percentage =
(+res.activitySkuTotalCount - +res.saleCount) / +res.activitySkuTotalCount;
if (isNaN(percentage)) {
this.stockPercentage = 0;
} else {
this.stockPercentage = Math.floor(percentage) >= 1 ? 100 : Math.floor(percentage * 100);
}
console.log(this.stockPercentage);
}
this.imgList = res.imageUrl || [];
this.detailInfo = res;
this.setStartStatus(res);
try { try {
this.detailInfo.contentDetailUrl = this.detailInfo.contentDetailUrl.replace( firstGroupShare(
'http://', {
'https://' ...this.$route.query,
skuName: res.goodsName,
skuImg: res.thumbImageUrl
},
2
); );
const detailImages = await goods.getDetailPic(this.detailInfo.contentDetailUrl); if (res.groupBuyInfo.groupId) {
console.log(detailImages); // localStorage.set('groupBuyGroupId', res.groupBuyInfo.groupId || ''); // 设置groupBuyGroupId,用于下单
// const imgReg = new RegExp('(?<=src=").[^"]*', 'g'); this.groupId = +res.groupBuyInfo.groupId || '';
// this.detailImgList = (detailImages || '').match(imgReg); }
let imgReg = /<img.*?(?:>|\/>)/gi; if (res.saleCount && res.activitySkuTotalCount) {
// eslint-disable-next-line no-useless-escape const percentage =
let srcReg = /src=[\'"]?([^\'"]*)[\'"]?/i; (+res.activitySkuTotalCount - +res.saleCount) / +res.activitySkuTotalCount;
let arr = (detailImages || '').match(imgReg); if (isNaN(percentage)) {
let srcArr = []; this.stockPercentage = 0;
for (let i = 0; i < arr.length; i++) { } else {
let src = arr[i].match(srcReg)[1].replace('http://', 'https://'); this.stockPercentage = Math.floor(percentage) >= 1 ? 100 : Math.floor(percentage * 100);
srcArr.push(src); }
console.log(this.stockPercentage);
}
this.imgList = res.imageUrl || [];
this.detailInfo = res;
this.setStartStatus(res);
try {
this.detailInfo.contentDetailUrl = this.detailInfo.contentDetailUrl.replace(
'http://',
'https://'
);
const detailImages = await goods.getDetailPic(this.detailInfo.contentDetailUrl);
console.log(detailImages);
// const imgReg = new RegExp('(?<=src=").[^"]*', 'g');
// this.detailImgList = (detailImages || '').match(imgReg);
let imgReg = /<img.*?(?:>|\/>)/gi;
// eslint-disable-next-line no-useless-escape
let srcReg = /src=[\'"]?([^\'"]*)[\'"]?/i;
let arr = (detailImages || '').match(imgReg);
let srcArr = [];
for (let i = 0; i < arr.length; i++) {
let src = arr[i].match(srcReg)[1].replace('http://', 'https://');
srcArr.push(src);
}
this.detailImgList = srcArr;
} catch (error) {
console.error(error);
} }
this.detailImgList = srcArr; } catch (e) {
} catch (error) { console.log(e);
console.error(error);
} }
}, },
setStartStatus(data) { setStartStatus(data) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment