Authored by weiqingting

Merge branch 'feature_student' into release/4.9.1.0

# Conflicts:
#	apps/product/models/detail.js
#	config/common.js
#	public/scss/common/_good.css
@@ -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
@@ -77,7 +77,7 @@ @@ -77,7 +77,7 @@
77 {{/activities}} 77 {{/activities}}
78 78
79 <section class='s-section clearfix'> 79 <section class='s-section clearfix'>
80 - <h1>学生专享商品<a class="more iconfont" href="//search.m.yohobuy.com/?students=1&title=学生专享商品&uid={{uid}}{{#isApp}}&app_version=1{{/isApp}}">&#xe618;</a></h1> 80 + <h1>学生专享商品<a class="more iconfont" href="//search.m.yohobuy.com/?students=1&title=学生专享商品&uid={{uid}}{{#isApp}}&app_version={{@root.app_version}}{{/isApp}}">&#xe618;</a></h1>
81 <div class='goods-list clearfix'> 81 <div class='goods-list clearfix'>
82 {{#each goods}} 82 {{#each goods}}
83 <div class="good-info"> 83 <div class="good-info">
@@ -119,7 +119,7 @@ @@ -119,7 +119,7 @@
119 </div> 119 </div>
120 {{/each}} 120 {{/each}}
121 </div> 121 </div>
122 - <a class='s-more' href='//search.m.yohobuy.com/?students=1&title=学生专享商品&uid={{uid}}{{#isApp}}&app_version=1{{/isApp}}'>查看更多</a> 122 + <a class='s-more' href='//search.m.yohobuy.com/?students=1&title=学生专享商品&uid={{uid}}{{#isApp}}&app_version={{@root.app_version}}{{/isApp}}'>查看更多</a>
123 </section> 123 </section>
124 124
125 {{#loginUrl}} 125 {{#loginUrl}}
@@ -20,7 +20,7 @@ @@ -20,7 +20,7 @@
20 </section> 20 </section>
21 {{/if}} 21 {{/if}}
22 <section class='s-section clearfix'> 22 <section class='s-section clearfix'>
23 - <h1>学生专享商品<a class="more iconfont" href="//search.m.yohobuy.com/?students=1&title=学生专享商品&uid={{uid}}{{#isApp}}&app_version=1{{/isApp}}">&#xe618;</a></h1> 23 + <h1>学生专享商品<a class="more iconfont" href="//search.m.yohobuy.com/?students=1&title=学生专享商品&uid={{uid}}{{#isApp}}&app_version={{@root.app_version}}{{/isApp}}">&#xe618;</a></h1>
24 <div class='goods-list clearfix'> 24 <div class='goods-list clearfix'>
25 {{#each goods}} 25 {{#each goods}}
26 <div class="good-info"> 26 <div class="good-info">
@@ -62,7 +62,7 @@ @@ -62,7 +62,7 @@
62 </div> 62 </div>
63 {{/each}} 63 {{/each}}
64 </div> 64 </div>
65 - <a class='s-more' href="//search.m.yohobuy.com/?students=1&title=学生专享商品{{#isApp}}&app_version=1{{/isApp}}">查看更多</a> 65 + <a class='s-more' href="//search.m.yohobuy.com/?students=1&title=学生专享商品{{#isApp}}&app_version={{@root.app_version}}{{/isApp}}">查看更多</a>
66 </section> 66 </section>
67 </div> 67 </div>
68 </div> 68 </div>