Authored by wenjiekong

js整理

... ... @@ -5,7 +5,6 @@
*/
'use strict';
const queryString = require('querystring');
// const utils = '../../../utils';
... ... @@ -53,11 +52,8 @@ exports.getStudentsData = (channel) => {
realData: {
sortItem: [{title: '学生权益介绍', href: 'stu-rights'}, {title: '我要验证身份', href: 'stu-identity'},
{title: '学生热门单品', href: 'stu-good'}, {title: '更多活动推荐', href: 'stu-activity'}],
identityItem: {
sendCoin: 100,
stuNum: []
}
{title: '学生热门单品', href: 'stu-good'}, {title: '更多活动推荐', href: 'stu-activity'}]
},
footerTop: true
... ... @@ -68,9 +64,9 @@ exports.getStudentsData = (channel) => {
Object.assign(responseData.realData, stuHandler.studentResource(result[1].data));
}
if (result[2].code === 200) {
responseData.realData.identityItem.stuNum = stuHandler.studentsNum(result[2].data);
}
// if (result[2].code === 200) {
// }
if (result[3].code === 200) {
Object.assign(responseData.realData, {proItem: stuHandler.stuProducts(result[3].data.product_list)});
... ... @@ -226,6 +222,10 @@ exports.getTestData = () => {
identityItem: {
sendCoin: 10,
stuNum: [1, 2, 3, 4, 5, 6, 7]
},
verifyRusult:{
status: true,
rank: 20
}
};
return respData;
... ... @@ -269,10 +269,8 @@ exports.getEduLevel = () => {
* @params areaCode int 地区码
* @return Object 接口数据
*/
exports.verifyIdentity = (uid, params) => {
let pageUrl = 'http://localhost:6001/product/students?' + queryString.stringify(params);
return studentsApi.verifyIdentity(uid, params.certNo, params.name, pageUrl).then(result => {
exports.verifyIdentity = () => {
return studentsApi.verifyIdentity().then(result => {
return result;
});
};
... ... @@ -283,10 +281,9 @@ exports.verifyIdentity = (uid, params) => {
* @return Object 接口数据
*/
exports.verifyStudents = (uid, params) => {
let pageUrl = '/product/students?';
return studentsApi.verifyIdentity(uid, params.collegeName, params.educationDegree, params.enrollmentYear).
then(result => {
return studentsApi.verifyIdentity(uid, params.certNo, params.name, pageUrl).then(result => {
return result;
});
};
\ No newline at end of file
... ...
... ... @@ -21,8 +21,6 @@ var $sortItem = $('.sort-item'),
$stuYearWrap = $stuYear.parent(),
$identityForm = $('#identity-form');
// $stuYearUl = $stuYear.next();
var $rightDia = $('#rights-dia'),
$couponDia = $('#coupon-dia');
... ... @@ -110,8 +108,10 @@ function submitIdentity(json) {
type: 'GET',
url: '/product/students/verify',
data: json
}).then(function() {
}).then(function(data) {
if (data.code === 200) {
window.location.href = data.data;
}
});
}
... ... @@ -249,11 +249,37 @@ $sortItem.on('click', function() {
$(this).addClass('active');
});
function loadSelectLi(jsonData, param) {
var $wrap = jsonData.$ul.parent(),
keyData = jsonData.keyData;
jsonData.$ul.empty();
if ($wrap.hasClass('active')) {
$wrap.removeClass('active');
} else {
closeStuSelect();
$wrap.addClass('active');
$.ajax({
type: 'GET',
url: jsonData.url,
data: param
}).then(function(data) {
if (data.code === 200) {
jsonData.$ul.html(provFn({
keyData: data.data
}));
} else if (data.code === 403) {
location.href = data.data.url;
}
});
}
}
// 加载学校地区数据
$stuProv.on('click', function() {
var $provUl = $(this).next();
var $ul = $(this).next();
$provUl.empty();
$ul.empty();
if ($stuProvWrap.hasClass('active')) {
$stuProvWrap.removeClass('active');
} else {
... ... @@ -264,7 +290,7 @@ $stuProv.on('click', function() {
url: '/product/students/schoolArea'
}).then(function(data) {
if (data.code === 200) {
$provUl.html(provFn({
$ul.html(provFn({
provData: data.data
}));
} else if (data.code === 403) {
... ... @@ -274,22 +300,6 @@ $stuProv.on('click', function() {
}
});
$('#stu-province-ul').delegate('li', 'click', function() {
clearSelectUl($(this), 'areacode');
});
$('#stu-school-ul').delegate('li', 'click', function() {
clearSelectUl($(this), 'schoolCode');
});
$('#stu-edu-ul').delegate('li', 'click', function() {
clearSelectUl($(this));
});
$('#stu-entrance-year-ul').delegate('li', 'click', function() {
clearSelectUl($(this));
});
//
$stuSchool.on('click', function() {
var $ul = $(this).next();
... ... @@ -316,6 +326,7 @@ $stuSchool.on('click', function() {
}
});
}
});
//
... ... @@ -381,12 +392,24 @@ $rightDia.on('click', function() {
$agreenShow.on('click', function() {
var $ck = $(this);
if ($ck.hasClass('active')) {
$ck.removeClass('active');
} else {
$ck.addClass('active');
}
$ck.hasClass('active') === true ? $ck.removeClass('active') : $ck.addClass('active');
});
$('#stu-province-ul').delegate('li', 'click', function() {
clearSelectUl($(this), 'areacode');
});
$('#stu-school-ul').delegate('li', 'click', function() {
clearSelectUl($(this), 'schoolCode');
});
$('#stu-edu-ul').delegate('li', 'click', function() {
clearSelectUl($(this));
});
$('#stu-entrance-year-ul').delegate('li', 'click', function() {
clearSelectUl($(this));
});
$('.enable .info').on('click', function(e) {
... ...