...
|
...
|
@@ -396,12 +396,19 @@ function timedCutProductInit() { |
|
|
return;
|
|
|
}
|
|
|
|
|
|
getGoodsInfo(selfObj.skn).then(function(res) {
|
|
|
if (res.code !== 200 || !res.data || !res.data.length) {
|
|
|
$.ajax({
|
|
|
url: '//m.yohobuy.com/activity/feature/goods/detail',
|
|
|
dataType: 'jsonp',
|
|
|
data: {
|
|
|
skn: selfObj.skn
|
|
|
}
|
|
|
}).then(function(res) {
|
|
|
if (res.code !== 200 || !res.data) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
selfObj.changeNowPrice && selfObj.changeNowPrice(res.data[0].saleprice);
|
|
|
selfObj.saleprice = res.data.sales_price;
|
|
|
selfObj.changeNowPrice && selfObj.changeNowPrice(selfObj.saleprice);
|
|
|
});
|
|
|
}
|
|
|
|
...
|
...
|
@@ -413,7 +420,6 @@ function timedCutProductInit() { |
|
|
let time = res.timestamp || Date.parse(new Date()) / 1000;
|
|
|
let list = {};
|
|
|
|
|
|
|
|
|
res.data.forEach(value => {
|
|
|
list[value.product_skn] = value;
|
|
|
});
|
...
|
...
|
@@ -442,6 +448,7 @@ function timedCutProductInit() { |
|
|
plan.push(val);
|
|
|
});
|
|
|
|
|
|
value.plan = plan; // 降价计划
|
|
|
value.curEndTime = 0; // 当前价格档结束时间
|
|
|
value.saleprice = info.saleprice; // 商品售价
|
|
|
});
|
...
|
...
|
@@ -477,7 +484,7 @@ function timedCutProductInit() { |
|
|
}
|
|
|
|
|
|
let curPrice;
|
|
|
let isEndPlan;
|
|
|
let changePriceStatus;
|
|
|
|
|
|
value.changeBtnClass(2);
|
|
|
|
...
|
...
|
@@ -485,6 +492,8 @@ function timedCutProductInit() { |
|
|
let curEndTime,
|
|
|
curStartTime;
|
|
|
|
|
|
changePriceStatus = 1;
|
|
|
|
|
|
value.plan.forEach((val, index) => {
|
|
|
if (!curEndTime && val.end_time - time > 0) {
|
|
|
curEndTime = +val.end_time;
|
...
|
...
|
@@ -492,32 +501,39 @@ function timedCutProductInit() { |
|
|
curPrice = +val.current_saleprice;
|
|
|
|
|
|
if (!value.plan[index + 1]) {
|
|
|
isEndPlan = 1;
|
|
|
value.isEndPlan = 1;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
// 取不到下一档时价格恢复售价
|
|
|
curPrice = curPrice || value.saleprice;
|
|
|
// 未匹配到降价档则设为最后一档
|
|
|
if (!curEndTime) {
|
|
|
value.isEndPlan = 1;
|
|
|
}
|
|
|
|
|
|
value.curStartTime = curStartTime;
|
|
|
value.curEndTime = curEndTime;
|
|
|
value.curStartTime = curStartTime || value.startTime;
|
|
|
value.curEndTime = curEndTime || value.endTime;
|
|
|
}
|
|
|
|
|
|
let limitTime;
|
|
|
let isEndPlan = value.isEndPlan;
|
|
|
|
|
|
if (time >= value.curStartTime) {
|
|
|
limitTime = value.curEndTime - time;
|
|
|
} else {
|
|
|
// 执行变价时从接口获取当前实时售价
|
|
|
if (!changePriceStatus) {
|
|
|
updateProductPriceBySkn(value);
|
|
|
}
|
|
|
|
|
|
// 当前降价未开始时价格恢复售价
|
|
|
curPrice = value.saleprice;
|
|
|
limitTime = value.curStartTime - time;
|
|
|
isEndPlan = 0;
|
|
|
updateProductPriceBySkn(value);
|
|
|
}
|
|
|
|
|
|
value.changeNowPrice(curPrice);
|
|
|
value.$time.text(`距离${isEndPlan ? '活动结束' : '下次降价'}还剩 ${convertTime(limitTime)}`);
|
|
|
value.changeNowPrice(curPrice || value.saleprice);
|
|
|
value.$time.text(`距离${isEndPlan > 0 ? '活动结束' : '下次降价'}还剩 ${convertTime(limitTime)}`);
|
|
|
} else { // 【活动未开始】
|
|
|
value.changeBtnClass(1);
|
|
|
value.changeNowPrice(value.saleprice);
|
...
|
...
|
|