Authored by wenjiekong

添加优惠券状态判断

... ... @@ -94,7 +94,7 @@ exports.userAcquireStatus = (req, res, next) => {
if (!req.user.uid) {
uid = '';
}else {
} else {
uid = req.user.uid;
}
... ...
... ... @@ -153,8 +153,8 @@ exports.verifyStudents = (params) => {
/**
* 获取优惠券领取状态
* @params
* @return
* @params
* @return
*/
exports.userAcquireStatus = (uid, couponIds) => {
return studentsApi.userAcquireStatus(uid, couponIds).
... ...
... ... @@ -564,10 +564,10 @@ $('.ident-select-wrap').one('click', function() {
*埋点
*/
$(function() {
//加载优惠券状态
// 加载优惠券状态
var couponIds = '';
$('.coupon > a').each(function(){
$('.coupon > a').each(function() {
couponIds += $(this).attr('data-id') + ',';
});
... ... @@ -575,43 +575,45 @@ $(function() {
type: 'GET',
url: '/product/students/userAcquireStatus',
data: {
couponIds: couponIds.substring(0,couponIds.length-1)
couponIds: couponIds.substring(0, couponIds.length - 1)
},
success: function(res) {
var code = res.code;
var code = res.code,
i,
text;
console.info(res);
if (code == 200) {
for (var i = 0; i < res.data.length; i++) {
var text = '';
if (code === 200) {
for (i = 0; i < res.data.length; i++) {
text = '';
if (res.data[i].status === 1) {
text = '<div class="normal">' +
text = '<div class="normal">' +
'<p>点击</p>' +
'<p>领取</p>' +
'</div>';
}
if (res.data[i].status === 2) {
text = '<div class="empty">' +
text = '<div class="empty">' +
'<p>已抢光</p>' +
'<p class="guang">去逛逛</p>' +
'</div>';
}
if (res.data[i].status === 3) {
text = '<div class="got">' +
text = '<div class="got">' +
'<p>已领取</p>' +
'<p class="guang">去使用</p>' +
'</div>';
}
if (res.data[i].status === 4) {
text = '<div class="normal">' +
text = '<div class="normal">' +
'<p>已过期</p>' +
'<p class="guang">去逛逛</p>' +
'</div>';
}
$("[data-id='" + res.data[i].couponId + "']").find('.info').html(text);
$('[data-id=\'' + res.data[i].couponId + '\']').find('.info').html(text);
}
}
},
error: function() {
... ...