|
@@ -92,19 +92,30 @@ const getPlatForm = (req) => { |
|
@@ -92,19 +92,30 @@ const getPlatForm = (req) => { |
92
|
let yoho = {};
|
92
|
let yoho = {};
|
93
|
let uids = req.get('User-Agent').match(/uid=([^;]+)/i);
|
93
|
let uids = req.get('User-Agent').match(/uid=([^;]+)/i);
|
94
|
let arrs = [];
|
94
|
let arrs = [];
|
95
|
- let version = false;
|
95
|
+ let isNewVersion = false;
|
96
|
const isProduction = process.env.NODE_ENV === 'production';
|
96
|
const isProduction = process.env.NODE_ENV === 'production';
|
97
|
|
97
|
|
98
|
yoho.isiOS = /\(i[^;]+;( U;)? CPU.+Mac OS X/i.test(userAgent);
|
98
|
yoho.isiOS = /\(i[^;]+;( U;)? CPU.+Mac OS X/i.test(userAgent);
|
99
|
yoho.isAndroid = /Android/i.test(userAgent);
|
99
|
yoho.isAndroid = /Android/i.test(userAgent);
|
100
|
yoho.isApp = /YohoBuy/i.test(req.get('User-Agent')) || (req.query.app_version && req.query.client_type);
|
100
|
yoho.isApp = /YohoBuy/i.test(req.get('User-Agent')) || (req.query.app_version && req.query.client_type);
|
|
|
101
|
+ yoho.app_version = req.query.app_version||'';
|
101
|
if (req.query.app_version) {
|
102
|
if (req.query.app_version) {
|
102
|
arrs = req.query.app_version.split('.');
|
103
|
arrs = req.query.app_version.split('.');
|
103
|
- version = arrs.length > 2 && Number(arrs.slice(0, 2).join('') + arrs[2].slice(0, 1)) > 490;
|
104
|
+ if(arrs.length>2){
|
|
|
105
|
+ if(arrs[0]&&+arrs[0]<4){
|
|
|
106
|
+ isNewVersion=false;
|
|
|
107
|
+ }else if(arrs[1]&&+arrs[1]<9){
|
|
|
108
|
+ isNewVersion=false;
|
|
|
109
|
+ }else if(arrs[2]&&+arrs[2]<0){
|
|
|
110
|
+ isNewVersion=false;
|
|
|
111
|
+ }else{
|
|
|
112
|
+ isNewVersion=true;
|
|
|
113
|
+ }
|
|
|
114
|
+ }
|
104
|
}
|
115
|
}
|
105
|
|
116
|
|
106
|
|
117
|
|
107
|
- yoho.isSupportStudent = !yoho.isApp || version;
|
118
|
+ yoho.isSupportStudent = !yoho.isApp || isNewVersion;
|
108
|
yoho.http = 'http:';
|
119
|
yoho.http = 'http:';
|
109
|
if (isProduction) {
|
120
|
if (isProduction) {
|
110
|
yoho.http = 'https:';
|
121
|
yoho.http = 'https:';
|
|
@@ -117,7 +128,6 @@ const getPlatForm = (req) => { |
|
@@ -117,7 +128,6 @@ const getPlatForm = (req) => { |
117
|
|
128
|
|
118
|
yoho.isStudent = data.data && data.data.vip_info && data.data.vip_info.is_student ? true : false;
|
129
|
yoho.isStudent = data.data && data.data.vip_info && data.data.vip_info.is_student ? true : false;
|
119
|
|
130
|
|
120
|
- // console.log(yoho);
|
|
|
121
|
return yoho;
|
131
|
return yoho;
|
122
|
})();
|
132
|
})();
|
123
|
|
133
|
|
|
@@ -185,7 +195,7 @@ exports.index = (req, res, next) => { |
|
@@ -185,7 +195,7 @@ exports.index = (req, res, next) => { |
185
|
}
|
195
|
}
|
186
|
});
|
196
|
});
|
187
|
if (coupons && coupons.data) {
|
197
|
if (coupons && coupons.data) {
|
188
|
- coupons.link = link && link.data ? link.data[0].url + (req.__USER__.isApp ? '&app_version=1' : '') : '';
|
198
|
+ coupons.link = link && link.data ? link.data[0].url + (req.__USER__.isApp ? '&app_version='+req.__USER__.app_version : '') : '';
|
189
|
coupons.data = (coupons.data || []).map((item) => {
|
199
|
coupons.data = (coupons.data || []).map((item) => {
|
190
|
couponids.push(item.couponID);
|
200
|
couponids.push(item.couponID);
|
191
|
|
201
|
|
|
@@ -242,7 +252,8 @@ exports.index = (req, res, next) => { |
|
@@ -242,7 +252,8 @@ exports.index = (req, res, next) => { |
242
|
isLogin: req.__USER__.isLogin,
|
252
|
isLogin: req.__USER__.isLogin,
|
243
|
title: '有货学生专享优惠',
|
253
|
title: '有货学生专享优惠',
|
244
|
http: req.__USER__.http,
|
254
|
http: req.__USER__.http,
|
245
|
- uid: req.__USER__.uid
|
255
|
+ uid: req.__USER__.uid,
|
|
|
256
|
+ app_version: req.__USER__.app_version
|
246
|
};
|
257
|
};
|
247
|
if (!req.__USER__.isApp) {
|
258
|
if (!req.__USER__.isApp) {
|
248
|
options.pageHeader = headerModel.setNav({
|
259
|
options.pageHeader = headerModel.setNav({
|
|
@@ -271,7 +282,7 @@ exports.index = (req, res, next) => { |
|
@@ -271,7 +282,7 @@ exports.index = (req, res, next) => { |
271
|
}
|
282
|
}
|
272
|
}
|
283
|
}
|
273
|
|
284
|
|
274
|
- // console.log(options);
|
285
|
+ console.log(options);
|
275
|
res.render('student', options);
|
286
|
res.render('student', options);
|
276
|
});
|
287
|
});
|
277
|
|
288
|
|
|
@@ -353,12 +364,17 @@ exports.verifystudent = (req, res, next) => { |
|
@@ -353,12 +364,17 @@ exports.verifystudent = (req, res, next) => { |
353
|
prompt = '你的学校信息未通审核';
|
364
|
prompt = '你的学校信息未通审核';
|
354
|
|
365
|
|
355
|
if (datas[2].code === 200) {
|
366
|
if (datas[2].code === 200) {
|
356
|
- if (datas[2].data.isStudent === 1) {
|
|
|
357
|
- isverify = true;
|
|
|
358
|
- prompt = datas[2].data.prompt;
|
367
|
+ if(datas[2].code===200){
|
|
|
368
|
+ if (datas[2].data.isStudent === 1) {
|
|
|
369
|
+ isverify = true;
|
|
|
370
|
+ prompt = datas[2].data.prompt;
|
|
|
371
|
+ }
|
|
|
372
|
+ }else {
|
|
|
373
|
+ prompt = datas[2].message;
|
359
|
}
|
374
|
}
|
|
|
375
|
+
|
360
|
} else {
|
376
|
} else {
|
361
|
- prompt = datas[2].message;
|
377
|
+ prompt = "认证失败";
|
362
|
}
|
378
|
}
|
363
|
datas[1].data.product_list = datas[1].data.product_list.map(function(value) {
|
379
|
datas[1].data.product_list = datas[1].data.product_list.map(function(value) {
|
364
|
value.goodsId = value.goods_list[0].goods_id;
|
380
|
value.goodsId = value.goods_list[0].goods_id;
|
|
@@ -375,7 +391,8 @@ exports.verifystudent = (req, res, next) => { |
|
@@ -375,7 +391,8 @@ exports.verifystudent = (req, res, next) => { |
375
|
isLogin: user.data && user.data.vip_info && user.data.vip_info.is_student ? true : false,
|
391
|
isLogin: user.data && user.data.vip_info && user.data.vip_info.is_student ? true : false,
|
376
|
title: '学生身份认证',
|
392
|
title: '学生身份认证',
|
377
|
http: req.__USER__.http,
|
393
|
http: req.__USER__.http,
|
378
|
- uid: req.__USER__.uid
|
394
|
+ uid: req.__USER__.uid,
|
|
|
395
|
+ app_version: req.__USER__.app_version
|
379
|
});
|
396
|
});
|
380
|
}).catch(next);
|
397
|
}).catch(next);
|
381
|
|
398
|
|