Authored by htoooth

Merge branch 'feature/format' of http://git.yoho.cn/fe/yohobuy-node into feature/format

@@ -149,13 +149,13 @@ app.use((req, res, next) => { @@ -149,13 +149,13 @@ app.use((req, res, next) => {
149 req.session = {}; 149 req.session = {};
150 } 150 }
151 151
152 - req.app.locals = _.merge(req.app.locals, {  
153 - pc: {  
154 - geetest: {  
155 - validation: false  
156 - }  
157 - }  
158 - }); 152 + // req.app.locals = _.merge(req.app.locals, {
  153 + // pc: {
  154 + // geetest: {
  155 + // validation: true
  156 + // }
  157 + // }
  158 + // });
159 159
160 next(); 160 next();
161 }); 161 });
@@ -325,14 +325,18 @@ const checkFav = (req, res) => { @@ -325,14 +325,18 @@ const checkFav = (req, res) => {
325 co(function * () { 325 co(function * () {
326 326
327 let uid = req.user.uid; 327 let uid = req.user.uid;
328 - let pids = req.body.pidList.split(',');  
329 let ret = { 328 let ret = {
330 - code: 200, 329 + code: 400,
331 message: '是否收藏', 330 message: '是否收藏',
332 data: {} 331 data: {}
333 }; 332 };
334 333
335 - ret.data = yield service.checkUserIsFav(uid, pids); 334 + if (uid && req.body.pidList) {
  335 + let pids = req.body.pidList.split(',');
  336 +
  337 + Object.assign(ret, {code: 200,
  338 + data: yield service.checkUserIsFav(uid, pids)});
  339 + }
336 340
337 return res.send(ret); 341 return res.send(ret);
338 })(); 342 })();
@@ -89,7 +89,7 @@ @@ -89,7 +89,7 @@
89 <ul class="package-goods clearfix"> 89 <ul class="package-goods clearfix">
90 {{#each goods_list}} 90 {{#each goods_list}}
91 <li class="left"> 91 <li class="left">
92 - <img class="lazy package-goods-img" data-original="{{image goods_images 68 90}}"> 92 + <img class="lazy package-goods-img" data-original="{{image2 goods_images w=68 h=90}}">
93 {{#isEqual goods_type 'gift'}} 93 {{#isEqual goods_type 'gift'}}
94 <span>赠品</span> 94 <span>赠品</span>
95 {{/isEqual}} 95 {{/isEqual}}
@@ -124,7 +124,7 @@ @@ -124,7 +124,7 @@
124 <td{{#if @first}} class="border-top"{{/if}}></td> 124 <td{{#if @first}} class="border-top"{{/if}}></td>
125 <td class="border-top aline-left"> 125 <td class="border-top aline-left">
126 <a class="image" href="{{linkToGoods}}"> 126 <a class="image" href="{{linkToGoods}}">
127 - <img src="{{image goods_images 64 85}}" class="thumb"> 127 + <img src="{{image2 goods_images w=64 h=85}}" class="thumb">
128 <p class="name"> 128 <p class="name">
129 {{#isEqual goods_type 'gift'}} 129 {{#isEqual goods_type 'gift'}}
130 <span>赠品</span> 130 <span>赠品</span>
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 {{# imgBrand}} 4 {{# imgBrand}}
5 <li class="img-item"> 5 <li class="img-item">
6 <a href="{{url}}" target= "_blank" title="{{title}}"> 6 <a href="{{url}}" target= "_blank" title="{{title}}">
7 - <img data-original="{{image src 378 175}}" src="{{image2 src w=378 h=175}}" alt="{{alt}}"> 7 + <img data-original="{{image2 src w=378 h=175}}" src="{{image2 src w=378 h=175}}" alt="{{alt}}">
8 </a> 8 </a>
9 </li> 9 </li>
10 {{/ imgBrand}} 10 {{/ imgBrand}}
@@ -26,13 +26,6 @@ const checkAPI = (req, res) => { @@ -26,13 +26,6 @@ const checkAPI = (req, res) => {
26 img.checkAPI)(req, res); 26 img.checkAPI)(req, res);
27 }; 27 };
28 28
29 -// 重定向调用  
30 -const requiredPage = (req, res, next) => {  
31 - return (_.get(req.app.locals.pc, 'geetest.validation', false) ?  
32 - gee.requiredPage :  
33 - img.requiredPage)(req, res, next);  
34 -};  
35 -  
36 const passwordRequired = (req, res, next) => { 29 const passwordRequired = (req, res, next) => {
37 if (req.body.loginType === 'password') { 30 if (req.body.loginType === 'password') {
38 return requiredAPI(req, res, next); 31 return requiredAPI(req, res, next);
@@ -43,7 +36,6 @@ const passwordRequired = (req, res, next) => { @@ -43,7 +36,6 @@ const passwordRequired = (req, res, next) => {
43 36
44 module.exports = { 37 module.exports = {
45 requiredAPI, 38 requiredAPI,
46 - requiredPage,  
47 generate, 39 generate,
48 checkAPI, 40 checkAPI,
49 passwordRequired 41 passwordRequired
@@ -9,8 +9,6 @@ const Geetest = require('../models/captcha-gee-service'); @@ -9,8 +9,6 @@ const Geetest = require('../models/captcha-gee-service');
9 9
10 const config = global.yoho.config; 10 const config = global.yoho.config;
11 const logger = global.yoho.logger; 11 const logger = global.yoho.logger;
12 -const helpers = global.yoho.helpers;  
13 -  
14 const CAPTCHA = config.UNIVERSAL_CAPTCHA; 12 const CAPTCHA = config.UNIVERSAL_CAPTCHA;
15 13
16 // 对比函数 14 // 对比函数
@@ -126,40 +124,8 @@ const checkAPI = (req, res) => { @@ -126,40 +124,8 @@ const checkAPI = (req, res) => {
126 }); 124 });
127 }; 125 };
128 126
129 -// 重定向调用  
130 -const requiredPage = (req, res, next) => {  
131 - let verifyCode = req.body.verifyCode || '';  
132 - let captcha = verifyCode.split(',');  
133 -  
134 - if (!verifyCode) {  
135 - return res.redirect(helpers.urlFormat('/passport/back/index'));  
136 - }  
137 -  
138 - if (_mustEqual(req)) {  
139 - return next();  
140 - } else {  
141 - pcGeetest.validate({  
142 - challenge: captcha[0],  
143 - validate: captcha[1],  
144 - seccode: captcha[2]  
145 - }, function(err, success) {  
146 - logger.info(`geetest captcha auth [${err ? 'fail' : 'success'}]`,  
147 - `CLIENT [${req.body.verifyCode}] SERVER [${err}]`);  
148 -  
149 - if (err) {  
150 - return res.redirect(helpers.urlFormat('/passport/back/index'));  
151 - } else if (!success) {  
152 - return res.redirect(helpers.urlFormat('/passport/back/index'));  
153 - } else {  
154 - return next();  
155 - }  
156 - });  
157 - }  
158 -};  
159 -  
160 module.exports = { 127 module.exports = {
161 generate, 128 generate,
162 requiredAPI, 129 requiredAPI,
163 - checkAPI,  
164 - requiredPage 130 + checkAPI
165 }; 131 };
@@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
7 // const _ = require('lodash'); 7 // const _ = require('lodash');
8 8
9 const captchaService = require('../models/captcha-img-service'); 9 const captchaService = require('../models/captcha-img-service');
10 -const helpers = global.yoho.helpers;  
11 const CAPTCHA = global.yoho.config.UNIVERSAL_CAPTCHA; 10 const CAPTCHA = global.yoho.config.UNIVERSAL_CAPTCHA;
12 const request = require('request'); 11 const request = require('request');
13 const logger = global.yoho.logger; 12 const logger = global.yoho.logger;
@@ -47,24 +46,6 @@ const requiredAPI = (req, res, next) => { @@ -47,24 +46,6 @@ const requiredAPI = (req, res, next) => {
47 } 46 }
48 }; 47 };
49 48
50 -// 重定向调用  
51 -const requiredPage = (req, res, next) => {  
52 - let count = req.session.captchaCount;  
53 -  
54 - if (count >= 4) {  
55 - req.session.captcha = CAPTCHA;  
56 -  
57 - return res.redirect(helpers.urlFormat('/passport/back/index'));  
58 - }  
59 -  
60 - req.session.captchaCount = count + 1;  
61 - if (_mustEqual(req)) {  
62 - return next();  
63 - } else {  
64 - return res.redirect(helpers.urlFormat('/passport/back/index'));  
65 - }  
66 -};  
67 -  
68 // 七牛验证码 49 // 七牛验证码
69 const generate = (req, res, next) => { 50 const generate = (req, res, next) => {
70 captchaService.generateCaptcha().then((result) => { 51 captchaService.generateCaptcha().then((result) => {
@@ -108,7 +89,6 @@ const checkAPI = (req, res) => { @@ -108,7 +89,6 @@ const checkAPI = (req, res) => {
108 89
109 module.exports = { 90 module.exports = {
110 requiredAPI, 91 requiredAPI,
111 - requiredPage,  
112 generate, 92 generate,
113 checkAPI 93 checkAPI
114 }; 94 };
@@ -62,7 +62,7 @@ @@ -62,7 +62,7 @@
62 {{#each trendList}} 62 {{#each trendList}}
63 <li> 63 <li>
64 <a href="{{href}}"> 64 <a href="{{href}}">
65 - <img src="{{image src 264 173}}" /> 65 + <img src="{{image2 src w=264 h=173}}" />
66 <div class="main-title">{{mainTitle}}</div> 66 <div class="main-title">{{mainTitle}}</div>
67 <div class="sub-title">{{Subtitle}}</div> 67 <div class="sub-title">{{Subtitle}}</div>
68 </a> 68 </a>
1 {{# mainBanner}} 1 {{# mainBanner}}
2 - <div class="main-banner slide-container"{{#unless list}} style="background:url({{image src 1920 450}}) no-repeat top center;"{{/unless}}> 2 + <div class="main-banner slide-container"{{#unless list}} style="background:url({{image2 src w=1920 h=450}}) no-repeat top center;"{{/unless}}>
3 {{#if list}} 3 {{#if list}}
4 <div class="slide-wrapper"> 4 <div class="slide-wrapper">
5 <ul> 5 <ul>
6 {{# list}} 6 {{# list}}
7 - <li class="banner-img" style="background: {{bgColor}} url({{image src 1920 450}}) no-repeat top center;"> 7 + <li class="banner-img" style="background: {{bgColor}} url({{image2 src w=1920 h=450}}) no-repeat top center;">
8 {{#if url}} 8 {{#if url}}
9 <a href="{{url}}" target= "_blank"></a> 9 <a href="{{url}}" target= "_blank"></a>
10 {{/if}} 10 {{/if}}
1 {{# banner}} 1 {{# banner}}
2 - <div class="brand-banner" style="background:{{bgColor}}{{#if bgImg}} url({{image bgImg 1920 45}}){{/if}}"> 2 + <div class="brand-banner" style="background:{{bgColor}}{{#if bgImg}} url({{image2 bgImg w=1920 h=45}}){{/if}}">
3 {{#if homeUrl}} 3 {{#if homeUrl}}
4 <div class="center-content clearfix"> 4 <div class="center-content clearfix">
5 <a class="pull-left" href="{{homeUrl}}"> 5 <a class="pull-left" href="{{homeUrl}}">
6 - <img src="{{image logo 45 45}}"> 6 + <img src="{{image2 logo w=45 h=45}}">
7 </a> 7 </a>
8 8
9 <div class="opt pull-right"> 9 <div class="opt pull-right">
1 { 1 {
2 "name": "yohobuy-node", 2 "name": "yohobuy-node",
3 - "version": "5.5.3", 3 + "version": "5.5.8",
4 "private": true, 4 "private": true,
5 "description": "A New Yohobuy Project With Express", 5 "description": "A New Yohobuy Project With Express",
6 "repository": { 6 "repository": {
@@ -10,6 +10,7 @@ @@ -10,6 +10,7 @@
10 "scripts": { 10 "scripts": {
11 "start": "node app.js", 11 "start": "node app.js",
12 "dev": "nodemon -e js,hbs -i public/ app.js", 12 "dev": "nodemon -e js,hbs -i public/ app.js",
  13 + "build": "gulp ge --cwd=public",
13 "online": "NODE_ENV=\"production\" node app.js", 14 "online": "NODE_ENV=\"production\" node app.js",
14 "debug": "DEBUG=\"express:*\" nodemon -e js,hbs -i public/ app.js", 15 "debug": "DEBUG=\"express:*\" nodemon -e js,hbs -i public/ app.js",
15 "lint-js": "eslint -c .eslintrc --cache --fix .", 16 "lint-js": "eslint -c .eslintrc --cache --fix .",
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 <div class="color-row"> 5 <div class="color-row">
6 {{#each colors}} 6 {{#each colors}}
7 <div class="dt {{#if active}} active current-color{{/if}} {{#if disable}} disabled{{/if}}" 7 <div class="dt {{#if active}} active current-color{{/if}} {{#if disable}} disabled{{/if}}"
8 - data-pic="{{image pic 100 134}}" 8 + data-pic="{{image2 pic w=100 h=134}}"
9 data-pid="{{pid}}" 9 data-pid="{{pid}}"
10 {{!--data-target="{{proId}}-color-{{@index}}" 10 {{!--data-target="{{proId}}-color-{{@index}}"
11 data-title="{{this.color}}" --}} 11 data-title="{{this.color}}" --}}
@@ -40,9 +40,9 @@ @@ -40,9 +40,9 @@
40 {{# colors}} 40 {{# colors}}
41 <div class="big-img {{#unless active}} hide{{/unless}}"> 41 <div class="big-img {{#unless active}} hide{{/unless}}">
42 {{#if pic}} 42 {{#if pic}}
43 - <img src="{{image pic 100 134}}" /> 43 + <img src="{{image2 pic w=100 h=134}}" />
44 {{else}} 44 {{else}}
45 - <img src="{{image ../defaultImg 100 134}}" /> 45 + <img src="{{image2 ../defaultImg w=100 h=134}}" />
46 {{/if}} 46 {{/if}}
47 </div> 47 </div>
48 {{/ colors}} 48 {{/ colors}}
@@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
14 <div class="good-info" data-skn="{{skn}}" data-id="{{id}}" data-index="{{@index}}"> 14 <div class="good-info" data-skn="{{skn}}" data-id="{{id}}" data-index="{{@index}}">
15 <div class="good-detail-img"> 15 <div class="good-detail-img">
16 <a class="good-thumb" href="{{url}}" target="_blank"> 16 <a class="good-thumb" href="{{url}}" target="_blank">
17 - <img class="lazy" src="{{image src 100 135}}" style="display: block;"> 17 + <img class="lazy" src="{{image2 src w=100 h=135}}" style="display: block;">
18 </a> 18 </a>
19 </div> 19 </div>
20 <div class="good-detail-text stu-good-detail "> 20 <div class="good-detail-text stu-good-detail ">