Authored by wenjiekong

优惠券领取

... ... @@ -25,7 +25,7 @@ exports.index = (req, res, next) => {
let responseData = studentsModel.getTestData(channel);
// let responseData = {};
// Object.assign(responseData, result);
Object.assign(responseData, result);
res.render('students/index', responseData);
... ...
... ... @@ -65,7 +65,7 @@ exports.getStudentsData = (channel) => {
}
// if (result[2].code === 200) {
// }
if (result[3].code === 200) {
... ... @@ -221,7 +221,7 @@ exports.getTestData = () => {
],
identityItem: {
sendCoin: 10,
stuNum: [1,2,3,4,5,6,7]
stuNum: [1, 2, 3, 4, 5, 6, 7]
}
};
return respData;
... ...
... ... @@ -29,6 +29,33 @@ var $rightDia = $('#rights-dia'),
var provFn;
var alertConfig,
makeAlert;
// j面跳转对象
var redirect = {
// 去逛逛跳转链接
gunangSrc: null,
// 查看优惠券跳转链接
checkCouponSrc: null,
goToGuang: function() {
window.location.href = this.gunangSrc;
},
goToCheck: function() {
window.location.href = this.checkCouponSrc;
},
// 处理网络返回
403: function(url) {
window.location.href = url;
},
200: function(url) {
this.checkCouponSrc = url;
}
};
// handlebars模板
provFn = handlebars.compile($('#stu-select').html() || '');
... ... @@ -54,33 +81,27 @@ function closeStuSelect() {
$('.ident-select-wrap .select-ul').empty();
}
lazyLoad($('img.lazy'));
var alertConfig,
makeAlert;
// j面跳转对象
var redirect = {
// 去逛逛跳转链接
gunangSrc: null,
/**
* 清除加载的下拉数据,还原点击状态
* @param
* @param
*/
function clearSelectUl($li, code) {
var $a = $li.find('a'),
$ul = $li.parent();
// 查看优惠券跳转链接
checkCouponSrc: null,
goToGuang: function() {
window.location.href = this.gunangSrc;
},
goToCheck: function() {
window.location.href = this.checkCouponSrc;
},
var $show = $ul.prev(),
$wrap = $ul.parent();
// 处理网络返回
403: function(url) {
window.location.href = url;
},
200: function(url) {
this.checkCouponSrc = url;
$show.html($a.html());
if (arguments.length === 2) {
$show.attr(code, $a.attr(code));
}
};
$ul.empty();
$wrap.removeClass('active');
}
lazyLoad($('img.lazy'));
// 根据配置执行展示弹窗
function couponAlert(opt) {
... ... @@ -190,13 +211,14 @@ function requestCoupon(id) {
var code = res.code;
// 如果返回的数据里有url,则执行redirect里的方法
res.url && res.url.length > 0 && redirect[code] && redirect[code](res.url + '?'+ location.href.split('?')[1]);
res.url && res.url.length > 0 && redirect[code] &&
redirect[code](res.url + '?' + location.href.split('?')[1]);
// 如果能找到对应code则执行相应方法,如果没有的对应code则执行error提示
makeAlert[code] ? makeAlert[code]() : makeAlert['400']();
},
error: function(err) {
error: function() {
var Alert = require('../common/dialog').Alert;
new Alert('网络异常').show();
... ... @@ -215,8 +237,7 @@ $sortItem.on('click', function() {
// 加载学校地区数据
$stuProv.on('click', function() {
var $prov = $(this),
$provUl = $(this).next();
var $provUl = $(this).next();
$provUl.empty();
if ($stuProvWrap.hasClass('active')) {
... ... @@ -232,16 +253,6 @@ $stuProv.on('click', function() {
$provUl.html(provFn({
provData: data.data
}));
// 学校地区选中事件
// $provUl.find('li').on('click', function() {
// var $selectProv = $(this).find('a');
// $prov.html($selectProv.html());
// $prov.attr('areaCode', $selectProv.attr('areaCode'));
// $provUl.empty();
// $stuProvWrap.removeClass('active');
// });
} else if (data.code === 403) {
location.href = data.data.url;
}
... ... @@ -249,46 +260,25 @@ $stuProv.on('click', function() {
}
});
$('#stu-province-ul').delegate('li', 'click', function(e) {
clearSelectUl($(this),'areacode');
$('#stu-province-ul').delegate('li', 'click', function() {
clearSelectUl($(this), 'areacode');
});
$('#stu-school-ul').delegate('li', 'click', function(e) {
clearSelectUl($(this),'schoolCode');
$('#stu-school-ul').delegate('li', 'click', function() {
clearSelectUl($(this), 'schoolCode');
});
$('#stu-edu-ul').delegate('li', 'click', function(e) {
$('#stu-edu-ul').delegate('li', 'click', function() {
clearSelectUl($(this));
});
$('#stu-entrance-year-ul').delegate('li', 'click', function(e) {
$('#stu-entrance-year-ul').delegate('li', 'click', function() {
clearSelectUl($(this));
});
/**
* 清除加载的下拉数据,还原点击状态
* @param
* @param
*/
function clearSelectUl($li,code) {
var $a = $li.find('a'),
$ul = $li.parent();
var $show = $ul.prev(),
$wrap = $ul.parent();
$show.html($a.html());
if (undefined != code) {
$show.attr(code, $a.attr(code));
}
$ul.empty();
$wrap.removeClass('active');
}
// 加载学校数据
$stuSchool.on('click', function() {
var $school = $(this),
$ul = $(this).next();
var $ul = $(this).next();
$ul.empty();
if ($stuSchoolWrap.hasClass('active')) {
... ... @@ -316,8 +306,7 @@ $stuSchool.on('click', function() {
// 加载学历数据
$stuEdu.on('click', function() {
var $edu = $(this),
$ul = $(this).next();
var $ul = $(this).next();
$ul.empty();
if ($stuEduWrap.hasClass('active')) {
... ... @@ -342,8 +331,7 @@ $stuEdu.on('click', function() {
// 加载学历数据
$stuYear.on('click', function() {
var $edu = $(this),
$ul = $(this).next();
var $ul = $(this).next();
$ul.empty();
if ($stuYearWrap.hasClass('active')) {
... ...