Showing
23 changed files
with
264 additions
and
133 deletions
@@ -148,17 +148,6 @@ app.use((req, res, next) => { | @@ -148,17 +148,6 @@ app.use((req, res, next) => { | ||
148 | req.yoho = {}; // req和res绑定yoho对象,用于传递全局数据, 如req.yoho.channel等 | 148 | req.yoho = {}; // req和res绑定yoho对象,用于传递全局数据, 如req.yoho.channel等 |
149 | req.app.locals.wap = app.locals.wap; // zookeper对象赋值 | 149 | req.app.locals.wap = app.locals.wap; // zookeper对象赋值 |
150 | 150 | ||
151 | - // 临时增加错误日志记录 | ||
152 | - let sendJson = res.json; | ||
153 | - | ||
154 | - res.json = function(...args) { | ||
155 | - try { | ||
156 | - sendJson(...args); | ||
157 | - } catch (e) { | ||
158 | - logger.error(`res.json error data: ${JSON.stringify(args)}`); | ||
159 | - } | ||
160 | - }; | ||
161 | - | ||
162 | next(); | 151 | next(); |
163 | }); | 152 | }); |
164 | 153 |
@@ -241,7 +241,7 @@ const getPriceGiftList = (promotionIds, promotionType) => { | @@ -241,7 +241,7 @@ const getPriceGiftList = (promotionIds, promotionType) => { | ||
241 | method: 'app.Shopping.queryPromotionGifts', | 241 | method: 'app.Shopping.queryPromotionGifts', |
242 | promotion_ids: promotionIds | 242 | promotion_ids: promotionIds |
243 | }).then((data) => { | 243 | }).then((data) => { |
244 | - return data.code === 200 ? cartProcess.procPriceGiftData(data.data, promotionType) : void 0; | 244 | + return data.code === 200 ? cartProcess.procPriceGiftData(data.data, promotionType) : {}; |
245 | }); | 245 | }); |
246 | }; | 246 | }; |
247 | 247 |
@@ -42,7 +42,7 @@ const _packageAd = (params) => { | @@ -42,7 +42,7 @@ const _packageAd = (params) => { | ||
42 | 42 | ||
43 | const _packageList = (channel) => { | 43 | const _packageList = (channel) => { |
44 | return api.get('', { | 44 | return api.get('', { |
45 | - method: 'app.brand.newBrandList', | 45 | + method: 'app.brand.allBrandList', |
46 | yh_channel: channel | 46 | yh_channel: channel |
47 | }, { | 47 | }, { |
48 | cache: true, | 48 | cache: true, |
@@ -172,7 +172,12 @@ const getBrandListByChannel = (channel) => { | @@ -172,7 +172,12 @@ const getBrandListByChannel = (channel) => { | ||
172 | name: row.brand_name, | 172 | name: row.brand_name, |
173 | isHot: row.is_hot === 'Y' ? true : false, | 173 | isHot: row.is_hot === 'Y' ? true : false, |
174 | isNew: row.is_show_new === 'Y' ? true : false, | 174 | isNew: row.is_show_new === 'Y' ? true : false, |
175 | - url: helpers.urlFormat('/product/index/brand?domain=' + row.brand_domain) | 175 | + url: parseInt(row.type, 10) !== 3 ? helpers.urlFormat('/product/index/brand', { |
176 | + domain: row.brand_domain, | ||
177 | + shopType: row.type | ||
178 | + }) : helpers.urlFormat('/product/global/list/', { | ||
179 | + brand: row.global_brand_id | ||
180 | + }) | ||
176 | }); | 181 | }); |
177 | }); | 182 | }); |
178 | resu.brandList.push(obj); | 183 | resu.brandList.push(obj); |
@@ -190,7 +195,10 @@ const getBrandListByChannel = (channel) => { | @@ -190,7 +195,10 @@ const getBrandListByChannel = (channel) => { | ||
190 | 195 | ||
191 | obj.list.push({ | 196 | obj.list.push({ |
192 | brandName: newList[key].brand_name, | 197 | brandName: newList[key].brand_name, |
193 | - url: helpers.urlFormat('/product/index/brand?domain=' + newList[key].brand_domain), | 198 | + url: helpers.urlFormat('/product/index/brand', { |
199 | + domain: newList[key].brand_domain, | ||
200 | + shopType: newList[key].type | ||
201 | + }), | ||
194 | img: helpers.image(newList[key].brand_ico, 186, 115), | 202 | img: helpers.image(newList[key].brand_ico, 186, 115), |
195 | }); | 203 | }); |
196 | resu.newBrandWall.push(obj); | 204 | resu.newBrandWall.push(obj); |
@@ -208,7 +216,10 @@ const getBrandListByChannel = (channel) => { | @@ -208,7 +216,10 @@ const getBrandListByChannel = (channel) => { | ||
208 | 216 | ||
209 | obj.list.push({ | 217 | obj.list.push({ |
210 | brandName: hotList[key].brand_name, | 218 | brandName: hotList[key].brand_name, |
211 | - url: helpers.urlFormat('/product/index/brand?domain=' + hotList[key].brand_domain), | 219 | + url: helpers.urlFormat('/product/index/brand', { |
220 | + domain: hotList[key].brand_domain, | ||
221 | + shopType: hotList[key].type | ||
222 | + }), | ||
212 | img: helpers.image(hotList[key].brand_ico, 186, 115), | 223 | img: helpers.image(hotList[key].brand_ico, 186, 115), |
213 | }); | 224 | }); |
214 | resu.recommandBrandWall.push(obj); | 225 | resu.recommandBrandWall.push(obj); |
@@ -201,7 +201,7 @@ const packageData = (id, isApp, isWeixin, channel, isShare) => { | @@ -201,7 +201,7 @@ const packageData = (id, isApp, isWeixin, channel, isShare) => { | ||
201 | 201 | ||
202 | return Promise.all(promises).then(datas => { | 202 | return Promise.all(promises).then(datas => { |
203 | 203 | ||
204 | - let getArticleContent = {}; | 204 | + let getArticleContent = []; |
205 | 205 | ||
206 | if (datas) { | 206 | if (datas) { |
207 | if (datas[1]) { | 207 | if (datas[1]) { |
@@ -10,10 +10,12 @@ const passport = require('passport'); | @@ -10,10 +10,12 @@ const passport = require('passport'); | ||
10 | 10 | ||
11 | // const md5 = require('yoho-md5'); | 11 | // const md5 = require('yoho-md5'); |
12 | const uuid = require('uuid'); | 12 | const uuid = require('uuid'); |
13 | +const co = Promise.coroutine; | ||
13 | const cookie = global.yoho.cookie; | 14 | const cookie = global.yoho.cookie; |
14 | const helpers = global.yoho.helpers; | 15 | const helpers = global.yoho.helpers; |
15 | const log = global.yoho.logger; | 16 | const log = global.yoho.logger; |
16 | const config = global.yoho.config; | 17 | const config = global.yoho.config; |
18 | +const cache = global.yoho.cache; | ||
17 | const utils = require(global.utils); | 19 | const utils = require(global.utils); |
18 | const RegService = require('../models/reg-service'); | 20 | const RegService = require('../models/reg-service'); |
19 | const AuthHelper = require('../models/auth-helper'); | 21 | const AuthHelper = require('../models/auth-helper'); |
@@ -122,21 +124,10 @@ const local = { | @@ -122,21 +124,10 @@ const local = { | ||
122 | req.session.captchaValidCount = 5; | 124 | req.session.captchaValidCount = 5; |
123 | } | 125 | } |
124 | 126 | ||
125 | - // 先清除cookie | ||
126 | - // res.clearCookie('LE' + md5('_LOGIN_EXPIRE'), { | ||
127 | - // domain: 'yohobuy.com' | ||
128 | - // }); | ||
129 | - | ||
130 | - // 设置登录有效时间30分钟, 防机器刷,cache不稳定,改为cookie | ||
131 | - // res.cookie('LE' + md5('_LOGIN_EXPIRE'), (new Date()).getTime() / 1000 + 1800); | ||
132 | - | ||
133 | - // 170406 账户密码方式登录可以选择是否开启验证码,默认开关是关闭状态,此时开启验证码,开关开启,无需验证 | ||
134 | - let captchaShow = _.get(req.app.locals.wap, 'close.loginValidation', false); | ||
135 | - | ||
136 | res.render('login', { | 127 | res.render('login', { |
137 | width750: true, | 128 | width750: true, |
138 | loginIndex: true, // 模板中使用JS的标识 | 129 | loginIndex: true, // 模板中使用JS的标识 |
139 | - captchaShow: !captchaShow, // 170306 因为暴力破解密码问题,要求每次都展示验证码 | 130 | + captchaShow: req.yoho.captchaShow, |
140 | backUrl: 'javascript:history.go(-1)', // eslint-disable-line | 131 | backUrl: 'javascript:history.go(-1)', // eslint-disable-line |
141 | showHeaderImg: true, // 控制显示头部图片 | 132 | showHeaderImg: true, // 控制显示头部图片 |
142 | isPassportPage: true, // 模板中模块标识 | 133 | isPassportPage: true, // 模板中模块标识 |
@@ -166,22 +157,11 @@ const local = { | @@ -166,22 +157,11 @@ const local = { | ||
166 | req.session.captchaValidCount = 5; | 157 | req.session.captchaValidCount = 5; |
167 | } | 158 | } |
168 | 159 | ||
169 | - // 先清除cookie | ||
170 | - // res.clearCookie('LE' + md5('_LOGIN_EXPIRE'), { | ||
171 | - // domain: 'yohobuy.com' | ||
172 | - // }); | ||
173 | - | ||
174 | - // 设置登录有效时间30分钟, 防机器刷,cache不稳定,改为cookie | ||
175 | - // res.cookie('LE' + md5('_LOGIN_EXPIRE'), (new Date()).getTime() / 1000 + 1800); | ||
176 | - | ||
177 | - // 170406 账户密码方式登录可以选择是否开启验证码,默认开关是关闭状态,此时开启验证码,开关开启,无需验证 | ||
178 | - let captchaShow = _.get(req.app.locals.wap, 'close.loginValidation', false); | ||
179 | - | ||
180 | res.render('international', { | 160 | res.render('international', { |
181 | width750: true, | 161 | width750: true, |
182 | backUrl: 'javascript:history.go(-1)', // eslint-disable-line | 162 | backUrl: 'javascript:history.go(-1)', // eslint-disable-line |
183 | loginInternational: true, // 模板中使用JS的标识 | 163 | loginInternational: true, // 模板中使用JS的标识 |
184 | - captchaShow: !captchaShow, // 170306 因为暴力破解密码问题,要求每次都展示验证码 | 164 | + captchaShow: req.yoho.captchaShow, |
185 | isPassportPage: true, // 模板中模块标识 | 165 | isPassportPage: true, // 模板中模块标识 |
186 | headerText: '登录', | 166 | headerText: '登录', |
187 | areaCode: '+86', // 默认区号 | 167 | areaCode: '+86', // 默认区号 |
@@ -211,6 +191,8 @@ const local = { | @@ -211,6 +191,8 @@ const local = { | ||
211 | captchaShow: true | 191 | captchaShow: true |
212 | }; | 192 | }; |
213 | 193 | ||
194 | + cache.set(`loginErrorIp:${req.yoho.clientIp}`, true, 3600).catch(log.error); | ||
195 | + | ||
214 | res.json(obj); | 196 | res.json(obj); |
215 | } else { | 197 | } else { |
216 | let refer = req.cookies.refer; | 198 | let refer = req.cookies.refer; |
@@ -406,6 +388,36 @@ exports.user = function(req, res, next) { | @@ -406,6 +388,36 @@ exports.user = function(req, res, next) { | ||
406 | res.jsonp(result); | 388 | res.jsonp(result); |
407 | }; | 389 | }; |
408 | 390 | ||
391 | +/** | ||
392 | + * 中间件 | ||
393 | + * 根据用户登录是否成功决定是否展示验证码 | ||
394 | + */ | ||
395 | +exports.loginShowCaptchaByIp = function(req, res, next) { | ||
396 | + // 总开关状态 | ||
397 | + req.yoho.captchaShow = !_.get(req.app.locals.wap, 'close.loginValidation', false); | ||
398 | + | ||
399 | + // 开关打开,不走任何验证逻辑 | ||
400 | + if (!req.yoho.captchaShow) { | ||
401 | + return next(); | ||
402 | + } else { | ||
403 | + req.yoho.captchaShow = false; | ||
404 | + } | ||
405 | + | ||
406 | + co(function*() { | ||
407 | + let hasErrorLog = yield cache.get(`loginErrorIp:${req.yoho.clientIp}`); | ||
408 | + | ||
409 | + log.info(`Pagerender clientip ${req.yoho.clientIp} status is ` + hasErrorLog); | ||
410 | + | ||
411 | + if (hasErrorLog) { | ||
412 | + req.yoho.captchaShow = true; | ||
413 | + } | ||
414 | + next(); | ||
415 | + })().catch(function(e) { | ||
416 | + req.yoho.captchaShow = true; | ||
417 | + next(); | ||
418 | + }); | ||
419 | +}; | ||
420 | + | ||
409 | exports.common = common; | 421 | exports.common = common; |
410 | exports.local = local; | 422 | exports.local = local; |
411 | exports.wechat = wechat; | 423 | exports.wechat = wechat; |
@@ -7,6 +7,9 @@ | @@ -7,6 +7,9 @@ | ||
7 | 'use strict'; | 7 | 'use strict'; |
8 | const _ = require('lodash'); | 8 | const _ = require('lodash'); |
9 | const config = global.yoho.config; | 9 | const config = global.yoho.config; |
10 | +const co = Promise.coroutine; | ||
11 | +const cache = global.yoho.cache; | ||
12 | +const log = global.yoho.logger; | ||
10 | const geetest = require('./geetest'); | 13 | const geetest = require('./geetest'); |
11 | const captcha = require('./captcha'); | 14 | const captcha = require('./captcha'); |
12 | 15 | ||
@@ -20,20 +23,44 @@ const check = (req, res, next) => { | @@ -20,20 +23,44 @@ const check = (req, res, next) => { | ||
20 | return next(); | 23 | return next(); |
21 | } | 24 | } |
22 | 25 | ||
23 | - // 170406 采用账号密码方式登录验证码可以配置关闭,默认开关是关闭状态,这时需要验证,开关开启,无需验证 | ||
24 | - if (_.get(req.app.locals.wap, 'close.loginValidation', false) && req.path === '/passport/login/auth') { | ||
25 | - return next(); | ||
26 | - } | 26 | + // 默认取配置总开关来决定是否展示验证码 |
27 | + req.yoho.captchaShow = !_.get(req.app.locals.wap, 'close.loginValidation', false); | ||
27 | 28 | ||
28 | - // 使用极验证 | ||
29 | - let useGeetest = !_.get(req.app.locals.wap, 'geetest.validation', false); | 29 | + co(function* () { |
30 | + // 如果是账号密码登录,那么需要检查是否登录失败过,登录失败过展示验证码 | ||
31 | + if (req.path === '/passport/login/auth') { | ||
32 | + let hasErrorLog = yield cache.get(`loginErrorIp:${req.yoho.clientIp}`); | ||
30 | 33 | ||
31 | - // 某次请求极验证调用注册失败,强制使用自有图形验证码 | ||
32 | - if (req.session.useYohoCaptcha) { | ||
33 | - useGeetest = false; | ||
34 | - } | 34 | + log.info(`Check clientip ${req.yoho.clientIp} status is ` + hasErrorLog); |
35 | + | ||
36 | + if (hasErrorLog) { | ||
37 | + req.yoho.captchaShow = true; | ||
38 | + } else { | ||
39 | + req.yoho.captchaShow = false; | ||
40 | + } | ||
41 | + } | ||
42 | + | ||
43 | + return req.yoho.captchaShow; | ||
44 | + })().catch(function() { | ||
45 | + // memcache 不可用,展示验证码 | ||
46 | + req.yoho.captchaShow = true; | ||
47 | + return req.yoho.captchaShow; | ||
48 | + }).then(function() { | ||
49 | + // 不是账号密码登录,直接根据配置总开关决定是否需要展示验证码 | ||
50 | + if (!req.yoho.captchaShow) { | ||
51 | + return next(); | ||
52 | + } | ||
53 | + | ||
54 | + // 使用极验证 | ||
55 | + let useGeetest = !_.get(req.app.locals.wap, 'geetest.validation', false); | ||
56 | + | ||
57 | + // 某次请求极验证调用注册失败,强制使用自有图形验证码 | ||
58 | + if (req.session.useYohoCaptcha) { | ||
59 | + useGeetest = false; | ||
60 | + } | ||
35 | 61 | ||
36 | - return (useGeetest ? geetest : captcha).validate(req, res, next); | 62 | + return (useGeetest ? geetest : captcha).validate(req, res, next); |
63 | + }); | ||
37 | }; | 64 | }; |
38 | 65 | ||
39 | /** | 66 | /** |
@@ -39,10 +39,21 @@ router.get('/emailback.html', back.indexEmailPage); | @@ -39,10 +39,21 @@ router.get('/emailback.html', back.indexEmailPage); | ||
39 | router.get('/passport/signout/index', login.common.clearCookie, login.local.logout); | 39 | router.get('/passport/signout/index', login.common.clearCookie, login.local.logout); |
40 | 40 | ||
41 | // 登录页面 | 41 | // 登录页面 |
42 | -router.get('/passport/login', validateCode.load, | ||
43 | - login.common.beforeLogin, login.common.clearCookie, login.local.loginPage); | ||
44 | -router.get('/passport/international', validateCode.load, | ||
45 | -login.common.beforeLogin, login.common.clearCookie, login.local.international); | 42 | +router.get('/passport/login', |
43 | + validateCode.load, | ||
44 | + login.common.beforeLogin, | ||
45 | + login.common.clearCookie, | ||
46 | + login.loginShowCaptchaByIp, | ||
47 | + login.local.loginPage | ||
48 | +); | ||
49 | + | ||
50 | +router.get('/passport/international', | ||
51 | + validateCode.load, | ||
52 | + login.common.beforeLogin, | ||
53 | + login.common.clearCookie, | ||
54 | + login.loginShowCaptchaByIp, | ||
55 | + login.local.international | ||
56 | +); | ||
46 | 57 | ||
47 | // 本地登录 | 58 | // 本地登录 |
48 | router.post('/passport/login/auth', validateCode.check, login.local.login); | 59 | router.post('/passport/login/auth', validateCode.check, login.local.login); |
@@ -44,6 +44,7 @@ const shop = { | @@ -44,6 +44,7 @@ const shop = { | ||
44 | let title = ''; | 44 | let title = ''; |
45 | let uid = req.user.uid || 0; | 45 | let uid = req.user.uid || 0; |
46 | let shopEnter; | 46 | let shopEnter; |
47 | + let shopType = req.query.shopType; | ||
47 | 48 | ||
48 | if (req.query.shop_id) { | 49 | if (req.query.shop_id) { |
49 | return shop.shop(req, res, next); | 50 | return shop.shop(req, res, next); |
@@ -82,13 +83,13 @@ const shop = { | @@ -82,13 +83,13 @@ const shop = { | ||
82 | searchParam.uid = uid; | 83 | searchParam.uid = uid; |
83 | } | 84 | } |
84 | 85 | ||
85 | - if (req.query.from !== 'search' && brandLogo.type === '2' && brandLogo.shopId) { | 86 | + if (req.query.from !== 'search' && brandLogo.type === '2' && brandLogo.shopId && shopType !== '1') { |
86 | req.query.shop_id = brandLogo.shopId; | 87 | req.query.shop_id = brandLogo.shopId; |
87 | shop.shop(req, res, next); | 88 | shop.shop(req, res, next); |
88 | return false; | 89 | return false; |
89 | - } else if (req.query.from === 'search') { | 90 | + } else if (req.query.from === 'search' || shopType === '1') { |
90 | return Promise.all([ | 91 | return Promise.all([ |
91 | - listModel.getBrandShops(brandId, req), | 92 | + listModel.getBrandShops(brandLogo.brandDomain, req), |
92 | searchModel.getSearchData(searchParam) | 93 | searchModel.getSearchData(searchParam) |
93 | ]).then(shopResult => { | 94 | ]).then(shopResult => { |
94 | let brandShop = shopResult[0]; | 95 | let brandShop = shopResult[0]; |
@@ -114,14 +115,16 @@ const shop = { | @@ -114,14 +115,16 @@ const shop = { | ||
114 | } | 115 | } |
115 | 116 | ||
116 | if (brandShop.length > 0 || brandLogo && shopEnter) { | 117 | if (brandShop.length > 0 || brandLogo && shopEnter) { |
118 | + | ||
117 | params = _.assign({ | 119 | params = _.assign({ |
118 | brandWay: _.isEmpty(brandShop) ? brandLogo : brandShop, | 120 | brandWay: _.isEmpty(brandShop) ? brandLogo : brandShop, |
119 | search: { | 121 | search: { |
120 | - default: req.query.query, | 122 | + default: req.query.query || req.query.domain, |
121 | url: helpers.urlFormat('', null, 'search') | 123 | url: helpers.urlFormat('', null, 'search') |
122 | } | 124 | } |
123 | }, params); | 125 | }, params); |
124 | } | 126 | } |
127 | + | ||
125 | return true; | 128 | return true; |
126 | }); | 129 | }); |
127 | } else { | 130 | } else { |
@@ -218,6 +221,12 @@ const shop = { | @@ -218,6 +221,12 @@ const shop = { | ||
218 | searchParam.uid = uid; | 221 | searchParam.uid = uid; |
219 | } | 222 | } |
220 | 223 | ||
224 | + /* 红人店铺直接跳转 */ | ||
225 | + if (shopInfoResult.is_red_shop) { | ||
226 | + shop.redShop(req, res, next); | ||
227 | + return false; | ||
228 | + } | ||
229 | + | ||
221 | /* 基础店铺返回程序内的跳转信号,跳转到基础店铺 */ | 230 | /* 基础店铺返回程序内的跳转信号,跳转到基础店铺 */ |
222 | if (shopInfoResult && shopInfoResult.shop_template_type) { | 231 | if (shopInfoResult && shopInfoResult.shop_template_type) { |
223 | 232 |
@@ -891,7 +891,7 @@ const getLimitProductData = (uid, limitProductCode) => { | @@ -891,7 +891,7 @@ const getLimitProductData = (uid, limitProductCode) => { | ||
891 | 891 | ||
892 | if (obj.attaches.length > 1) { | 892 | if (obj.attaches.length > 1) { |
893 | obj.attaches.sort((v1, v2) => { | 893 | obj.attaches.sort((v1, v2) => { |
894 | - return v1.orderBy - v2.orderBy; | 894 | + return v2.orderBy - v1.orderBy; |
895 | }); | 895 | }); |
896 | } | 896 | } |
897 | 897 |
@@ -29,17 +29,29 @@ const _processBrandShops = (list) => { | @@ -29,17 +29,29 @@ const _processBrandShops = (list) => { | ||
29 | let formatDat = []; | 29 | let formatDat = []; |
30 | 30 | ||
31 | _.forEach(list, item => { | 31 | _.forEach(list, item => { |
32 | - if (item.shop_id) { | 32 | + if (item.shop_type === 'yoho_shop') { |
33 | formatDat.push({ | 33 | formatDat.push({ |
34 | url: helpers.urlFormat('/product/index/brand/', { | 34 | url: helpers.urlFormat('/product/index/brand/', { |
35 | shop_id: item.shop_id | 35 | shop_id: item.shop_id |
36 | }), | 36 | }), |
37 | + thumb: helpers.image(item.shop_logo, 75, 40), | ||
38 | + name: item.shop_name | ||
39 | + }); | ||
40 | + } else if (item.shop_type === 'tbl_brand') { | ||
41 | + formatDat.push({ | ||
42 | + url: helpers.urlFormat('/product/global/list/', { | ||
43 | + brand: item.global_brand_id | ||
44 | + }), | ||
37 | thumb: helpers.image(item.brand_ico, 75, 40), | 45 | thumb: helpers.image(item.brand_ico, 75, 40), |
38 | name: item.brand_name | 46 | name: item.brand_name |
39 | }); | 47 | }); |
40 | } | 48 | } |
41 | }); | 49 | }); |
42 | 50 | ||
51 | + if (formatDat.length > 2) { | ||
52 | + formatDat.moreShop = true; | ||
53 | + } | ||
54 | + | ||
43 | return formatDat; | 55 | return formatDat; |
44 | }; | 56 | }; |
45 | 57 | ||
@@ -749,7 +761,8 @@ const getBrandLogoByDomain = (domain) => { | @@ -749,7 +761,8 @@ const getBrandLogoByDomain = (domain) => { | ||
749 | thumb: helpers.image(formatData.brand_ico, 75, 40), | 761 | thumb: helpers.image(formatData.brand_ico, 75, 40), |
750 | name: formatData.brand_name, | 762 | name: formatData.brand_name, |
751 | shopId: formatData.shop_id ? formatData.shop_id : 0, // 店铺id | 763 | shopId: formatData.shop_id ? formatData.shop_id : 0, // 店铺id |
752 | - type: formatData.type ? formatData.type : 0 | 764 | + type: formatData.type ? formatData.type : 0, |
765 | + brandDomain: formatData.brand_domain | ||
753 | }; | 766 | }; |
754 | } else { | 767 | } else { |
755 | return false; | 768 | return false; |
@@ -763,18 +776,18 @@ const getBrandLogoByDomain = (domain) => { | @@ -763,18 +776,18 @@ const getBrandLogoByDomain = (domain) => { | ||
763 | * @param req | 776 | * @param req |
764 | * @return array | 777 | * @return array |
765 | */ | 778 | */ |
766 | -const getBrandShops = (brandId, req) => { | 779 | +const getBrandShops = (domain, req) => { |
767 | return api.get('', { | 780 | return api.get('', { |
768 | - method: 'app.shop.queryShopsByBrandId', | ||
769 | - brand_id: brandId | 781 | + method: 'app.search.li', |
782 | + query: domain | ||
770 | }, { | 783 | }, { |
771 | code: 200, | 784 | code: 200, |
772 | cache: true | 785 | cache: true |
773 | }).then(result => { | 786 | }).then(result => { |
774 | - if (_.isArray(result.data)) { | 787 | + if (result.data.shopList && _.isArray(result.data.shopList)) { |
775 | let seoResult = _getBrandShopSeo(req.channel, result.data[0], req.query); | 788 | let seoResult = _getBrandShopSeo(req.channel, result.data[0], req.query); |
776 | 789 | ||
777 | - return Object.assign(_processBrandShops(result.data), {seoResult: seoResult}); | 790 | + return Object.assign(_processBrandShops(result.data.shopList), {seoResult: seoResult}); |
778 | } else { | 791 | } else { |
779 | return []; | 792 | return []; |
780 | } | 793 | } |
@@ -123,6 +123,8 @@ const selectHotrank = (yhChannel, gender, sort, tabId, limit, page, notab) => { | @@ -123,6 +123,8 @@ const selectHotrank = (yhChannel, gender, sort, tabId, limit, page, notab) => { | ||
123 | } | 123 | } |
124 | 124 | ||
125 | return formData; | 125 | return formData; |
126 | + } else { | ||
127 | + return {}; | ||
126 | } | 128 | } |
127 | 129 | ||
128 | }); | 130 | }); |
@@ -12,18 +12,28 @@ | @@ -12,18 +12,28 @@ | ||
12 | </div> | 12 | </div> |
13 | <ul class="search-associate"></ul> | 13 | <ul class="search-associate"></ul> |
14 | {{/ search}} | 14 | {{/ search}} |
15 | - {{# brandWay}} | ||
16 | - <div class="brand-way" data-shopid="{{shopId}}" data-brandid="{{brandId}}"> | ||
17 | - <a href={{url}}> | ||
18 | - <img class="brand-thumb" src={{image2 thumb q=60}}> | ||
19 | - <span class="brand-name">{{name}}</span> | ||
20 | - <span class="entry"> | ||
21 | - 进入店铺 | ||
22 | - <i class="iconfont"></i> | ||
23 | - </span> | ||
24 | - </a> | 15 | + {{#if brandWay}} |
16 | + <div class="brand-way" data-shopid="{{brandWay/shopId}}" data-brandid="{{brandWay/brandId}}"> | ||
17 | + <div class="brand-enter"> | ||
18 | + {{# brandWay}} | ||
19 | + <a href={{url}}> | ||
20 | + <img class="brand-thumb" src={{image2 thumb q=60}}> | ||
21 | + <span class="brand-name">{{name}}</span> | ||
22 | + <span class="entry"> | ||
23 | + 进入店铺 | ||
24 | + <i class="iconfont"></i> | ||
25 | + </span> | ||
26 | + </a> | ||
27 | + {{/ brandWay}} | ||
28 | + </div> | ||
29 | + | ||
30 | + {{#if brandWay.moreShop}} | ||
31 | + <div class="more-shop down"> | ||
32 | + <span class="iconfont"></span> | ||
33 | + </div> | ||
34 | + {{/if}} | ||
25 | </div> | 35 | </div> |
26 | - {{/ brandWay}} | 36 | + {{/if}} |
27 | <!-- 品牌页面 --> | 37 | <!-- 品牌页面 --> |
28 | {{# brandHome}} | 38 | {{# brandHome}} |
29 | <div id="brand-header" class="brand-header" data-id={{id}}> | 39 | <div id="brand-header" class="brand-header" data-id={{id}}> |
@@ -24,6 +24,11 @@ | @@ -24,6 +24,11 @@ | ||
24 | {{# is_presell}} | 24 | {{# is_presell}} |
25 | <p class="good-tag is-presell">预售</p> | 25 | <p class="good-tag is-presell">预售</p> |
26 | {{/ is_presell}} | 26 | {{/ is_presell}} |
27 | + {{# is_global}} | ||
28 | + <p class="good-tag is-global"> | ||
29 | + <span>{{../tbl_country_name}}</span> | ||
30 | + </p> | ||
31 | + {{/ is_global}} | ||
27 | {{/ tags}} | 32 | {{/ tags}} |
28 | </div> | 33 | </div> |
29 | <div class="good-detail-img"> | 34 | <div class="good-detail-img"> |
@@ -37,7 +42,7 @@ | @@ -37,7 +42,7 @@ | ||
37 | {{# is_soon_sold_out}} | 42 | {{# is_soon_sold_out}} |
38 | <p class="few-tag">即将售罄</p> | 43 | <p class="few-tag">即将售罄</p> |
39 | {{/ is_soon_sold_out}} | 44 | {{/ is_soon_sold_out}} |
40 | - | 45 | + |
41 | {{# is_solded}} | 46 | {{# is_solded}} |
42 | <p class="out-tag">已售罄</p> | 47 | <p class="out-tag">已售罄</p> |
43 | {{/ is_solded}} | 48 | {{/ is_solded}} |
@@ -50,7 +50,7 @@ | @@ -50,7 +50,7 @@ | ||
50 | "xml2js": "^0.4.17", | 50 | "xml2js": "^0.4.17", |
51 | "yoho-express-session": "^2.0.0", | 51 | "yoho-express-session": "^2.0.0", |
52 | "yoho-md5": "^2.0.0", | 52 | "yoho-md5": "^2.0.0", |
53 | - "yoho-node-lib": "=0.2.16", | 53 | + "yoho-node-lib": "=0.2.17", |
54 | "yoho-zookeeper": "^1.0.8" | 54 | "yoho-zookeeper": "^1.0.8" |
55 | }, | 55 | }, |
56 | "devDependencies": { | 56 | "devDependencies": { |
public/img/product/airplane.png
0 → 100644
1.29 KB
@@ -425,23 +425,15 @@ $reaMask.find('.box-cmp').on('touchend', function() { | @@ -425,23 +425,15 @@ $reaMask.find('.box-cmp').on('touchend', function() { | ||
425 | return; | 425 | return; |
426 | } | 426 | } |
427 | 427 | ||
428 | - if (res.code === 200) { | ||
429 | - dialog.showDialog({ | ||
430 | - dialogText: '您的取消订单申请已提交,请耐心等待', | ||
431 | - hasFooter: { | ||
432 | - leftBtnText: '返回', | ||
433 | - rightBtnText: '确定' | ||
434 | - } | ||
435 | - }, function() { | ||
436 | - window.location.href = '/home/orders'; | ||
437 | - }); | ||
438 | - | ||
439 | - return false; | ||
440 | - } | ||
441 | - | ||
442 | if (res.message) { | 428 | if (res.message) { |
443 | tip.show(res.message); | 429 | tip.show(res.message); |
444 | } | 430 | } |
431 | + | ||
432 | + if (res.code === 200) { | ||
433 | + setTimeout(function() { | ||
434 | + window.location.href = '/home/orders'; | ||
435 | + }, 500); | ||
436 | + } | ||
445 | }).fail(function() { | 437 | }).fail(function() { |
446 | tip.show('网络错误'); | 438 | tip.show('网络错误'); |
447 | }); | 439 | }); |
@@ -259,22 +259,15 @@ $reaMask.find('.box-cmp').on('touchend', function() { | @@ -259,22 +259,15 @@ $reaMask.find('.box-cmp').on('touchend', function() { | ||
259 | return; | 259 | return; |
260 | } | 260 | } |
261 | 261 | ||
262 | - if (res.code === 200) { | ||
263 | - dialog.showDialog({ | ||
264 | - dialogText: '您的取消订单申请已提交,请耐心等待', | ||
265 | - hasFooter: { | ||
266 | - leftBtnText: '返回', | ||
267 | - rightBtnText: '确定' | ||
268 | - } | ||
269 | - }, function() { | ||
270 | - window.location.href = '/home/orders'; | ||
271 | - }); | ||
272 | - | ||
273 | - return false; | ||
274 | - } | ||
275 | if (res.message) { | 262 | if (res.message) { |
276 | tip.show(res.message); | 263 | tip.show(res.message); |
277 | } | 264 | } |
265 | + | ||
266 | + if (res.code === 200) { | ||
267 | + setTimeout(function() { | ||
268 | + window.location.href = '/home/orders'; | ||
269 | + }, 500); | ||
270 | + } | ||
278 | }).fail(function() { | 271 | }).fail(function() { |
279 | tip.show('网络错误'); | 272 | tip.show('网络错误'); |
280 | }); | 273 | }); |
@@ -14,7 +14,6 @@ let $account = $('#account'), | @@ -14,7 +14,6 @@ let $account = $('#account'), | ||
14 | $ways = $('#retrive-pwd-ways'), | 14 | $ways = $('#retrive-pwd-ways'), |
15 | 15 | ||
16 | $captcha = $('#js-img-check'), | 16 | $captcha = $('#js-img-check'), |
17 | - useVerify = $captcha.data('userverify'), // 170406 是否使用验证 | ||
18 | 17 | ||
19 | accPass = false, | 18 | accPass = false, |
20 | pwdPass = false; | 19 | pwdPass = false; |
@@ -26,16 +25,14 @@ let trim = $.trim; | @@ -26,16 +25,14 @@ let trim = $.trim; | ||
26 | let showErrTip = tip.show; | 25 | let showErrTip = tip.show; |
27 | 26 | ||
28 | 27 | ||
29 | -let validate = {}; | ||
30 | - | ||
31 | -if (useVerify) { | ||
32 | - validate = new Validate($captcha, { | ||
33 | - useREM: { | ||
34 | - rootFontSize: 40, | ||
35 | - picWidth: 150 | ||
36 | - } | ||
37 | - }); | 28 | +let validate = new Validate($captcha, { |
29 | + useREM: { | ||
30 | + rootFontSize: 40, | ||
31 | + picWidth: 150 | ||
32 | + } | ||
33 | +}); | ||
38 | 34 | ||
35 | +if ($captcha.data('userverify')) { | ||
39 | validate.init(); | 36 | validate.init(); |
40 | } | 37 | } |
41 | 38 | ||
@@ -100,8 +97,13 @@ function loginAuth(params, acc) { | @@ -100,8 +97,13 @@ function loginAuth(params, acc) { | ||
100 | location.href = res.href; | 97 | location.href = res.href; |
101 | $loginBtn.text('登录成功'); | 98 | $loginBtn.text('登录成功'); |
102 | } else { | 99 | } else { |
103 | - if (useVerify && data.captchaShow) { | ||
104 | - ((data.changeCaptcha && validate.type !== 2) && validate.refresh()); | 100 | + $captcha.data('userverify', data.captchaShow); |
101 | + if (data.captchaShow) { | ||
102 | + if (validate.atWorking) { | ||
103 | + ((data.changeCaptcha && validate.type !== 2) && validate.refresh()); | ||
104 | + } else { | ||
105 | + validate.init(); | ||
106 | + } | ||
105 | } | 107 | } |
106 | 108 | ||
107 | showErrTip(data.message); | 109 | showErrTip(data.message); |
@@ -161,7 +163,7 @@ $loginBtn.on('touchstart', function() { | @@ -161,7 +163,7 @@ $loginBtn.on('touchstart', function() { | ||
161 | password: pwd | 163 | password: pwd |
162 | }; | 164 | }; |
163 | 165 | ||
164 | - if (useVerify) { | 166 | + if ($captcha.data('userverify')) { |
165 | validate.getResults().then((result) => { | 167 | validate.getResults().then((result) => { |
166 | $loginBtn.text('正在登录...').addClass('disable'); | 168 | $loginBtn.text('正在登录...').addClass('disable'); |
167 | 169 |
@@ -200,7 +200,7 @@ function getQueryString(name) { | @@ -200,7 +200,7 @@ function getQueryString(name) { | ||
200 | let r = window.location.search.substr(1).match(reg); | 200 | let r = window.location.search.substr(1).match(reg); |
201 | 201 | ||
202 | if (r !== null) { | 202 | if (r !== null) { |
203 | - return window.unescape(r[2]); | 203 | + return decodeURIComponent(r[2]); |
204 | } | 204 | } |
205 | return null; | 205 | return null; |
206 | } | 206 | } |
@@ -577,7 +577,6 @@ if ($brandHeader.data('isbaseshop') === true) { | @@ -577,7 +577,6 @@ if ($brandHeader.data('isbaseshop') === true) { | ||
577 | Object.assign(defaultOpt, {shop_id: $brandHeader.data('id')}); | 577 | Object.assign(defaultOpt, {shop_id: $brandHeader.data('id')}); |
578 | } | 578 | } |
579 | 579 | ||
580 | - | ||
581 | $.ajax({ | 580 | $.ajax({ |
582 | type: 'GET', | 581 | type: 'GET', |
583 | url: location.protocol + '//m.yohobuy.com/product/search/filter', | 582 | url: location.protocol + '//m.yohobuy.com/product/search/filter', |
@@ -848,4 +847,14 @@ $('.brand-way a').on('click', function() { | @@ -848,4 +847,14 @@ $('.brand-way a').on('click', function() { | ||
848 | } | 847 | } |
849 | }); | 848 | }); |
850 | 849 | ||
850 | +$('.more-shop').on('click', function() { | ||
851 | + if ($(this).hasClass('down')) { | ||
852 | + $('.brand-enter').css('max-height', '100%'); | ||
853 | + $('.more-shop').removeClass('down').find('span').html(''); | ||
854 | + } else { | ||
855 | + $('.brand-enter').removeAttr('style'); | ||
856 | + $('.more-shop').addClass('down').find('span').html(''); | ||
857 | + } | ||
858 | +}); | ||
859 | + | ||
851 | require('channel/maybe-like')({recpose: 100101, isExecute: true}); | 860 | require('channel/maybe-like')({recpose: 100101, isExecute: true}); |
@@ -69,6 +69,21 @@ | @@ -69,6 +69,21 @@ | ||
69 | background-color: #000; | 69 | background-color: #000; |
70 | color: #fff; | 70 | color: #fff; |
71 | } | 71 | } |
72 | + | ||
73 | + .is-global { | ||
74 | + padding: 3px 10px 0 8px; | ||
75 | + color: #fff; | ||
76 | + background-color: #462e3e; | ||
77 | + line-height: 26px; | ||
78 | + | ||
79 | + span { | ||
80 | + display: inline-block; | ||
81 | + background-image: resolve("product/airplane.png"); | ||
82 | + background-repeat: no-repeat; | ||
83 | + padding-left: 32px; | ||
84 | + background-size: auto 95%; | ||
85 | + } | ||
86 | + } | ||
72 | } | 87 | } |
73 | } | 88 | } |
74 | 89 |
@@ -65,12 +65,16 @@ | @@ -65,12 +65,16 @@ | ||
65 | padding-bottom: 20px; | 65 | padding-bottom: 20px; |
66 | background: #f4f4f4; | 66 | background: #f4f4f4; |
67 | 67 | ||
68 | - > a { | 68 | + .brand-enter { |
69 | + max-height: 160px; | ||
70 | + overflow: hidden; | ||
71 | + } | ||
72 | + | ||
73 | + a { | ||
69 | display: block; | 74 | display: block; |
70 | height: 80px; | 75 | height: 80px; |
71 | line-height: 80px; | 76 | line-height: 80px; |
72 | padding: 0 20px; | 77 | padding: 0 20px; |
73 | - border-bottom: 1px solid #e6e6e6; | ||
74 | border-top: 1px solid #e6e6e6; | 78 | border-top: 1px solid #e6e6e6; |
75 | font-size: 34px; | 79 | font-size: 34px; |
76 | background: #fff; | 80 | background: #fff; |
@@ -78,6 +82,10 @@ | @@ -78,6 +82,10 @@ | ||
78 | overflow: hidden; | 82 | overflow: hidden; |
79 | } | 83 | } |
80 | 84 | ||
85 | + /* a:last-child { | ||
86 | + border-bottom: 1px solid #e6e6e6; | ||
87 | + } */ | ||
88 | + | ||
81 | span { | 89 | span { |
82 | font-size: 28px; | 90 | font-size: 28px; |
83 | overflow: hidden; | 91 | overflow: hidden; |
@@ -90,21 +98,38 @@ | @@ -90,21 +98,38 @@ | ||
90 | overflow: hidden; | 98 | overflow: hidden; |
91 | text-overflow: ellipsis; | 99 | text-overflow: ellipsis; |
92 | white-space: nowrap; | 100 | white-space: nowrap; |
93 | - position: absolute; | 101 | + display: inline-block; |
102 | + | ||
103 | + /* position: absolute; */ | ||
94 | } | 104 | } |
95 | 105 | ||
96 | .brand-thumb { | 106 | .brand-thumb { |
97 | - display: block; | ||
98 | float: left; | 107 | float: left; |
99 | width: 150px; | 108 | width: 150px; |
100 | height: 80px; | 109 | height: 80px; |
101 | margin: 0; | 110 | margin: 0; |
111 | + display: inline-block; | ||
102 | } | 112 | } |
103 | 113 | ||
104 | .entry { | 114 | .entry { |
105 | color: #999; | 115 | color: #999; |
106 | font-size: 28px; | 116 | font-size: 28px; |
107 | float: right; | 117 | float: right; |
118 | + display: inline-block; | ||
119 | + } | ||
120 | + | ||
121 | + .more-shop { | ||
122 | + width: 100%; | ||
123 | + height: 40px; | ||
124 | + background: #fff; | ||
125 | + color: #999; | ||
126 | + margin-top: 0; | ||
127 | + text-align: center; | ||
128 | + | ||
129 | + span { | ||
130 | + position: relative; | ||
131 | + top: -6px; | ||
132 | + } | ||
108 | } | 133 | } |
109 | } | 134 | } |
110 | 135 |
@@ -103,9 +103,9 @@ exports.processProductList = (list, options) => { | @@ -103,9 +103,9 @@ exports.processProductList = (list, options) => { | ||
103 | } | 103 | } |
104 | 104 | ||
105 | // H5 暂时不支持全球购商品,先过滤掉 2017.04.09 | 105 | // H5 暂时不支持全球购商品,先过滤掉 2017.04.09 |
106 | - if (product.is_global === 'Y') { | ||
107 | - return; | ||
108 | - } | 106 | + // if (product.is_global === 'Y') { |
107 | + // return; | ||
108 | + // } | ||
109 | 109 | ||
110 | // 商品信息有问题,则不显示 | 110 | // 商品信息有问题,则不显示 |
111 | if (!( | 111 | if (!( |
@@ -114,7 +114,6 @@ exports.processProductList = (list, options) => { | @@ -114,7 +114,6 @@ exports.processProductList = (list, options) => { | ||
114 | return; | 114 | return; |
115 | } | 115 | } |
116 | 116 | ||
117 | - | ||
118 | if (product.recommend_type) { | 117 | if (product.recommend_type) { |
119 | // recommend_type 对应 附加属性 | 118 | // recommend_type 对应 附加属性 |
120 | let flagMap = { | 119 | let flagMap = { |
@@ -170,7 +169,8 @@ exports.processProductList = (list, options) => { | @@ -170,7 +169,8 @@ exports.processProductList = (list, options) => { | ||
170 | product.cn_alphabet = productNameProcess(product.cn_alphabet); | 169 | product.cn_alphabet = productNameProcess(product.cn_alphabet); |
171 | } | 170 | } |
172 | 171 | ||
173 | - product.url = helpers.urlFormat(`/product/${product.product_skn}.html`); // 商品url改版 // eslint-disable-line | 172 | + product.url = product.is_global === 'Y' ? helpers.urlFormat(`/product/global/${product.product_skn}.html`) : |
173 | + helpers.urlFormat(`/product/${product.product_skn}.html`); // 商品url改版 // eslint-disable-line | ||
174 | 174 | ||
175 | // APP访问需要加附加的参数 | 175 | // APP访问需要加附加的参数 |
176 | // 备注:如果以后APP的接口太多,可以把这边参数提取出来,变成一个公共的方法来生成,便于以后管理维护 | 176 | // 备注:如果以后APP的接口太多,可以把这边参数提取出来,变成一个公共的方法来生成,便于以后管理维护 |
@@ -191,6 +191,10 @@ exports.processProductList = (list, options) => { | @@ -191,6 +191,10 @@ exports.processProductList = (list, options) => { | ||
191 | product.is_solded = true; | 191 | product.is_solded = true; |
192 | } | 192 | } |
193 | 193 | ||
194 | + if (product.is_global === 'Y') { | ||
195 | + tags.is_global = true; | ||
196 | + } | ||
197 | + | ||
194 | product.is_soon_sold_out = tags.is_soon_sold_out; | 198 | product.is_soon_sold_out = tags.is_soon_sold_out; |
195 | 199 | ||
196 | } | 200 | } |
@@ -2,10 +2,12 @@ | @@ -2,10 +2,12 @@ | ||
2 | * @Author: Targaryen | 2 | * @Author: Targaryen |
3 | * @Date: 2017-03-23 11:02:31 | 3 | * @Date: 2017-03-23 11:02:31 |
4 | * @Last Modified by: Targaryen | 4 | * @Last Modified by: Targaryen |
5 | - * @Last Modified time: 2017-03-31 16:57:27 | 5 | + * @Last Modified time: 2017-04-12 14:36:15 |
6 | */ | 6 | */ |
7 | /* 红人店铺数据处理 */ | 7 | /* 红人店铺数据处理 */ |
8 | 8 | ||
9 | +'use strict'; | ||
10 | + | ||
9 | const _ = require('lodash'); | 11 | const _ = require('lodash'); |
10 | const helpers = global.yoho.helpers; | 12 | const helpers = global.yoho.helpers; |
11 | 13 |
-
Please register or login to post a comment