...
|
...
|
@@ -11,85 +11,80 @@ const _ = require('lodash'); |
|
|
const productProcess = require(`${utils}/product-process`);
|
|
|
|
|
|
|
|
|
const getResource = code => {
|
|
|
return serviceApi.get('operations/api/v5/resource/get', {
|
|
|
content_code: code,
|
|
|
platform: 'iphone'
|
|
|
});
|
|
|
};
|
|
|
const vip = (limit) => {
|
|
|
return api.get('', {
|
|
|
method: 'app.student.vip',
|
|
|
limit: limit || 60
|
|
|
});
|
|
|
};
|
|
|
const verifiedStudentTotal = () => {
|
|
|
return api.get('', {
|
|
|
method: 'app.student.verifiedStudentTotal'
|
|
|
});
|
|
|
};
|
|
|
const getProvince = () => {
|
|
|
return api.get('', {
|
|
|
method: 'app.studentMarket.getAddressList'
|
|
|
}, {
|
|
|
cache: true
|
|
|
});
|
|
|
};
|
|
|
const getSchool = code => {
|
|
|
return api.get('', {
|
|
|
method: 'app.studentMarket.getSchoolInfoList',
|
|
|
areaCode: code
|
|
|
});
|
|
|
};
|
|
|
const getEducationLevelList = () => {
|
|
|
return api.get('', {
|
|
|
method: 'app.studentMarket.getEducationLevelList'
|
|
|
});
|
|
|
};
|
|
|
// const getResource = code => {
|
|
|
// return serviceApi.get('operations/api/v5/resource/get', {
|
|
|
// content_code: code,
|
|
|
// platform: 'iphone'
|
|
|
// });
|
|
|
// };
|
|
|
|
|
|
// const verifiedStudentTotal = () => {
|
|
|
// return api.get('', {
|
|
|
// method: 'app.student.verifiedStudentTotal'
|
|
|
// });
|
|
|
// };
|
|
|
// const getProvince = () => {
|
|
|
// return api.get('', {
|
|
|
// method: 'app.studentMarket.getAddressList'
|
|
|
// }, {
|
|
|
// cache: true
|
|
|
// });
|
|
|
// };
|
|
|
// const getSchool = code => {
|
|
|
// return api.get('', {
|
|
|
// method: 'app.studentMarket.getSchoolInfoList',
|
|
|
// areaCode: code
|
|
|
// });
|
|
|
// };
|
|
|
// const getEducationLevelList = () => {
|
|
|
// return api.get('', {
|
|
|
// method: 'app.studentMarket.getEducationLevelList'
|
|
|
// });
|
|
|
// };
|
|
|
const userAcquireStatus = (uid, couponIds) => {
|
|
|
return api.get('', {
|
|
|
method: 'app.coupons.userAcquireStatus',
|
|
|
uid: uid,
|
|
|
couponIds: couponIds
|
|
|
});
|
|
|
};
|
|
|
const verifyStudent = (uid, collegename, educationdegree, enrollmentyear) => {
|
|
|
return api.get('', {
|
|
|
method: 'app.student.verifyStudent',
|
|
|
uid: uid,
|
|
|
client_type: 'h5',
|
|
|
college_name: collegename,
|
|
|
enrollment_year: enrollmentyear,
|
|
|
education_degree: educationdegree
|
|
|
});
|
|
|
};
|
|
|
const verifyIdentity = (uid, certno, name, pageurl) => {
|
|
|
return api.get('', {
|
|
|
method: 'app.student.verifyIdentity',
|
|
|
uid: uid,
|
|
|
client_type: 'h5',
|
|
|
cert_no: certno,
|
|
|
name: name,
|
|
|
page_url: pageurl
|
|
|
});
|
|
|
};
|
|
|
const getUser = (uid) => {
|
|
|
if (!uid) {
|
|
|
return Promise.resolve({
|
|
|
code: 200,
|
|
|
data: {}
|
|
|
});
|
|
|
}
|
|
|
return api.get('', {
|
|
|
method: 'app.passport.profile',
|
|
|
uid: uid
|
|
|
}, {
|
|
|
cache: true
|
|
|
});
|
|
|
};
|
|
|
};//yao
|
|
|
// const verifyStudent = (uid, collegename, educationdegree, enrollmentyear) => {
|
|
|
// return api.get('', {
|
|
|
// method: 'app.student.verifyStudent',
|
|
|
// uid: uid,
|
|
|
// client_type: 'h5',
|
|
|
// college_name: collegename,
|
|
|
// enrollment_year: enrollmentyear,
|
|
|
// education_degree: educationdegree
|
|
|
// });
|
|
|
// };
|
|
|
// const verifyIdentity = (uid, certno, name, pageurl) => {
|
|
|
// return api.get('', {
|
|
|
// method: 'app.student.verifyIdentity',
|
|
|
// uid: uid,
|
|
|
// client_type: 'h5',
|
|
|
// cert_no: certno,
|
|
|
// name: name,
|
|
|
// page_url: pageurl
|
|
|
// });
|
|
|
// };
|
|
|
// const getUser = (uid) => {
|
|
|
// if (!uid) {
|
|
|
// return Promise.resolve({
|
|
|
// code: 200,
|
|
|
// data: {}
|
|
|
// });
|
|
|
// }
|
|
|
// return api.get('', {
|
|
|
// method: 'app.passport.profile',
|
|
|
// uid: uid
|
|
|
// }, {
|
|
|
// cache: true
|
|
|
// });
|
|
|
// };
|
|
|
|
|
|
/**
|
|
|
* 商品
|
|
|
* 查询商品
|
|
|
* @param id
|
|
|
* @returns {*}
|
|
|
*/
|
...
|
...
|
@@ -102,7 +97,6 @@ const _getRelatedData = (idList) => { |
|
|
let goods = [];
|
|
|
|
|
|
if (result && result.code === 200) {
|
|
|
console.log(result);
|
|
|
|
|
|
goods = productProcess.processProductList(result.data.product_list);
|
|
|
|
...
|
...
|
@@ -112,67 +106,67 @@ const _getRelatedData = (idList) => { |
|
|
return {};
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
|
|
|
/* 获取用户或者环境相关数据*/
|
|
|
const getPlatForm = (req) => {
|
|
|
let userAgent = req.get('User-Agent');
|
|
|
let yoho = {};
|
|
|
let uids = req.get('User-Agent').match(/uid=([^;]+)/i);
|
|
|
let versions = req.get('User-Agent').match(/app_version=([^;]+)/i);
|
|
|
let arrs = [];
|
|
|
let isNewVersion = false;
|
|
|
const isProduction = process.env.NODE_ENV === 'production';
|
|
|
|
|
|
// console.log(req.get('User-Agent'));
|
|
|
// console.log(req.query.uid);
|
|
|
|
|
|
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);
|
|
|
|
|
|
yoho.app_version = versions && versions.length === 2 ? versions[1] : '';
|
|
|
yoho.app_version = yoho.app_version || req.query.app_version || '';
|
|
|
if (yoho.app_version) {
|
|
|
yoho.app_version = _.toString(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;
|
|
|
// }
|
|
|
// }
|
|
|
if (arrs[0] >= 5) {
|
|
|
isNewVersion = true;
|
|
|
} else if (+arrs[0] === 4 && +arrs[1] === 9 && +arrs[2] > 0) {
|
|
|
isNewVersion = true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
yoho.isSupportStudent = !yoho.isApp || isNewVersion;
|
|
|
yoho.http = 'http:';
|
|
|
if (isProduction) {
|
|
|
yoho.http = 'https:';
|
|
|
}
|
|
|
yoho.uid = uids && uids.length === 2 ? uids[1] : ''; // 8041246
|
|
|
yoho.uid = req.user.uid || yoho.uid || req.query.uid || '';
|
|
|
yoho.isLogin = yoho.uid ? true : false;
|
|
|
return co(function*() {
|
|
|
let data = yield getUser(yoho.uid);
|
|
|
|
|
|
yoho.isStudent = data && data.data && data.data.vip_info && data.data.vip_info.is_student ? true : false;
|
|
|
|
|
|
// yoho.isStudent = false;
|
|
|
// console.log(yoho);
|
|
|
return yoho;
|
|
|
})();
|
|
|
};
|
|
|
};//yao
|
|
|
|
|
|
// /* 获取用户或者环境相关数据*/
|
|
|
// const getPlatForm = (req) => {
|
|
|
// let userAgent = req.get('User-Agent');
|
|
|
// let yoho = {};
|
|
|
// let uids = req.get('User-Agent').match(/uid=([^;]+)/i);
|
|
|
// let versions = req.get('User-Agent').match(/app_version=([^;]+)/i);
|
|
|
// let arrs = [];
|
|
|
// let isNewVersion = false;
|
|
|
// const isProduction = process.env.NODE_ENV === 'production';
|
|
|
|
|
|
// // console.log(req.get('User-Agent'));
|
|
|
// // console.log(req.query.uid);
|
|
|
|
|
|
// 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);
|
|
|
|
|
|
// yoho.app_version = versions && versions.length === 2 ? versions[1] : '';
|
|
|
// yoho.app_version = yoho.app_version || req.query.app_version || '';
|
|
|
// if (yoho.app_version) {
|
|
|
// yoho.app_version = _.toString(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;
|
|
|
// // }
|
|
|
// // }
|
|
|
// if (arrs[0] >= 5) {
|
|
|
// isNewVersion = true;
|
|
|
// } else if (+arrs[0] === 4 && +arrs[1] === 9 && +arrs[2] > 0) {
|
|
|
// isNewVersion = true;
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
// yoho.isSupportStudent = !yoho.isApp || isNewVersion;
|
|
|
// yoho.http = 'http:';
|
|
|
// if (isProduction) {
|
|
|
// yoho.http = 'https:';
|
|
|
// }
|
|
|
// yoho.uid = uids && uids.length === 2 ? uids[1] : ''; // 8041246
|
|
|
// yoho.uid = req.user.uid || yoho.uid || req.query.uid || '';
|
|
|
// yoho.isLogin = yoho.uid ? true : false;
|
|
|
// return co(function*() {
|
|
|
// let data = yield getUser(yoho.uid);
|
|
|
|
|
|
// yoho.isStudent = data && data.data && data.data.vip_info && data.data.vip_info.is_student ? true : false;
|
|
|
|
|
|
// // yoho.isStudent = false;
|
|
|
// // console.log(yoho);
|
|
|
// return yoho;
|
|
|
// })();
|
|
|
// };
|
|
|
|
|
|
exports.index = (req, res, next) => {
|
|
|
let code = '50b995e190ff8cfe52989972a4943b06';
|
...
|
...
|
@@ -238,7 +232,10 @@ exports.index = (req, res, next) => { |
|
|
return item;
|
|
|
});
|
|
|
|
|
|
coupons.data = coupons.data.slice(0, 2);
|
|
|
if (coupons.data.length > 2) {
|
|
|
coupons.data = coupons.data.slice(0, 2);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (studentGoods && studentGoods.data) {
|
...
|
...
|
@@ -277,7 +274,7 @@ exports.index = (req, res, next) => { |
|
|
app_version: req.__USER__.app_version,
|
|
|
isAppNoLogin: req.__USER__.isApp && !req.__USER__.isLogin,
|
|
|
noLoginUrl: noLoginUrl,
|
|
|
page: 'student',
|
|
|
page: 'student-market',
|
|
|
showDownloadApp: true
|
|
|
};
|
|
|
if (!req.__USER__.isApp) {
|
...
|
...
|
@@ -291,7 +288,7 @@ exports.index = (req, res, next) => { |
|
|
if (options.isApp) {
|
|
|
if (options.isLogin) {
|
|
|
if (options.isStudent) {
|
|
|
options.loginUrl = false;
|
|
|
//options.loginUrl = false;
|
|
|
} else {
|
|
|
options.loginUrl = options.loginUrl + '?openby:yohobuy={"action":"go.h5","params":{"islogin":"N","url":"' + req.__USER__.http + '//m.yohobuy.com/activity/student/register"}}';
|
|
|
}
|
...
|
...
|
@@ -302,7 +299,7 @@ exports.index = (req, res, next) => { |
|
|
} else {
|
|
|
if (options.isLogin) {
|
|
|
if (options.isStudent) {
|
|
|
options.loginUrl = false;
|
|
|
//options.loginUrl = false;
|
|
|
}
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -310,373 +307,168 @@ exports.index = (req, res, next) => { |
|
|
// console.log(options);
|
|
|
res.render('student-market', options);
|
|
|
|
|
|
});
|
|
|
|
|
|
// return userAcquireStatus(uid, couponids.join(',')).then((cous) => {
|
|
|
// coupons.data = _.get(coupons, 'data', []).map((item)=>{
|
|
|
// item.status = 1;
|
|
|
// (cous.data || []).forEach((it) => {
|
|
|
|
|
|
// if (+it.couponId === +item.couponID) {
|
|
|
// item.hasNum = it.hasNum;
|
|
|
// item.status = it.status;
|
|
|
// }
|
|
|
// });
|
|
|
// item.couponID = crypto.encryption('yoho9646abcdefgh', item.couponID);
|
|
|
// return item;
|
|
|
// });
|
|
|
|
|
|
// // console.log(datas[1]);
|
|
|
|
|
|
// // datas[1].data = datas[1].data || {};
|
|
|
// // datas[1].data.product_list = (datas[1].data.product_list || []).map(function(value) {
|
|
|
// // value.goodsId = value.goods_list[0].goods_id;
|
|
|
// // value.url = helpers.urlFormat(`/product/pro_${value.product_id}_${value.goodsId}/${value.cn_alphabet}.html`) + `?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":${value.product_skn}}}`;
|
|
|
// // return value;
|
|
|
// // });
|
|
|
|
|
|
// options = {
|
|
|
// isApp: req.__USER__.isApp,
|
|
|
// // goods: datas[1].data.product_list,
|
|
|
// banner: banner,
|
|
|
// icons: icons,
|
|
|
// coupons: coupons,
|
|
|
// activities: activities,
|
|
|
// isStudent: req.__USER__.isStudent,
|
|
|
// isSupportStudent: req.__USER__.isSupportStudent,
|
|
|
// isLogin: req.__USER__.isLogin,
|
|
|
// title: '有货学生专享权益',
|
|
|
// http: req.__USER__.http,
|
|
|
// uid: req.__USER__.uid,
|
|
|
// app_version: req.__USER__.app_version,
|
|
|
// isAppNoLogin: req.__USER__.isApp && !req.__USER__.isLogin,
|
|
|
// noLoginUrl: noLoginUrl,
|
|
|
// page: 'student',
|
|
|
// showDownloadApp: true
|
|
|
// };
|
|
|
// if (!req.__USER__.isApp) {
|
|
|
// options.pageHeader = headerModel.setNav({
|
|
|
// navTitle: options.title,
|
|
|
// navBtn: true
|
|
|
// });
|
|
|
// }
|
|
|
|
|
|
// options.loginUrl = '//m.yohobuy.com/activity/student/register';
|
|
|
// if (options.isApp) {
|
|
|
// if (options.isLogin) {
|
|
|
// if (options.isStudent) {
|
|
|
// options.loginUrl = false;
|
|
|
// } else {
|
|
|
// options.loginUrl = options.loginUrl + '?openby:yohobuy={"action":"go.h5","params":{"islogin":"N","url":"' + req.__USER__.http + '//m.yohobuy.com/activity/student/register"}}';
|
|
|
// }
|
|
|
// } else {
|
|
|
// // no login
|
|
|
// options.loginUrl = options.loginUrl + '?openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"' + req.__USER__.http + '//m.yohobuy.com/activity/student/register","antarget":"1"}}}';
|
|
|
// }
|
|
|
// } else {
|
|
|
// if (options.isLogin) {
|
|
|
// if (options.isStudent) {
|
|
|
// options.loginUrl = false;
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
// // console.log(options);
|
|
|
// res.render('student-market', options);
|
|
|
// });
|
|
|
});
|
|
|
|
|
|
// Promise.all([getResource(code), vip()]).then(datas => {
|
|
|
// let coupons,
|
|
|
// activities,
|
|
|
// banner,
|
|
|
// icons,
|
|
|
// link,
|
|
|
|
|
|
// // url,
|
|
|
// // param,
|
|
|
// couponids = [];
|
|
|
|
|
|
// (datas[0].data || []).forEach((item) => {
|
|
|
// switch (item.template_name) {
|
|
|
// case 'getCoupon':
|
|
|
// coupons = item;
|
|
|
// break;
|
|
|
// case 'image_list':
|
|
|
// activities = item;
|
|
|
// break;
|
|
|
// case 'focus':
|
|
|
// banner = item;
|
|
|
// break;
|
|
|
// case 'recommend_content_five':
|
|
|
// icons = item;
|
|
|
// break;
|
|
|
// case 'link':
|
|
|
// link = item;
|
|
|
// break;
|
|
|
// default:
|
|
|
// // other = item;
|
|
|
// break;
|
|
|
// }
|
|
|
// });
|
|
|
|
|
|
// if (coupons && coupons.data) {
|
|
|
// coupons.link = link && link.data ? link.data[0].url + (req.__USER__.isApp ? '&app_version=' + req.__USER__.app_version : '') : '';
|
|
|
|
|
|
// coupons.data = (coupons.data || []).map((item) => {
|
|
|
// // let url = item.image.url;
|
|
|
// couponids.push(item.couponID);
|
|
|
|
|
|
// // if (!req.__USER__.isLogin) {
|
|
|
// // url = 'http://m.yohobuy.com/activity/student/register?openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"http://m.yohobuy.com/activity/student"}}}';
|
|
|
// // }
|
|
|
// //
|
|
|
// // item.image.noLoginUrl=url;
|
|
|
// return item;
|
|
|
// });
|
|
|
|
|
|
// coupons.data = coupons.data.slice(0, 2);
|
|
|
// }
|
|
|
|
|
|
// return userAcquireStatus(uid, couponids.join(',')).then((cous) => {
|
|
|
// coupons.data = _.get(coupons, 'data', []).map((item)=>{
|
|
|
// item.status = 1;
|
|
|
// (cous.data || []).forEach((it) => {
|
|
|
|
|
|
// if (+it.couponId === +item.couponID) {
|
|
|
// item.hasNum = it.hasNum;
|
|
|
// item.status = it.status;
|
|
|
// }
|
|
|
// });
|
|
|
// item.couponID = crypto.encryption('yoho9646abcdefgh', item.couponID);
|
|
|
// return item;
|
|
|
// });
|
|
|
|
|
|
// // console.log(datas[1]);
|
|
|
|
|
|
// datas[1].data = datas[1].data || {};
|
|
|
// datas[1].data.product_list = (datas[1].data.product_list || []).map(function(value) {
|
|
|
// value.goodsId = value.goods_list[0].goods_id;
|
|
|
// value.url = helpers.urlFormat(`/product/pro_${value.product_id}_${value.goodsId}/${value.cn_alphabet}.html`) + `?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":${value.product_skn}}}`;
|
|
|
// return value;
|
|
|
// });
|
|
|
|
|
|
// options = {
|
|
|
// isApp: req.__USER__.isApp,
|
|
|
// goods: datas[1].data.product_list,
|
|
|
// banner: banner,
|
|
|
// icons: icons,
|
|
|
// coupons: coupons,
|
|
|
// activities: activities,
|
|
|
// isStudent: req.__USER__.isStudent,
|
|
|
// isSupportStudent: req.__USER__.isSupportStudent,
|
|
|
// isLogin: req.__USER__.isLogin,
|
|
|
// title: '有货学生专享权益',
|
|
|
// http: req.__USER__.http,
|
|
|
// uid: req.__USER__.uid,
|
|
|
// app_version: req.__USER__.app_version,
|
|
|
// isAppNoLogin: req.__USER__.isApp && !req.__USER__.isLogin,
|
|
|
// noLoginUrl: noLoginUrl,
|
|
|
// page: 'student',
|
|
|
// showDownloadApp: true
|
|
|
// };
|
|
|
// if (!req.__USER__.isApp) {
|
|
|
// options.pageHeader = headerModel.setNav({
|
|
|
// navTitle: options.title,
|
|
|
// navBtn: true
|
|
|
// });
|
|
|
// }
|
|
|
|
|
|
// options.loginUrl = '//m.yohobuy.com/activity/student/register';
|
|
|
// if (options.isApp) {
|
|
|
// if (options.isLogin) {
|
|
|
// if (options.isStudent) {
|
|
|
// options.loginUrl = false;
|
|
|
// } else {
|
|
|
// options.loginUrl = options.loginUrl + '?openby:yohobuy={"action":"go.h5","params":{"islogin":"N","url":"' + req.__USER__.http + '//m.yohobuy.com/activity/student/register"}}';
|
|
|
// }
|
|
|
// } else {
|
|
|
// // no login
|
|
|
// options.loginUrl = options.loginUrl + '?openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"' + req.__USER__.http + '//m.yohobuy.com/activity/student/register","antarget":"1"}}}';
|
|
|
// }
|
|
|
// } else {
|
|
|
// if (options.isLogin) {
|
|
|
// if (options.isStudent) {
|
|
|
// options.loginUrl = false;
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
// // console.log(options);
|
|
|
// res.render('student-market', options);
|
|
|
// });
|
|
|
|
|
|
|
|
|
// }).catch(next);
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
exports.province = (req, res, next) => {
|
|
|
getProvince().then((result) => {
|
|
|
res.json(result);
|
|
|
}).catch(next);
|
|
|
};
|
|
|
|
|
|
exports.register = (req, res, next) => {
|
|
|
let years = [],
|
|
|
refer;
|
|
|
|
|
|
for (let i = 0; i < 8; i++) {
|
|
|
years.push((new Date()).getFullYear() - i);
|
|
|
}
|
|
|
Promise.all([verifiedStudentTotal(), getEducationLevelList()]).then((arr) => {
|
|
|
if (req.__USER__.isStudent) {
|
|
|
refer = '/activity/student?uid=' + req.__USER__.uid;// 所有认证过的,都跳转学生首页
|
|
|
|
|
|
|
|
|
res.redirect(helpers.urlFormat(refer));
|
|
|
} else {
|
|
|
res.render('register', {
|
|
|
title: '认证信息填写',
|
|
|
isApp: req.__USER__.isApp,
|
|
|
count: arr[0].data,
|
|
|
educations: arr[1].data,
|
|
|
educationsStr: JSON.stringify(arr[1].data),
|
|
|
years: years,
|
|
|
yearsStr: JSON.stringify(years),
|
|
|
module: 'activity',
|
|
|
page: 'register',
|
|
|
http: req.__USER__.http
|
|
|
});
|
|
|
}
|
|
|
}).catch(next);
|
|
|
};
|
|
|
|
|
|
exports.school = (req, res, next) => {
|
|
|
let code = req.query.code;
|
|
|
|
|
|
getSchool(code).then((result) => {
|
|
|
res.json(result);
|
|
|
}).catch(next);
|
|
|
};
|
|
|
|
|
|
exports.verifyidentity = (req, res, next) => {
|
|
|
// let uid=req.user.id;
|
|
|
let params = req.body;
|
|
|
let uid = req.__USER__.uid;
|
|
|
let url = 'http://m.yohobuy.com/activity/student/verify?' +
|
|
|
queryString.stringify({
|
|
|
college_name: params.college_name,
|
|
|
education_degree: params.education_degree,
|
|
|
enrollment_year: params.enrollment_year,
|
|
|
uid: req.__USER__.isApp ? uid : '',
|
|
|
}) + '&';
|
|
|
|
|
|
verifyIdentity(uid, params.cert_no, params.name, url).then((result) => {
|
|
|
res.json(result);
|
|
|
}).catch(next);
|
|
|
};
|
|
|
|
|
|
exports.verifystudent = (req, res, next) => {
|
|
|
let params = req.query;
|
|
|
|
|
|
let uid = req.__USER__.uid;
|
|
|
|
|
|
Promise.all([verifiedStudentTotal(), vip(), verifyStudent(uid, params.college_name, params.education_degree, params.enrollment_year, params.token)])
|
|
|
.then((datas) => {
|
|
|
let isverify = false,
|
|
|
prompt = '您的学校信息未通过审核';
|
|
|
|
|
|
if (datas[2].code === 200) {
|
|
|
if (datas[2].data.isStudent === 1) {
|
|
|
isverify = true;
|
|
|
prompt = datas[2].data.prompt;
|
|
|
}
|
|
|
} else {
|
|
|
if (datas[2].code === 500) {
|
|
|
prompt = '请重新认证!';
|
|
|
} else {
|
|
|
prompt = datas[2].message;
|
|
|
}
|
|
|
}
|
|
|
datas[1].data.product_list = datas[1].data.product_list.map(function(value) {
|
|
|
value.goodsId = value.goods_list[0].goods_id;
|
|
|
value.url = helpers.urlFormat(`/product/pro_${value.product_id}_${value.goodsId}/${value.cn_alphabet}.html`) + `?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":${value.product_skn}}}`;
|
|
|
return value;
|
|
|
});
|
|
|
return getUser(uid).then((user) => {
|
|
|
res.render('verify', {
|
|
|
isApp: req.__USER__.isApp,
|
|
|
count: datas[0].data,
|
|
|
goods: datas[1].data.product_list,
|
|
|
isverify: isverify,
|
|
|
prompt: prompt,
|
|
|
isLogin: user.data && user.data.vip_info && user.data.vip_info.is_student ? true : false,
|
|
|
title: '学生身份认证',
|
|
|
http: req.__USER__.http,
|
|
|
uid: req.__USER__.uid,
|
|
|
app_version: req.__USER__.app_version
|
|
|
});
|
|
|
}).catch(next);
|
|
|
|
|
|
}).catch(next);
|
|
|
});
|
|
|
};
|
|
|
|
|
|
exports.detail = (req, res) => {
|
|
|
let type = req.params.type,
|
|
|
options;
|
|
|
|
|
|
if (type === 'renzhen') {
|
|
|
options = {
|
|
|
title: '认证协议',
|
|
|
isRenZhen: true
|
|
|
};
|
|
|
} else {
|
|
|
options = {
|
|
|
title: '更多学生权益',
|
|
|
isQuanYi: true
|
|
|
};
|
|
|
}
|
|
|
options.isApp = req.__USER__.isApp;
|
|
|
res.render('detail', options);
|
|
|
};
|
|
|
|
|
|
exports.isLogin = (req, res, next) => {
|
|
|
// let refer = req.cookies.refer;
|
|
|
let url = req.get('referer') || '/activity/student/register';
|
|
|
|
|
|
|
|
|
getPlatForm(req).then((yoho)=>{
|
|
|
if (yoho.uid) {
|
|
|
req.__USER__ = yoho;
|
|
|
next();
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// refer = decodeURI(req.cookies.refer)||req.get("refer");
|
|
|
//
|
|
|
// if (refer) {
|
|
|
// refer = decodeURI(req.cookies.refer)||req.get("refer");
|
|
|
// } else {
|
|
|
// refer = '/activity/student/register';
|
|
|
// }
|
|
|
|
|
|
|
|
|
if (req.path === '/student/register' && !yoho.isStudent) {
|
|
|
url = '/activity/student/register';
|
|
|
}
|
|
|
res.redirect(helpers.urlFormat('/signin.html', {
|
|
|
refer: url
|
|
|
}));
|
|
|
}).catch(next);
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
exports.getUser = (req, res, next)=>{
|
|
|
getPlatForm(req).then((yoho)=>{
|
|
|
req.__USER__ = yoho;
|
|
|
next();
|
|
|
}).catch(next);
|
|
|
}; |
|
|
// exports.province = (req, res, next) => {
|
|
|
// getProvince().then((result) => {
|
|
|
// res.json(result);
|
|
|
// }).catch(next);
|
|
|
// };
|
|
|
|
|
|
// exports.register = (req, res, next) => {
|
|
|
// let years = [],
|
|
|
// refer;
|
|
|
|
|
|
// for (let i = 0; i < 8; i++) {
|
|
|
// years.push((new Date()).getFullYear() - i);
|
|
|
// }
|
|
|
// Promise.all([verifiedStudentTotal(), getEducationLevelList()]).then((arr) => {
|
|
|
// if (req.__USER__.isStudent) {
|
|
|
// refer = '/activity/student-market?uid=' + req.__USER__.uid;// 所有认证过的,都跳转学生首页
|
|
|
|
|
|
// res.redirect(helpers.urlFormat(refer));
|
|
|
// } else {
|
|
|
// res.render('register', {
|
|
|
// title: '认证信息填写',
|
|
|
// isApp: req.__USER__.isApp,
|
|
|
// count: arr[0].data,
|
|
|
// educations: arr[1].data,
|
|
|
// educationsStr: JSON.stringify(arr[1].data),
|
|
|
// years: years,
|
|
|
// yearsStr: JSON.stringify(years),
|
|
|
// module: 'activity',
|
|
|
// page: 'register',
|
|
|
// http: req.__USER__.http
|
|
|
// });
|
|
|
// }
|
|
|
// }).catch(next);
|
|
|
// };
|
|
|
|
|
|
// exports.school = (req, res, next) => {
|
|
|
// let code = req.query.code;
|
|
|
|
|
|
// getSchool(code).then((result) => {
|
|
|
// res.json(result);
|
|
|
// }).catch(next);
|
|
|
// };
|
|
|
|
|
|
// exports.verifyidentity = (req, res, next) => {
|
|
|
// // let uid=req.user.id;
|
|
|
// let params = req.body;
|
|
|
// let uid = req.__USER__.uid;
|
|
|
// let url = 'http://m.yohobuy.com/activity/student/verify?' +
|
|
|
// queryString.stringify({
|
|
|
// college_name: params.college_name,
|
|
|
// education_degree: params.education_degree,
|
|
|
// enrollment_year: params.enrollment_year,
|
|
|
// uid: req.__USER__.isApp ? uid : '',
|
|
|
// }) + '&';
|
|
|
|
|
|
// verifyIdentity(uid, params.cert_no, params.name, url).then((result) => {
|
|
|
// res.json(result);
|
|
|
// }).catch(next);
|
|
|
// };
|
|
|
|
|
|
// exports.verifystudent = (req, res, next) => {
|
|
|
// let params = req.query;
|
|
|
|
|
|
// let uid = req.__USER__.uid;
|
|
|
|
|
|
// Promise.all([verifiedStudentTotal(), vip(), verifyStudent(uid, params.college_name, params.education_degree, params.enrollment_year, params.token)])
|
|
|
// .then((datas) => {
|
|
|
// let isverify = false,
|
|
|
// prompt = '您的学校信息未通过审核';
|
|
|
|
|
|
// if (datas[2].code === 200) {
|
|
|
// if (datas[2].data.isStudent === 1) {
|
|
|
// isverify = true;
|
|
|
// prompt = datas[2].data.prompt;
|
|
|
// }
|
|
|
// } else {
|
|
|
// if (datas[2].code === 500) {
|
|
|
// prompt = '请重新认证!';
|
|
|
// } else {
|
|
|
// prompt = datas[2].message;
|
|
|
// }
|
|
|
// }
|
|
|
// datas[1].data.product_list = datas[1].data.product_list.map(function(value) {
|
|
|
// value.goodsId = value.goods_list[0].goods_id;
|
|
|
// value.url = helpers.urlFormat(`/product/pro_${value.product_id}_${value.goodsId}/${value.cn_alphabet}.html`) + `?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":${value.product_skn}}}`;
|
|
|
// return value;
|
|
|
// });
|
|
|
// return getUser(uid).then((user) => {
|
|
|
// res.render('verify', {
|
|
|
// isApp: req.__USER__.isApp,
|
|
|
// count: datas[0].data,
|
|
|
// goods: datas[1].data.product_list,
|
|
|
// isverify: isverify,
|
|
|
// prompt: prompt,
|
|
|
// isLogin: user.data && user.data.vip_info && user.data.vip_info.is_student ? true : false,
|
|
|
// title: '学生身份认证',
|
|
|
// http: req.__USER__.http,
|
|
|
// uid: req.__USER__.uid,
|
|
|
// app_version: req.__USER__.app_version
|
|
|
// });
|
|
|
// }).catch(next);
|
|
|
|
|
|
// }).catch(next);
|
|
|
// };
|
|
|
|
|
|
// exports.detail = (req, res) => {
|
|
|
// let type = req.params.type,
|
|
|
// options;
|
|
|
|
|
|
// if (type === 'renzhen') {
|
|
|
// options = {
|
|
|
// title: '认证协议',
|
|
|
// isRenZhen: true
|
|
|
// };
|
|
|
// } else {
|
|
|
// options = {
|
|
|
// title: '更多学生权益',
|
|
|
// isQuanYi: true
|
|
|
// };
|
|
|
// }
|
|
|
// options.isApp = req.__USER__.isApp;
|
|
|
// res.render('detail', options);
|
|
|
// };
|
|
|
|
|
|
// exports.isLogin = (req, res, next) => {
|
|
|
// // let refer = req.cookies.refer;
|
|
|
// let url = req.get('referer') || '/activity/student/register';
|
|
|
|
|
|
// getPlatForm(req).then((yoho)=>{
|
|
|
// if (yoho.uid) {
|
|
|
// req.__USER__ = yoho;
|
|
|
// next();
|
|
|
// return;
|
|
|
// }
|
|
|
|
|
|
// // refer = decodeURI(req.cookies.refer)||req.get("refer");
|
|
|
// //
|
|
|
// // if (refer) {
|
|
|
// // refer = decodeURI(req.cookies.refer)||req.get("refer");
|
|
|
// // } else {
|
|
|
// // refer = '/activity/student/register';
|
|
|
// // }
|
|
|
|
|
|
|
|
|
// if (req.path === '/student/register' && !yoho.isStudent) {
|
|
|
// url = '/activity/student/register';
|
|
|
// }
|
|
|
// res.redirect(helpers.urlFormat('/signin.html', {
|
|
|
// refer: url
|
|
|
// }));
|
|
|
// }).catch(next);
|
|
|
|
|
|
|
|
|
// };
|
|
|
|
|
|
// exports.getUser = (req, res, next)=>{
|
|
|
// getPlatForm(req).then((yoho)=>{
|
|
|
// req.__USER__ = yoho;
|
|
|
// next();
|
|
|
// }).catch(next);
|
|
|
// }; |
...
|
...
|
|