Authored by shuaiguo

feat(feature): 优惠券状态查询并修改

/* eslint-disable indent */
/* eslint-disable comma-spacing */
/* eslint-disable keyword-spacing */
/* eslint-disable quotes */
... ... @@ -282,7 +283,7 @@ class featureModel extends global.yoho.BaseModel {
/**
* 限时抢券时间转换
*/
_formatSeckillCouponTime(featureData = {}) {
_formatSeckillCouponTime(featureData = {}) {
const {floors = []} = featureData;
const seckillCouponFloor = floors.find(floor=> {
... ... @@ -373,9 +374,8 @@ class featureModel extends global.yoho.BaseModel {
floor.component = component.map(c=> {
if(c.type === 'coupon' && colNum === 1) {
const statusImg = seckillCouponStatusInfo[status];
return {...c, startTime, endOfDayTime, currentTime, status, statusImg};
return {...c, startTime, endOfDayTime, currentTime, status, statusImg: seckillCouponStatusInfo};
}else {
return c;
}
... ...
... ... @@ -135,7 +135,10 @@
{{#isEqualOr seckillCoupon '1'}}
{{#if statusImg}}
<div class="status-img">
<img src="{{statusImg}}"/>
<img
{{#isEqualOr status 'begin'}}id="{{token}}"{{/isEqualOr}}
data-status-imgs="{{stringify statusImg}}"
src="{{getKeyValue statusImg status}}"/>
</div>
{{/if}}
{{!-- yoho-conpon 领券 --}}
... ...
... ... @@ -133,7 +133,9 @@ module.exports = {
notifyUrl: domains.service + 'payment/weixin_notify',
},
geetestJs: '//static.geetest.com/static/tools/gt.js',
jsSdk: '//cdn.yoho.cn/js-sdk/1.3.24/jssdk.js',
// jsSdk: '//cdn.yoho.cn/js-sdk/1.3.24/jssdk.js',
jsSdk: 'https://cdn.yoho.cn/js-sdk/1.3.25-beta-2/jssdk.js',
redis: {
connect: {
host: '192.168.102.49',
... ...
{
"name": "yohobuywap-node-activity",
"version": "6.9.15-22",
"version": "6.9.15-23",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ...
... ... @@ -1383,6 +1383,42 @@ function seckillCouponTimeTask() {
}
}
// 限时抢券 优惠券已抢光状态
function couponSendFinished() {
let activityId = JSON.parse($('.activity-id').val());
let templateId = JSON.parse($('.template-id').val());
let data = {
activityId,
templateId
};
$.ajax({
url: '//m.yohobuy.com/activity/feature/coupon/send/info',
dataType: 'jsonp',
data
}).then((res)=> {
if(res.code === 200) {
res.data.forEach(coupon => {
const { token, sendFinished } = coupon;
// 1: 已发完 0: 未发完
if(sendFinished) {
let $img = $(`#${token}`);
if($img) {
let statusImgs = $img.data('status-imgs');
if(statusImgs) {
$img.attr('src', statusImgs.end);
}
}
}
});
}
});
}
// 活动计划动态刷新
function activityPlan() {
let atlBo = $('.activity-plan').val();
... ... @@ -1555,4 +1591,7 @@ $(function() {
// 限时抢券定时任务
seckillCouponTimeTask();
// couponSendFinished
couponSendFinished();
});
... ...
... ... @@ -309,5 +309,8 @@ module.exports = {
return s;
}
});
},
getKeyValue(obj = {}, key) {
return obj[key] || '';
}
};
... ...