...
|
...
|
@@ -92,19 +92,29 @@ const getPlatForm = (req) => { |
|
|
let yoho = {};
|
|
|
let uids = req.get('User-Agent').match(/uid=([^;]+)/i);
|
|
|
let arrs = [];
|
|
|
let version = false;
|
|
|
let isNewVersion = false;
|
|
|
const isProduction = process.env.NODE_ENV === 'production';
|
|
|
|
|
|
yoho.isiOS = /\(i[^;]+;( U;)? CPU.+Mac OS X/i.test(userAgent);
|
|
|
yoho.isAndroid = /Android/i.test(userAgent);
|
|
|
yoho.isApp = /YohoBuy/i.test(req.get('User-Agent')) || (req.query.app_version && req.query.client_type);
|
|
|
if (req.query.app_version) {
|
|
|
arrs = req.query.app_version.split('.');
|
|
|
version = arrs.length > 2 && Number(arrs.slice(0, 2).join('') + arrs[2].slice(0, 1)) > 490;
|
|
|
yoho.app_version = req.query.app_version || '';
|
|
|
if (yoho.app_version) {
|
|
|
arrs = yoho.app_version.split('.');
|
|
|
if (arrs.length > 2) {
|
|
|
if (arrs[0] && +arrs[0] < 4) {
|
|
|
isNewVersion = false;
|
|
|
} else if (arrs[1] && +arrs[1] < 9) {
|
|
|
isNewVersion = false;
|
|
|
} else if (arrs[2] && +arrs[2] <= 0) {
|
|
|
isNewVersion = false;
|
|
|
} else {
|
|
|
isNewVersion = true;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
yoho.isSupportStudent = !yoho.isApp || version;
|
|
|
yoho.isSupportStudent = !yoho.isApp || isNewVersion;
|
|
|
yoho.http = 'http:';
|
|
|
if (isProduction) {
|
|
|
yoho.http = 'https:';
|
...
|
...
|
@@ -116,33 +126,13 @@ const getPlatForm = (req) => { |
|
|
let data = yield getUser(yoho.uid);
|
|
|
|
|
|
yoho.isStudent = data.data && data.data.vip_info && data.data.vip_info.is_student ? true : false;
|
|
|
|
|
|
// console.log(yoho);
|
|
|
// yoho.isStudent = false;
|
|
|
return yoho;
|
|
|
})();
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
// const getRequest = (url)=>{
|
|
|
//
|
|
|
// let regurl = /^[^\?]+\?([\w\W]+)$/;
|
|
|
// let regpara = /([^&=]+)=([\w\W]*?)(&|$|#)/g;
|
|
|
// let ret = {};
|
|
|
// let strpara,
|
|
|
// result;
|
|
|
//
|
|
|
// let arrurl = regurl.exec(url);
|
|
|
//
|
|
|
// if (arrurl && arrurl[1]) {
|
|
|
// strpara = arrurl[1];
|
|
|
// while ((result = regpara.exec(strpara)) !== null) {
|
|
|
// ret[result[1]] = result[2];
|
|
|
// }
|
|
|
// }
|
|
|
// return ret;
|
|
|
// };
|
|
|
|
|
|
|
|
|
exports.index = (req, res, next) => {
|
|
|
let code = 'a83b7d55324fb65f96c1f85a3387ebd8';
|
...
|
...
|
@@ -185,7 +175,7 @@ exports.index = (req, res, next) => { |
|
|
}
|
|
|
});
|
|
|
if (coupons && coupons.data) {
|
|
|
coupons.link = link && link.data ? link.data[0].url + (req.__USER__.isApp ? '&app_version=1' : '') : '';
|
|
|
coupons.link = link && link.data ? link.data[0].url + (req.__USER__.isApp ? '&app_version=' + req.__USER__.app_version : '') : '';
|
|
|
coupons.data = (coupons.data || []).map((item) => {
|
|
|
couponids.push(item.couponID);
|
|
|
|
...
|
...
|
@@ -242,7 +232,8 @@ exports.index = (req, res, next) => { |
|
|
isLogin: req.__USER__.isLogin,
|
|
|
title: '有货学生专享优惠',
|
|
|
http: req.__USER__.http,
|
|
|
uid: req.__USER__.uid
|
|
|
uid: req.__USER__.uid,
|
|
|
app_version: req.__USER__.app_version
|
|
|
};
|
|
|
if (!req.__USER__.isApp) {
|
|
|
options.pageHeader = headerModel.setNav({
|
...
|
...
|
@@ -353,12 +344,17 @@ exports.verifystudent = (req, res, next) => { |
|
|
prompt = '你的学校信息未通审核';
|
|
|
|
|
|
if (datas[2].code === 200) {
|
|
|
if (datas[2].data.isStudent === 1) {
|
|
|
isverify = true;
|
|
|
prompt = datas[2].data.prompt;
|
|
|
if (datas[2].code === 200) {
|
|
|
if (datas[2].data.isStudent === 1) {
|
|
|
isverify = true;
|
|
|
prompt = datas[2].data.prompt;
|
|
|
}
|
|
|
} else {
|
|
|
prompt = datas[2].message;
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
prompt = datas[2].message;
|
|
|
prompt = '认证失败';
|
|
|
}
|
|
|
datas[1].data.product_list = datas[1].data.product_list.map(function(value) {
|
|
|
value.goodsId = value.goods_list[0].goods_id;
|
...
|
...
|
@@ -375,7 +371,8 @@ exports.verifystudent = (req, res, next) => { |
|
|
isLogin: user.data && user.data.vip_info && user.data.vip_info.is_student ? true : false,
|
|
|
title: '学生身份认证',
|
|
|
http: req.__USER__.http,
|
|
|
uid: req.__USER__.uid
|
|
|
uid: req.__USER__.uid,
|
|
|
app_version: req.__USER__.app_version
|
|
|
});
|
|
|
}).catch(next);
|
|
|
|
...
|
...
|
|