|
@@ -92,19 +92,29 @@ const getPlatForm = (req) => { |
|
@@ -92,19 +92,29 @@ 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
|
- if (req.query.app_version) {
|
|
|
102
|
- arrs = req.query.app_version.split('.');
|
|
|
103
|
- version = arrs.length > 2 && Number(arrs.slice(0, 2).join('') + arrs[2].slice(0, 1)) > 490;
|
101
|
+ yoho.app_version = req.query.app_version || '';
|
|
|
102
|
+ if (yoho.app_version) {
|
|
|
103
|
+ arrs = yoho.app_version.split('.');
|
|
|
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
|
-
|
|
|
107
|
- yoho.isSupportStudent = !yoho.isApp || version;
|
117
|
+ yoho.isSupportStudent = !yoho.isApp || isNewVersion;
|
108
|
yoho.http = 'http:';
|
118
|
yoho.http = 'http:';
|
109
|
if (isProduction) {
|
119
|
if (isProduction) {
|
110
|
yoho.http = 'https:';
|
120
|
yoho.http = 'https:';
|
|
@@ -116,33 +126,12 @@ const getPlatForm = (req) => { |
|
@@ -116,33 +126,12 @@ const getPlatForm = (req) => { |
116
|
let data = yield getUser(yoho.uid);
|
126
|
let data = yield getUser(yoho.uid);
|
117
|
|
127
|
|
118
|
yoho.isStudent = data.data && data.data.vip_info && data.data.vip_info.is_student ? true : false;
|
128
|
yoho.isStudent = data.data && data.data.vip_info && data.data.vip_info.is_student ? true : false;
|
119
|
-
|
|
|
120
|
- // console.log(yoho);
|
|
|
121
|
return yoho;
|
129
|
return yoho;
|
122
|
})();
|
130
|
})();
|
123
|
|
131
|
|
124
|
|
132
|
|
125
|
};
|
133
|
};
|
126
|
|
134
|
|
127
|
-// const getRequest = (url)=>{
|
|
|
128
|
-//
|
|
|
129
|
-// let regurl = /^[^\?]+\?([\w\W]+)$/;
|
|
|
130
|
-// let regpara = /([^&=]+)=([\w\W]*?)(&|$|#)/g;
|
|
|
131
|
-// let ret = {};
|
|
|
132
|
-// let strpara,
|
|
|
133
|
-// result;
|
|
|
134
|
-//
|
|
|
135
|
-// let arrurl = regurl.exec(url);
|
|
|
136
|
-//
|
|
|
137
|
-// if (arrurl && arrurl[1]) {
|
|
|
138
|
-// strpara = arrurl[1];
|
|
|
139
|
-// while ((result = regpara.exec(strpara)) !== null) {
|
|
|
140
|
-// ret[result[1]] = result[2];
|
|
|
141
|
-// }
|
|
|
142
|
-// }
|
|
|
143
|
-// return ret;
|
|
|
144
|
-// };
|
|
|
145
|
-
|
|
|
146
|
|
135
|
|
147
|
exports.index = (req, res, next) => {
|
136
|
exports.index = (req, res, next) => {
|
148
|
let code = 'a83b7d55324fb65f96c1f85a3387ebd8';
|
137
|
let code = 'a83b7d55324fb65f96c1f85a3387ebd8';
|
|
@@ -185,7 +174,7 @@ exports.index = (req, res, next) => { |
|
@@ -185,7 +174,7 @@ exports.index = (req, res, next) => { |
185
|
}
|
174
|
}
|
186
|
});
|
175
|
});
|
187
|
if (coupons && coupons.data) {
|
176
|
if (coupons && coupons.data) {
|
188
|
- coupons.link = link && link.data ? link.data[0].url + (req.__USER__.isApp ? '&app_version=1' : '') : '';
|
177
|
+ 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) => {
|
178
|
coupons.data = (coupons.data || []).map((item) => {
|
190
|
couponids.push(item.couponID);
|
179
|
couponids.push(item.couponID);
|
191
|
|
180
|
|
|
@@ -242,7 +231,8 @@ exports.index = (req, res, next) => { |
|
@@ -242,7 +231,8 @@ exports.index = (req, res, next) => { |
242
|
isLogin: req.__USER__.isLogin,
|
231
|
isLogin: req.__USER__.isLogin,
|
243
|
title: '有货学生专享优惠',
|
232
|
title: '有货学生专享优惠',
|
244
|
http: req.__USER__.http,
|
233
|
http: req.__USER__.http,
|
245
|
- uid: req.__USER__.uid
|
234
|
+ uid: req.__USER__.uid,
|
|
|
235
|
+ app_version: req.__USER__.app_version
|
246
|
};
|
236
|
};
|
247
|
if (!req.__USER__.isApp) {
|
237
|
if (!req.__USER__.isApp) {
|
248
|
options.pageHeader = headerModel.setNav({
|
238
|
options.pageHeader = headerModel.setNav({
|
|
@@ -353,12 +343,17 @@ exports.verifystudent = (req, res, next) => { |
|
@@ -353,12 +343,17 @@ exports.verifystudent = (req, res, next) => { |
353
|
prompt = '你的学校信息未通审核';
|
343
|
prompt = '你的学校信息未通审核';
|
354
|
|
344
|
|
355
|
if (datas[2].code === 200) {
|
345
|
if (datas[2].code === 200) {
|
356
|
- if (datas[2].data.isStudent === 1) {
|
|
|
357
|
- isverify = true;
|
|
|
358
|
- prompt = datas[2].data.prompt;
|
346
|
+ if (datas[2].code === 200) {
|
|
|
347
|
+ if (datas[2].data.isStudent === 1) {
|
|
|
348
|
+ isverify = true;
|
|
|
349
|
+ prompt = datas[2].data.prompt;
|
|
|
350
|
+ }
|
|
|
351
|
+ } else {
|
|
|
352
|
+ prompt = datas[2].message;
|
359
|
}
|
353
|
}
|
|
|
354
|
+
|
360
|
} else {
|
355
|
} else {
|
361
|
- prompt = datas[2].message;
|
356
|
+ prompt = '认证失败';
|
362
|
}
|
357
|
}
|
363
|
datas[1].data.product_list = datas[1].data.product_list.map(function(value) {
|
358
|
datas[1].data.product_list = datas[1].data.product_list.map(function(value) {
|
364
|
value.goodsId = value.goods_list[0].goods_id;
|
359
|
value.goodsId = value.goods_list[0].goods_id;
|
|
@@ -375,7 +370,8 @@ exports.verifystudent = (req, res, next) => { |
|
@@ -375,7 +370,8 @@ exports.verifystudent = (req, res, next) => { |
375
|
isLogin: user.data && user.data.vip_info && user.data.vip_info.is_student ? true : false,
|
370
|
isLogin: user.data && user.data.vip_info && user.data.vip_info.is_student ? true : false,
|
376
|
title: '学生身份认证',
|
371
|
title: '学生身份认证',
|
377
|
http: req.__USER__.http,
|
372
|
http: req.__USER__.http,
|
378
|
- uid: req.__USER__.uid
|
373
|
+ uid: req.__USER__.uid,
|
|
|
374
|
+ app_version: req.__USER__.app_version
|
379
|
});
|
375
|
});
|
380
|
}).catch(next);
|
376
|
}).catch(next);
|
381
|
|
377
|
|