Authored by 周少峰

Merge branch 'feature/students' of git.yoho.cn:fe/yohobuy-node into feature/students

... ... @@ -82,3 +82,24 @@ exports.verify = (req, res, next) => {
}).catch(next);
};
/**
* 获取优惠券领取状态
* @param {[type]} req [description]
* @param {[type]} res [description]
* @return {[type]} [description]
*/
exports.userAcquireStatus = (req, res, next) => {
let uid;
if (!req.user.uid) {
uid = '';
} else {
uid = req.user.uid;
}
studentsModel.userAcquireStatus(uid, req.couponIds).then(result => {
res.json(result);
}).catch(next);
};
... ...
... ... @@ -97,3 +97,21 @@ exports.verifyStudent = (uid, collegeName, educationDegree, enrollmentYear) => {
return api.get('', finalParams);
};
/**
* 获取优惠券领取状态
* @return
*/
exports.userAcquireStatus = (uid, couponIds) => {
let finalParams = {
method: 'app.coupons.userAcquireStatus',
couponIds: couponIds
};
if (uid !== '') {
finalParams.uid = uid;
}
return api.get('', finalParams);
};
... ...
... ... @@ -150,3 +150,15 @@ exports.verifyStudents = (params) => {
return result;
});
};
/**
* 获取优惠券领取状态
* @params
* @return
*/
exports.userAcquireStatus = (uid, couponIds) => {
return studentsApi.userAcquireStatus(uid, couponIds).
then(result => {
return result;
});
};
... ...
... ... @@ -60,5 +60,6 @@ router.get('/students/schoolArea', students.schoolArea); // 学校地区
router.get('/students/schoolList', students.schoolList); // 学校地区
router.get('/students/eduLevel', students.eduLevel); // 学校地区
router.get('/students/verify', students.verify); // 身份验证
router.get('/students/userAcquireStatus', students.userAcquireStatus); // 获取优惠券领取状态
module.exports = router;
... ...
... ... @@ -464,7 +464,7 @@ $identityWrap.delegate('.backForm', 'click', function() {
$identityForm.removeClass('hide').siblings().addClass('hide');
});
$('.enable .info').on('click', function(e) {
$('.enable .normal').on('click', function(e) {
e.preventDefault();
requestCoupon($(this).closest('a').data('id'));
redirect.gunangSrc = $(this).closest('a').get(0).href;
... ... @@ -564,6 +564,61 @@ $('.ident-select-wrap').one('click', function() {
*埋点
*/
$(function() {
// 加载优惠券状态
var couponIds = '';
$('.coupon > a').each(function() {
couponIds += $(this).attr('data-id') + ',';
});
$.ajax({
type: 'GET',
url: '/product/students/userAcquireStatus',
data: {
couponIds: couponIds.substring(0, couponIds.length - 1)
},
success: function(res) {
var code = res.code,
i,
text;
console.info(res);
if (code === 200) {
for (i = 0; i < res.data.length; i++) {
text = '';
if (res.data[i].status === 1) {
text = '<div class="normal">' +
'<p>点击</p>' +
'<p>领取</p>' +
'</div>';
}
if (res.data[i].status === 2) {
text = '<div class="empty">' +
'<p>已抢光</p>' +
'<p class="guang">去逛逛</p>' +
'</div>';
}
if (res.data[i].status === 3) {
text = '<div class="got">' +
'<p>已领取</p>' +
'<p class="guang">去使用</p>' +
'</div>';
}
if (res.data[i].status === 4) {
text = '<div class="normal">' +
'<p>已过期</p>' +
'<p class="guang">去逛逛</p>' +
'</div>';
}
$('[data-id=\'' + res.data[i].couponId + '\']').find('.info').html(text);
}
}
},
error: function() {
}
});
if ($('#identity-success').length > 0) {
// xls-4学生认证成功埋点
... ...