Authored by wenjiekong

js整理

@@ -5,7 +5,6 @@ @@ -5,7 +5,6 @@
5 */ 5 */
6 6
7 'use strict'; 7 'use strict';
8 -const queryString = require('querystring');  
9 8
10 // const utils = '../../../utils'; 9 // const utils = '../../../utils';
11 10
@@ -53,11 +52,8 @@ exports.getStudentsData = (channel) => { @@ -53,11 +52,8 @@ exports.getStudentsData = (channel) => {
53 52
54 realData: { 53 realData: {
55 sortItem: [{title: '学生权益介绍', href: 'stu-rights'}, {title: '我要验证身份', href: 'stu-identity'}, 54 sortItem: [{title: '学生权益介绍', href: 'stu-rights'}, {title: '我要验证身份', href: 'stu-identity'},
56 - {title: '学生热门单品', href: 'stu-good'}, {title: '更多活动推荐', href: 'stu-activity'}],  
57 - identityItem: {  
58 - sendCoin: 100,  
59 - stuNum: []  
60 - } 55 + {title: '学生热门单品', href: 'stu-good'}, {title: '更多活动推荐', href: 'stu-activity'}]
  56 +
61 }, 57 },
62 58
63 footerTop: true 59 footerTop: true
@@ -68,9 +64,9 @@ exports.getStudentsData = (channel) => { @@ -68,9 +64,9 @@ exports.getStudentsData = (channel) => {
68 Object.assign(responseData.realData, stuHandler.studentResource(result[1].data)); 64 Object.assign(responseData.realData, stuHandler.studentResource(result[1].data));
69 } 65 }
70 66
71 - if (result[2].code === 200) {  
72 - responseData.realData.identityItem.stuNum = stuHandler.studentsNum(result[2].data);  
73 - } 67 + // if (result[2].code === 200) {
  68 +
  69 + // }
74 70
75 if (result[3].code === 200) { 71 if (result[3].code === 200) {
76 Object.assign(responseData.realData, {proItem: stuHandler.stuProducts(result[3].data.product_list)}); 72 Object.assign(responseData.realData, {proItem: stuHandler.stuProducts(result[3].data.product_list)});
@@ -226,6 +222,10 @@ exports.getTestData = () => { @@ -226,6 +222,10 @@ exports.getTestData = () => {
226 identityItem: { 222 identityItem: {
227 sendCoin: 10, 223 sendCoin: 10,
228 stuNum: [1, 2, 3, 4, 5, 6, 7] 224 stuNum: [1, 2, 3, 4, 5, 6, 7]
  225 + },
  226 + verifyRusult:{
  227 + status: true,
  228 + rank: 20
229 } 229 }
230 }; 230 };
231 return respData; 231 return respData;
@@ -269,10 +269,8 @@ exports.getEduLevel = () => { @@ -269,10 +269,8 @@ exports.getEduLevel = () => {
269 * @params areaCode int 地区码 269 * @params areaCode int 地区码
270 * @return Object 接口数据 270 * @return Object 接口数据
271 */ 271 */
272 -exports.verifyIdentity = (uid, params) => {  
273 - let pageUrl = 'http://localhost:6001/product/students?' + queryString.stringify(params);  
274 -  
275 - return studentsApi.verifyIdentity(uid, params.certNo, params.name, pageUrl).then(result => { 272 +exports.verifyIdentity = () => {
  273 + return studentsApi.verifyIdentity().then(result => {
276 return result; 274 return result;
277 }); 275 });
278 }; 276 };
@@ -283,10 +281,9 @@ exports.verifyIdentity = (uid, params) => { @@ -283,10 +281,9 @@ exports.verifyIdentity = (uid, params) => {
283 * @return Object 接口数据 281 * @return Object 接口数据
284 */ 282 */
285 exports.verifyStudents = (uid, params) => { 283 exports.verifyStudents = (uid, params) => {
  284 + let pageUrl = '/product/students?';
286 285
287 -  
288 - return studentsApi.verifyIdentity(uid, params.collegeName, params.educationDegree, params.enrollmentYear).  
289 - then(result => { 286 + return studentsApi.verifyIdentity(uid, params.certNo, params.name, pageUrl).then(result => {
290 return result; 287 return result;
291 }); 288 });
292 }; 289 };
@@ -21,8 +21,6 @@ var $sortItem = $('.sort-item'), @@ -21,8 +21,6 @@ var $sortItem = $('.sort-item'),
21 $stuYearWrap = $stuYear.parent(), 21 $stuYearWrap = $stuYear.parent(),
22 $identityForm = $('#identity-form'); 22 $identityForm = $('#identity-form');
23 23
24 - // $stuYearUl = $stuYear.next();  
25 -  
26 var $rightDia = $('#rights-dia'), 24 var $rightDia = $('#rights-dia'),
27 $couponDia = $('#coupon-dia'); 25 $couponDia = $('#coupon-dia');
28 26
@@ -110,8 +108,10 @@ function submitIdentity(json) { @@ -110,8 +108,10 @@ function submitIdentity(json) {
110 type: 'GET', 108 type: 'GET',
111 url: '/product/students/verify', 109 url: '/product/students/verify',
112 data: json 110 data: json
113 - }).then(function() {  
114 - 111 + }).then(function(data) {
  112 + if (data.code === 200) {
  113 + window.location.href = data.data;
  114 + }
115 }); 115 });
116 } 116 }
117 117
@@ -249,11 +249,37 @@ $sortItem.on('click', function() { @@ -249,11 +249,37 @@ $sortItem.on('click', function() {
249 $(this).addClass('active'); 249 $(this).addClass('active');
250 }); 250 });
251 251
  252 +function loadSelectLi(jsonData, param) {
  253 + var $wrap = jsonData.$ul.parent(),
  254 + keyData = jsonData.keyData;
  255 +
  256 + jsonData.$ul.empty();
  257 + if ($wrap.hasClass('active')) {
  258 + $wrap.removeClass('active');
  259 + } else {
  260 + closeStuSelect();
  261 + $wrap.addClass('active');
  262 + $.ajax({
  263 + type: 'GET',
  264 + url: jsonData.url,
  265 + data: param
  266 + }).then(function(data) {
  267 + if (data.code === 200) {
  268 + jsonData.$ul.html(provFn({
  269 + keyData: data.data
  270 + }));
  271 + } else if (data.code === 403) {
  272 + location.href = data.data.url;
  273 + }
  274 + });
  275 + }
  276 +}
  277 +
252 // 加载学校地区数据 278 // 加载学校地区数据
253 $stuProv.on('click', function() { 279 $stuProv.on('click', function() {
254 - var $provUl = $(this).next(); 280 + var $ul = $(this).next();
255 281
256 - $provUl.empty(); 282 + $ul.empty();
257 if ($stuProvWrap.hasClass('active')) { 283 if ($stuProvWrap.hasClass('active')) {
258 $stuProvWrap.removeClass('active'); 284 $stuProvWrap.removeClass('active');
259 } else { 285 } else {
@@ -264,7 +290,7 @@ $stuProv.on('click', function() { @@ -264,7 +290,7 @@ $stuProv.on('click', function() {
264 url: '/product/students/schoolArea' 290 url: '/product/students/schoolArea'
265 }).then(function(data) { 291 }).then(function(data) {
266 if (data.code === 200) { 292 if (data.code === 200) {
267 - $provUl.html(provFn({ 293 + $ul.html(provFn({
268 provData: data.data 294 provData: data.data
269 })); 295 }));
270 } else if (data.code === 403) { 296 } else if (data.code === 403) {
@@ -274,22 +300,6 @@ $stuProv.on('click', function() { @@ -274,22 +300,6 @@ $stuProv.on('click', function() {
274 } 300 }
275 }); 301 });
276 302
277 -$('#stu-province-ul').delegate('li', 'click', function() {  
278 - clearSelectUl($(this), 'areacode');  
279 -});  
280 -  
281 -$('#stu-school-ul').delegate('li', 'click', function() {  
282 - clearSelectUl($(this), 'schoolCode');  
283 -});  
284 -  
285 -$('#stu-edu-ul').delegate('li', 'click', function() {  
286 - clearSelectUl($(this));  
287 -});  
288 -  
289 -$('#stu-entrance-year-ul').delegate('li', 'click', function() {  
290 - clearSelectUl($(this));  
291 -});  
292 -  
293 // 303 //
294 $stuSchool.on('click', function() { 304 $stuSchool.on('click', function() {
295 var $ul = $(this).next(); 305 var $ul = $(this).next();
@@ -316,6 +326,7 @@ $stuSchool.on('click', function() { @@ -316,6 +326,7 @@ $stuSchool.on('click', function() {
316 } 326 }
317 }); 327 });
318 } 328 }
  329 +
319 }); 330 });
320 331
321 // 332 //
@@ -381,12 +392,24 @@ $rightDia.on('click', function() { @@ -381,12 +392,24 @@ $rightDia.on('click', function() {
381 $agreenShow.on('click', function() { 392 $agreenShow.on('click', function() {
382 var $ck = $(this); 393 var $ck = $(this);
383 394
384 - if ($ck.hasClass('active')) {  
385 - $ck.removeClass('active');  
386 - } else {  
387 - $ck.addClass('active');  
388 - } 395 + $ck.hasClass('active') === true ? $ck.removeClass('active') : $ck.addClass('active');
  396 +});
  397 +
389 398
  399 +$('#stu-province-ul').delegate('li', 'click', function() {
  400 + clearSelectUl($(this), 'areacode');
  401 +});
  402 +
  403 +$('#stu-school-ul').delegate('li', 'click', function() {
  404 + clearSelectUl($(this), 'schoolCode');
  405 +});
  406 +
  407 +$('#stu-edu-ul').delegate('li', 'click', function() {
  408 + clearSelectUl($(this));
  409 +});
  410 +
  411 +$('#stu-entrance-year-ul').delegate('li', 'click', function() {
  412 + clearSelectUl($(this));
390 }); 413 });
391 414
392 $('.enable .info').on('click', function(e) { 415 $('.enable .info').on('click', function(e) {