...
|
...
|
@@ -10,78 +10,13 @@ const headerModel = require('../../../doraemon/models/header'); // 头部model |
|
|
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 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
|
|
|
});
|
|
|
};// 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
|
|
|
// });
|
|
|
// };
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 查询商品
|
...
|
...
|
@@ -106,67 +41,7 @@ const _getRelatedData = (idList) => { |
|
|
return {};
|
|
|
}
|
|
|
});
|
|
|
};// 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';
|
...
|
...
|
@@ -310,165 +185,3 @@ exports.index = (req, res, 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);
|
|
|
// }; |
...
|
...
|
|