Merge branch 'feature/zookeeper' of http://git.yoho.cn/fe/yohobuy-node into feature/zookeeper
Conflicts: app.js package.json
Showing
25 changed files
with
370 additions
and
94 deletions
@@ -13,6 +13,8 @@ const bodyParser = require('body-parser'); | @@ -13,6 +13,8 @@ const bodyParser = require('body-parser'); | ||
13 | const cookieParser = require('cookie-parser'); | 13 | const cookieParser = require('cookie-parser'); |
14 | const favicon = require('serve-favicon'); | 14 | const favicon = require('serve-favicon'); |
15 | const session = require('yoho-express-session'); | 15 | const session = require('yoho-express-session'); |
16 | +const _ = require('lodash'); | ||
17 | +const fp = require('lodash/fp'); | ||
16 | 18 | ||
17 | const memcached = require('connect-memcached'); | 19 | const memcached = require('connect-memcached'); |
18 | const hbs = require('express-handlebars'); | 20 | const hbs = require('express-handlebars'); |
@@ -27,6 +29,11 @@ const MemcachedStore = memcached(session); | @@ -27,6 +29,11 @@ const MemcachedStore = memcached(session); | ||
27 | // 全局注册library | 29 | // 全局注册library |
28 | yohoLib.global(config); | 30 | yohoLib.global(config); |
29 | 31 | ||
32 | +const helpers = global.yoho.helpers; | ||
33 | + | ||
34 | +// NOTE: 这里修改了图片质量的参数 | ||
35 | +helpers.image = _.flow(helpers.image, fp.replace(/\/quality\/\d*$/, '/quality/90')); | ||
36 | + | ||
30 | global.middleware = path.resolve('./doraemon/middleware'); | 37 | global.middleware = path.resolve('./doraemon/middleware'); |
31 | global.utils = path.resolve('./utils'); | 38 | global.utils = path.resolve('./utils'); |
32 | 39 |
@@ -173,7 +173,7 @@ const local = { | @@ -173,7 +173,7 @@ const local = { | ||
173 | return `${config.siteUrl}/home`; | 173 | return `${config.siteUrl}/home`; |
174 | } | 174 | } |
175 | }()); | 175 | }()); |
176 | - console.log(user.uid); | 176 | + |
177 | AuthHelper.syncUserSession(user.uid, req, res).then(() => { | 177 | AuthHelper.syncUserSession(user.uid, req, res).then(() => { |
178 | res.json({ | 178 | res.json({ |
179 | code: 200, | 179 | code: 200, |
@@ -17,10 +17,10 @@ const changeFavoriteBrand = (req, res, next) => { | @@ -17,10 +17,10 @@ const changeFavoriteBrand = (req, res, next) => { | ||
17 | 17 | ||
18 | if (uid && brandId) { | 18 | if (uid && brandId) { |
19 | brandService.changeAsync(uid, brandId).then(result => { | 19 | brandService.changeAsync(uid, brandId).then(result => { |
20 | - res.json(result); | 20 | + return res.json(result); |
21 | }).catch(next); | 21 | }).catch(next); |
22 | } else if (!uid) { | 22 | } else if (!uid) { |
23 | - res.json({ | 23 | + return res.json({ |
24 | code: 403, | 24 | code: 403, |
25 | message: '用户ID不存在', | 25 | message: '用户ID不存在', |
26 | data: { | 26 | data: { |
@@ -28,13 +28,29 @@ const changeFavoriteBrand = (req, res, next) => { | @@ -28,13 +28,29 @@ const changeFavoriteBrand = (req, res, next) => { | ||
28 | } | 28 | } |
29 | }); | 29 | }); |
30 | } else { | 30 | } else { |
31 | - res.json({ | 31 | + return res.json({ |
32 | code: 400, | 32 | code: 400, |
33 | message: '操作失败' | 33 | message: '操作失败' |
34 | }); | 34 | }); |
35 | } | 35 | } |
36 | }; | 36 | }; |
37 | 37 | ||
38 | +const isFavoriteBrand = (req, res, next) => { | ||
39 | + let uid = req.user.uid || ''; | ||
40 | + let brandId = req.query.brandId; | ||
41 | + | ||
42 | + if (uid && brandId) { | ||
43 | + brandService.isFavoriteAsync(uid, brandId).then(result => { | ||
44 | + return res.json(result); | ||
45 | + }).catch(next); | ||
46 | + } else { | ||
47 | + return res.json({ | ||
48 | + code: 400, | ||
49 | + message: '状态失败' | ||
50 | + }); | ||
51 | + } | ||
52 | +}; | ||
53 | + | ||
38 | const collectProduct = (req, res, next) => { | 54 | const collectProduct = (req, res, next) => { |
39 | let uid = req.user.uid || ''; | 55 | let uid = req.user.uid || ''; |
40 | let pid = req.body.productId; | 56 | let pid = req.body.productId; |
@@ -43,8 +59,7 @@ const collectProduct = (req, res, next) => { | @@ -43,8 +59,7 @@ const collectProduct = (req, res, next) => { | ||
43 | if (uid && pid) { | 59 | if (uid && pid) { |
44 | switch (type) { | 60 | switch (type) { |
45 | case 'add': | 61 | case 'add': |
46 | - { | ||
47 | - productService.createAsync(uid, pid) | 62 | + productService.createAsync(uid, pid) |
48 | .then(result => { | 63 | .then(result => { |
49 | if (result.code === 413) { | 64 | if (result.code === 413) { |
50 | result.message = '该商品已经收藏'; | 65 | result.message = '该商品已经收藏'; |
@@ -53,22 +68,17 @@ const collectProduct = (req, res, next) => { | @@ -53,22 +68,17 @@ const collectProduct = (req, res, next) => { | ||
53 | res.json(result); | 68 | res.json(result); |
54 | }) | 69 | }) |
55 | .catch(next); | 70 | .catch(next); |
56 | - break; | ||
57 | - } | 71 | + break; |
58 | case 'cancel': | 72 | case 'cancel': |
59 | - { | ||
60 | - productService.deleteAsync(uid, pid) | 73 | + productService.deleteAsync(uid, pid) |
61 | .then(result => res.json(result)) | 74 | .then(result => res.json(result)) |
62 | .catch(next); | 75 | .catch(next); |
63 | - break; | ||
64 | - } | 76 | + break; |
65 | default: | 77 | default: |
66 | - { | ||
67 | - res.json({ | ||
68 | - code: 400, | ||
69 | - message: '错误类型' | ||
70 | - }); | ||
71 | - } | 78 | + res.json({ |
79 | + code: 400, | ||
80 | + message: '错误类型' | ||
81 | + }); | ||
72 | } | 82 | } |
73 | } else if (!uid) { | 83 | } else if (!uid) { |
74 | res.json({ | 84 | res.json({ |
@@ -114,8 +124,26 @@ const collectShop = (req, res, next) => { | @@ -114,8 +124,26 @@ const collectShop = (req, res, next) => { | ||
114 | } | 124 | } |
115 | }; | 125 | }; |
116 | 126 | ||
127 | +const isFavShop = (req, res, next) => { | ||
128 | + let uid = req.user.uid; | ||
129 | + let shopId = req.body.shopId; | ||
130 | + | ||
131 | + if (!uid || !shopId) { | ||
132 | + return res.json({ | ||
133 | + code: 400, | ||
134 | + message: '未收藏' | ||
135 | + }); | ||
136 | + } | ||
137 | + | ||
138 | + fav.getFavStatus(uid, shopId, 'shop').then(result => { | ||
139 | + return res.json(result); | ||
140 | + }).catch(next); | ||
141 | +}; | ||
142 | + | ||
117 | module.exports = { | 143 | module.exports = { |
118 | changeFavoriteBrand, | 144 | changeFavoriteBrand, |
119 | collectProduct, | 145 | collectProduct, |
120 | - collectShop | 146 | + collectShop, |
147 | + isFavShop, | ||
148 | + isFavoriteBrand | ||
121 | }; | 149 | }; |
@@ -107,3 +107,19 @@ exports.userAcquireStatus = (req, res, next) => { | @@ -107,3 +107,19 @@ exports.userAcquireStatus = (req, res, next) => { | ||
107 | }).catch(next); | 107 | }).catch(next); |
108 | 108 | ||
109 | }; | 109 | }; |
110 | + | ||
111 | + | ||
112 | +/** | ||
113 | + * 学生返币专享页面 | ||
114 | + * @param {[type]} req [description] | ||
115 | + * @param {[type]} res [description] | ||
116 | + * @return {[type]} [description] | ||
117 | + */ | ||
118 | +exports.list = (req, res, next) => { | ||
119 | + let resData = {}; | ||
120 | + | ||
121 | + studentsModel.getStudentsList(req.query, req.yoho.channel).then(result => { | ||
122 | + Object.assign(resData, result); | ||
123 | + res.render('list/index', resData); | ||
124 | + }).catch(next); | ||
125 | +}; |
@@ -56,8 +56,8 @@ const indexAsync = pid => { | @@ -56,8 +56,8 @@ const indexAsync = pid => { | ||
56 | marketPrice: cur.product.productPriceBo.formatMarketPrice, | 56 | marketPrice: cur.product.productPriceBo.formatMarketPrice, |
57 | productName: cur.product.productName, | 57 | productName: cur.product.productName, |
58 | href: helpers.getUrlBySkc( | 58 | href: helpers.getUrlBySkc( |
59 | - _.head(goods.goodsImagesList).productId, | ||
60 | - _.head(goods.goodsImagesList).goodsId, | 59 | + _.get(goods, 'goodsImagesList[0].productId', ''), |
60 | + _.get(goods, 'goodsImagesList[0].goodsId', ''), | ||
61 | cur.product.cnAlphabet | 61 | cur.product.cnAlphabet |
62 | ) | 62 | ) |
63 | }; | 63 | }; |
@@ -67,7 +67,7 @@ const _getProductIntroAsync = (productId, productSkn) => { | @@ -67,7 +67,7 @@ const _getProductIntroAsync = (productId, productSkn) => { | ||
67 | * pid : product id | 67 | * pid : product id |
68 | * bid : brand id | 68 | * bid : brand id |
69 | */ | 69 | */ |
70 | -const _getProductFavoriteDataAsync = (uid, pid, bid) => { | 70 | +const _getProductFavoriteDataAsync = (uid, pid) => { |
71 | return co(function*() { | 71 | return co(function*() { |
72 | let result = { | 72 | let result = { |
73 | product: false, | 73 | product: false, |
@@ -84,23 +84,14 @@ const _getProductFavoriteDataAsync = (uid, pid, bid) => { | @@ -84,23 +84,14 @@ const _getProductFavoriteDataAsync = (uid, pid, bid) => { | ||
84 | requestApi.product = favoriteProductService.isFavoriteAsync(uid, pid); | 84 | requestApi.product = favoriteProductService.isFavoriteAsync(uid, pid); |
85 | } | 85 | } |
86 | 86 | ||
87 | - if (bid) { | ||
88 | - requestApi.brand = favoriteBrandService.isFavoriteAsync(uid, bid); | ||
89 | - } | ||
90 | - | ||
91 | let requestData = yield Promise.props(requestApi); | 87 | let requestData = yield Promise.props(requestApi); |
92 | 88 | ||
93 | let productData = requestData.product; | 89 | let productData = requestData.product; |
94 | - let brandData = requestData.brand; | ||
95 | 90 | ||
96 | if (productData) { | 91 | if (productData) { |
97 | result.product = productData.code === 200 && productData.data ? true : false; | 92 | result.product = productData.code === 200 && productData.data ? true : false; |
98 | } | 93 | } |
99 | 94 | ||
100 | - if (brandData) { | ||
101 | - result.brand = brandData.code && brandData.code === 200 ? true : false; | ||
102 | - } | ||
103 | - | ||
104 | return result; | 95 | return result; |
105 | })(); | 96 | })(); |
106 | }; | 97 | }; |
@@ -1072,11 +1063,9 @@ const _detailDataPkg = (origin, uid, vipLevel, cookies) => { | @@ -1072,11 +1063,9 @@ const _detailDataPkg = (origin, uid, vipLevel, cookies) => { | ||
1072 | 1063 | ||
1073 | result.goCartUrl = helpers.urlFormat('/shopping/cart'); | 1064 | result.goCartUrl = helpers.urlFormat('/shopping/cart'); |
1074 | 1065 | ||
1075 | - let brandId = propOrigin('brand_info.brand_id', 0); | ||
1076 | - | ||
1077 | let requestApi = { | 1066 | let requestApi = { |
1078 | addition: _getProductAdditionInfoAsync(origin), // 预处理所有的数据 | 1067 | addition: _getProductAdditionInfoAsync(origin), // 预处理所有的数据 |
1079 | - fav: _getProductFavoriteDataAsync(uid, result.productId, brandId), // 处理收藏喜欢数据 | 1068 | + fav: _getProductFavoriteDataAsync(uid, result.productId), // 处理收藏喜欢数据 |
1080 | promotion: productAPI.getPromotionAsync(result.skn) // 打折信息 | 1069 | promotion: productAPI.getPromotionAsync(result.skn) // 打折信息 |
1081 | }; | 1070 | }; |
1082 | 1071 |
@@ -9,6 +9,23 @@ | @@ -9,6 +9,23 @@ | ||
9 | const api = global.yoho.API; | 9 | const api = global.yoho.API; |
10 | 10 | ||
11 | /** | 11 | /** |
12 | + * 是否收藏API | ||
13 | + * @function cancelFavAsync | ||
14 | + * @param { number } uid 用户uid | ||
15 | + * @param { number } id 收藏id | ||
16 | + * @param { string } type 类型 product--商品 brand--品牌 shop--店铺 | ||
17 | + * @return { Object } 收藏状态 | ||
18 | + */ | ||
19 | +const isFavAsync = (uid, id, type) => { | ||
20 | + return api.get('', { | ||
21 | + method: 'app.favorite.isFavorite', | ||
22 | + id: id, | ||
23 | + uid: uid, | ||
24 | + type: type | ||
25 | + }); | ||
26 | +}; | ||
27 | + | ||
28 | +/** | ||
12 | * 收藏API | 29 | * 收藏API |
13 | * @function addFavAsync | 30 | * @function addFavAsync |
14 | * @param { number } uid 用户uid | 31 | * @param { number } uid 用户uid |
@@ -43,6 +60,7 @@ const cancelFavAsync = (uid, id, type) => { | @@ -43,6 +60,7 @@ const cancelFavAsync = (uid, id, type) => { | ||
43 | }; | 60 | }; |
44 | 61 | ||
45 | module.exports = { | 62 | module.exports = { |
63 | + isFavAsync, // 是否收藏 | ||
46 | addFavAsync, // 收藏 | 64 | addFavAsync, // 收藏 |
47 | cancelFavAsync // 取消收藏 | 65 | cancelFavAsync // 取消收藏 |
48 | }; | 66 | }; |
@@ -56,7 +56,12 @@ const toggleFavShop = (shopId, uid, isadd) => { | @@ -56,7 +56,12 @@ const toggleFavShop = (shopId, uid, isadd) => { | ||
56 | } | 56 | } |
57 | }; | 57 | }; |
58 | 58 | ||
59 | +const getFavStatus = (uid, id, type) => { | ||
60 | + return favAPI.isFavAsync(uid, id, type); | ||
61 | +}; | ||
62 | + | ||
59 | module.exports = { | 63 | module.exports = { |
64 | + getFavStatus, // 收藏状态 | ||
60 | toggleFavProduct, // 收藏商品 | 65 | toggleFavProduct, // 收藏商品 |
61 | toggleFavBrand, // 收藏品牌 | 66 | toggleFavBrand, // 收藏品牌 |
62 | toggleFavShop // 收藏店铺 | 67 | toggleFavShop // 收藏店铺 |
@@ -902,6 +902,7 @@ const getBaseShopData = (params, extra, channel, shopId) => { | @@ -902,6 +902,7 @@ const getBaseShopData = (params, extra, channel, shopId) => { | ||
902 | shopIntro: `/about?shopId=${shopId}`, | 902 | shopIntro: `/about?shopId=${shopId}`, |
903 | coled: _.get(result[2], 'data.is_favorite', 'N') === 'Y' | 903 | coled: _.get(result[2], 'data.is_favorite', 'N') === 'Y' |
904 | }); | 904 | }); |
905 | + | ||
905 | _.set(resData, 'brand.shopBanner', decorator.shopTopBannerBase); | 906 | _.set(resData, 'brand.shopBanner', decorator.shopTopBannerBase); |
906 | _.unset(resData, 'brand.brandBanner'); | 907 | _.unset(resData, 'brand.brandBanner'); |
907 | 908 | ||
@@ -914,6 +915,7 @@ const getBaseShopData = (params, extra, channel, shopId) => { | @@ -914,6 +915,7 @@ const getBaseShopData = (params, extra, channel, shopId) => { | ||
914 | if (result[2].code === 200) { | 915 | if (result[2].code === 200) { |
915 | let shopName = _.get(result[2], 'data.shop_name', ''); | 916 | let shopName = _.get(result[2], 'data.shop_name', ''); |
916 | 917 | ||
918 | + _.set(resData, 'brand.shopBanner.shopName', shopName); | ||
917 | _.set(resData, 'brand.pathNav[2]', { | 919 | _.set(resData, 'brand.pathNav[2]', { |
918 | name: shopName, | 920 | name: shopName, |
919 | pathTitle: shopName | 921 | pathTitle: shopName |
@@ -525,5 +525,7 @@ module.exports = { | @@ -525,5 +525,7 @@ module.exports = { | ||
525 | getShopDecorator, | 525 | getShopDecorator, |
526 | getArticleByBrand, | 526 | getArticleByBrand, |
527 | getShopList, | 527 | getShopList, |
528 | - getBrands4Filter | 528 | + getBrands4Filter, |
529 | + getProductListOrig, | ||
530 | + getSearchCackeKey | ||
529 | }; | 531 | }; |
@@ -6,6 +6,10 @@ | @@ -6,6 +6,10 @@ | ||
6 | 'use strict'; | 6 | 'use strict'; |
7 | 7 | ||
8 | const api = global.yoho.API; | 8 | const api = global.yoho.API; |
9 | +const config = require('../../../config/common'); | ||
10 | +const searchApi = require('./search-api'); | ||
11 | +const cache = global.yoho.cache; | ||
12 | +const logger = global.yoho.logger; | ||
9 | 13 | ||
10 | /** | 14 | /** |
11 | * 获取完成认证学生总数 | 15 | * 获取完成认证学生总数 |
@@ -115,3 +119,58 @@ exports.userAcquireStatus = (uid, couponIds) => { | @@ -115,3 +119,58 @@ exports.userAcquireStatus = (uid, couponIds) => { | ||
115 | 119 | ||
116 | return api.get('', finalParams); | 120 | return api.get('', finalParams); |
117 | }; | 121 | }; |
122 | + | ||
123 | + | ||
124 | +/** | ||
125 | + * 获取学生专享商品列表 | ||
126 | + * @return | ||
127 | + */ | ||
128 | +exports.getStudentsProduct = (params) => { | ||
129 | + let finalParams = { | ||
130 | + method: 'app.student.rebate', | ||
131 | + sales: 'Y', | ||
132 | + stocknumber: 1, | ||
133 | + need_filter: 'yes', | ||
134 | + limit: 60 | ||
135 | + }; | ||
136 | + | ||
137 | + Object.assign(finalParams, params); | ||
138 | + if (!config.useCache) { | ||
139 | + return searchApi.getProductListOrig(finalParams); | ||
140 | + } else { | ||
141 | + let cKey = searchApi.getSearchCackeKey(finalParams); | ||
142 | + | ||
143 | + return cache.get(cKey).catch().then(cdata => { | ||
144 | + let hasCache = false; | ||
145 | + | ||
146 | + if (cdata) { | ||
147 | + | ||
148 | + try { | ||
149 | + cdata = JSON.parse(cdata); | ||
150 | + } catch (e) { | ||
151 | + logger.debug('getProductList cache data parse fail.'); | ||
152 | + } | ||
153 | + | ||
154 | + if (cdata.filter && cdata.standard) { | ||
155 | + hasCache = true; | ||
156 | + finalParams.need_filter = 'no'; | ||
157 | + } | ||
158 | + } | ||
159 | + | ||
160 | + return searchApi.getProductListOrig(finalParams).then(result => { | ||
161 | + if (hasCache && result && result.data) { | ||
162 | + Object.assign(result.data, cdata); | ||
163 | + } else { | ||
164 | + if (result && result.data && result.data.filter) { | ||
165 | + cache.set(cKey, Object.assign({}, { | ||
166 | + filter: result.data.filter, | ||
167 | + standard: result.data.standard | ||
168 | + }), 3600); | ||
169 | + } | ||
170 | + } | ||
171 | + | ||
172 | + return result; | ||
173 | + }); | ||
174 | + }); | ||
175 | + } | ||
176 | +}; |
@@ -115,7 +115,7 @@ exports.stuProducts = (data) => { | @@ -115,7 +115,7 @@ exports.stuProducts = (data) => { | ||
115 | data[key].market_price = data[key].sales_price; | 115 | data[key].market_price = data[key].sales_price; |
116 | delete data[key].sales_price; | 116 | delete data[key].sales_price; |
117 | if (value.student_price) { | 117 | if (value.student_price) { |
118 | - Object.assign(data[key], {forStu: true}); | 118 | + Object.assign(data[key], {for_stu: true}); |
119 | } | 119 | } |
120 | }); | 120 | }); |
121 | return products; | 121 | return products; |
@@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
5 | */ | 5 | */ |
6 | 6 | ||
7 | 'use strict'; | 7 | 'use strict'; |
8 | - | 8 | +const utils = '../../../utils'; |
9 | const api = global.yoho.API; | 9 | const api = global.yoho.API; |
10 | const queryString = require('querystring'); | 10 | const queryString = require('querystring'); |
11 | const _ = require('lodash'); | 11 | const _ = require('lodash'); |
@@ -14,11 +14,13 @@ const studentsApi = require('./students-api'); | @@ -14,11 +14,13 @@ const studentsApi = require('./students-api'); | ||
14 | const stuHandler = require('./students-handler'); | 14 | const stuHandler = require('./students-handler'); |
15 | const helpers = global.yoho.helpers; | 15 | const helpers = global.yoho.helpers; |
16 | const crypto = global.yoho.crypto; | 16 | const crypto = global.yoho.crypto; |
17 | - | ||
18 | -// const productProcess = require(`${utils}/product-process`); | ||
19 | -// const _ = require('lodash'); | ||
20 | const headerModel = require('../../../doraemon/models/header'); | 17 | const headerModel = require('../../../doraemon/models/header'); |
21 | const serviceApi = global.yoho.ServiceAPI; | 18 | const serviceApi = global.yoho.ServiceAPI; |
19 | +const searchApi = require('./search-api'); | ||
20 | + | ||
21 | +const productProcess = require(`${utils}/product-process`); | ||
22 | +const searchHandler = require('./search-handler'); | ||
23 | +const needParams = ['query', 'msort', 'misort', 'gender', 'shelveTime']; | ||
22 | 24 | ||
23 | // 学生营销资源码 | 25 | // 学生营销资源码 |
24 | const studentsCode = '989396a17443bf61e3e269702e51ef04'; // h5 a83b7d55324fb65f96c1f85a3387ebd8 | 26 | const studentsCode = '989396a17443bf61e3e269702e51ef04'; // h5 a83b7d55324fb65f96c1f85a3387ebd8 |
@@ -177,3 +179,86 @@ exports.userAcquireStatus = (uid, couponIds) => { | @@ -177,3 +179,86 @@ exports.userAcquireStatus = (uid, couponIds) => { | ||
177 | return result; | 179 | return result; |
178 | }); | 180 | }); |
179 | }; | 181 | }; |
182 | + | ||
183 | +/** | ||
184 | + * 获取学生返币专享商品列表数据 | ||
185 | + */ | ||
186 | +exports.getStudentsList = (params, channel) => { | ||
187 | + let standard = []; | ||
188 | + | ||
189 | + _.forEach(params, (value, key) => { | ||
190 | + let s = _.split(key, 'parameter_', 2); | ||
191 | + | ||
192 | + if (s.length > 1) { | ||
193 | + standard.push(`${s[1]}_${value}`); | ||
194 | + _.unset(params, `${key}`); | ||
195 | + } | ||
196 | + }); | ||
197 | + | ||
198 | + if (standard.length) { | ||
199 | + params.standard = standard.join(','); | ||
200 | + } | ||
201 | + | ||
202 | + let searchParams = searchHandler.getSearchParams(params); | ||
203 | + | ||
204 | + // 调用接口 | ||
205 | + let apiMethod = [ | ||
206 | + headerModel.requestHeaderData(channel), | ||
207 | + searchApi.getSortList(Object.assign({}, {msort: '', misort: ''})), | ||
208 | + studentsApi.getStudentsProduct(searchParams) | ||
209 | + ]; | ||
210 | + | ||
211 | + return Promise.all(apiMethod).then(result => { | ||
212 | + let finalResult = { | ||
213 | + module: 'product', | ||
214 | + page: 'list', | ||
215 | + headerData: Object.assign(result[0].headerData, { | ||
216 | + header: true | ||
217 | + }), | ||
218 | + list: { | ||
219 | + leftContent: {} | ||
220 | + } | ||
221 | + }; | ||
222 | + | ||
223 | + // 获取左侧类目数据 | ||
224 | + if (result[1].code === 200) { | ||
225 | + let dps = {}; | ||
226 | + | ||
227 | + _.forEach(needParams, (value) => { | ||
228 | + if (params[value]) { | ||
229 | + dps[value] = params[value]; | ||
230 | + } | ||
231 | + }); | ||
232 | + | ||
233 | + finalResult.list = Object.assign( | ||
234 | + searchHandler.handlePathNavData(result[1].data.sort, params, 'sort', channel), { | ||
235 | + leftContent: searchHandler.handleSortData(result[1].data.sort, dps) | ||
236 | + }); | ||
237 | + } | ||
238 | + | ||
239 | + // 获取商品数据和顶部筛选条件 | ||
240 | + if (result[2].code === 200) { | ||
241 | + //删掉student_price,不让页面显示 | ||
242 | + _.forEach(result[2].data.product_list, goods => { | ||
243 | + delete goods.student_price; | ||
244 | + }); | ||
245 | + Object.assign(finalResult.list, { | ||
246 | + filters: searchHandler.handleFilterDataAll(result[2].data, params), | ||
247 | + opts: searchHandler.handleOptsData(params, result[2].data.total, result[2].data.filter), | ||
248 | + totalCount: result[2].data.total, | ||
249 | + footPager: searchHandler.handlePagerData(result[2].data.total, params), | ||
250 | + goods: productProcess.processProductList(result[2].data.product_list, | ||
251 | + Object.assign({showDiscount: false}, params, { | ||
252 | + from: {type: 'list', params: params} | ||
253 | + })), | ||
254 | + hasNextPage: searchHandler.handleNextPage(params, result[2].data.total), | ||
255 | + | ||
256 | + // 最近浏览记录 | ||
257 | + latestWalk: 6 | ||
258 | + }); | ||
259 | + } | ||
260 | + | ||
261 | + finalResult.criteo = {skn: searchHandler.getCriteo(_.get(finalResult.list, 'goods'))}; | ||
262 | + return Object.assign({}, finalResult); | ||
263 | + }); | ||
264 | +}; |
@@ -61,6 +61,7 @@ router.post('/index/favoriteBrand', favorite.changeFavoriteBrand);// 收è—å“ç‰ | @@ -61,6 +61,7 @@ router.post('/index/favoriteBrand', favorite.changeFavoriteBrand);// 收è—å“ç‰ | ||
61 | router.post('/item/togglecollect', favorite.collectProduct); // 收藏商品 | 61 | router.post('/item/togglecollect', favorite.collectProduct); // 收藏商品 |
62 | router.get('/detail/header', detail.productHeader); // 价格数据重新获取接口 | 62 | router.get('/detail/header', detail.productHeader); // 价格数据重新获取接口 |
63 | router.get('/detail/return', detail.detailReturn);// 特殊商品退换货 | 63 | router.get('/detail/return', detail.detailReturn);// 特殊商品退换货 |
64 | +router.get('/index/isfav', favorite.isFavoriteBrand);// 品牌收藏状态 | ||
64 | 65 | ||
65 | // 搜索 | 66 | // 搜索 |
66 | router.get('/search/index', search.index); | 67 | router.get('/search/index', search.index); |
@@ -84,6 +85,7 @@ router.get('/index/about', list.brandAbout); | @@ -84,6 +85,7 @@ router.get('/index/about', list.brandAbout); | ||
84 | 85 | ||
85 | router.get('/shoplist', list.shopList); // 店铺列表页 | 86 | router.get('/shoplist', list.shopList); // 店铺列表页 |
86 | router.post('/shop/togglecollect', favorite.collectShop); // 店铺收藏 | 87 | router.post('/shop/togglecollect', favorite.collectShop); // 店铺收藏 |
88 | +router.post('/index/isFavoriteShop', favorite.isFavShop); // 判断用户是否收藏品牌 | ||
87 | 89 | ||
88 | // 品牌页水牌 | 90 | // 品牌页水牌 |
89 | router.post('/index/getNodeContent', list.getNodeContent); | 91 | router.post('/index/getNodeContent', list.getNodeContent); |
@@ -101,5 +103,6 @@ router.get('/students/schoolList', students.schoolList); // å¦æ ¡åœ°åŒº | @@ -101,5 +103,6 @@ router.get('/students/schoolList', students.schoolList); // å¦æ ¡åœ°åŒº | ||
101 | router.get('/students/eduLevel', students.eduLevel); // 学校地区 | 103 | router.get('/students/eduLevel', students.eduLevel); // 学校地区 |
102 | router.get('/students/verify', students.verify); // 身份验证 | 104 | router.get('/students/verify', students.verify); // 身份验证 |
103 | router.get('/students/userAcquireStatus', students.userAcquireStatus); // 获取优惠券领取状态 | 105 | router.get('/students/userAcquireStatus', students.userAcquireStatus); // 获取优惠券领取状态 |
106 | +router.get('/students/list', students.list); // 获取优惠券领取状态 | ||
104 | 107 | ||
105 | module.exports = router; | 108 | module.exports = router; |
@@ -30,6 +30,7 @@ module.exports = { | @@ -30,6 +30,7 @@ module.exports = { | ||
30 | activity: '//activity.yohobuy.com', | 30 | activity: '//activity.yohobuy.com', |
31 | index: '//yohobuy.com' | 31 | index: '//yohobuy.com' |
32 | }, | 32 | }, |
33 | + zookeeperServer: '192.168.102.168:2188', | ||
33 | useOneapm: false, | 34 | useOneapm: false, |
34 | useCache: false, | 35 | useCache: false, |
35 | memcache: { | 36 | memcache: { |
1 | -<!DOCTYPE html> | ||
2 | -<html> | ||
3 | - <head> | ||
4 | - <meta charset="utf-8"> | ||
5 | - <title>{{title}}</title> | ||
6 | - <meta name="keywords" content="{{keywords}}"> | ||
7 | - <meta name="description" content="{{description}}"> | ||
8 | - <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"> | ||
9 | - <meta http-equiv="cleartype" content="on"> | ||
10 | - <meta name="apple-mobile-web-app-status-bar-style" content="black" /> | ||
11 | - <meta content="telephone=no" name="format-detection" /> | ||
12 | - <meta content="email=no" name="format-detection" /> | ||
13 | - <link rel="dns-prefetch" href="//cdn.yoho.cn"> | ||
14 | - <link rel="dns-prefetch" href="//static.yohobuy.com"> | ||
15 | - <link rel="dns-prefetch" href="//img12.static.yhbimg.com"> | ||
16 | - <link rel="dns-prefetch" href="//img13.static.yhbimg.com"> | ||
17 | - {{#if devEnv}} | ||
18 | - <link rel="stylesheet" href="//localhost:5002/css/index.css"> | ||
19 | - {{^}} | ||
20 | - <link rel="stylesheet" href="//cdn.yoho.cn/yohobuy-node/{{version}}/index.css"> | ||
21 | - {{/if}} | ||
22 | - </head> | ||
23 | - <body> | ||
24 | - {{> header}} | ||
25 | - {{> common/simple-header}} | ||
26 | - {{#if pageErr}} | ||
27 | - {{> 404}} | ||
28 | - {{^}} | ||
29 | - {{{body}}} | ||
30 | - {{/if}} | ||
31 | - {{> footer}} | ||
32 | - {{#if devEnv}} | ||
33 | - <script src="//localhost:5002/libs.js"></script> | ||
34 | - <script src="//localhost:5002/{{module}}.{{page}}.js"></script> | ||
35 | - {{^}} | ||
36 | - <script src="//cdn.yoho.cn/yohobuy-node/{{version}}/libs.js"></script> | ||
37 | - <script src="//cdn.yoho.cn/yohobuy-node/{{version}}/{{module}}.{{page}}.js"></script> | ||
38 | - {{> analysis}} | ||
39 | - {{/if}} | ||
40 | - </body> | ||
41 | -</html> | 1 | +<!DOCTYPE html> |
2 | +<html> | ||
3 | + <head> | ||
4 | + <meta charset="utf-8"> | ||
5 | + <title>{{title}}</title> | ||
6 | + <meta name="keywords" content="{{keywords}}"> | ||
7 | + <meta name="description" content="{{description}}"> | ||
8 | + <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"> | ||
9 | + <meta http-equiv="cleartype" content="on"> | ||
10 | + <meta name="apple-mobile-web-app-status-bar-style" content="black" /> | ||
11 | + <meta content="telephone=no" name="format-detection" /> | ||
12 | + <meta content="email=no" name="format-detection" /> | ||
13 | + <link rel="dns-prefetch" href="//cdn.yoho.cn"> | ||
14 | + <link rel="dns-prefetch" href="//static.yohobuy.com"> | ||
15 | + <link rel="dns-prefetch" href="//img12.static.yhbimg.com"> | ||
16 | + <link rel="dns-prefetch" href="//img13.static.yhbimg.com"> | ||
17 | + {{#if devEnv}} | ||
18 | + <link rel="stylesheet" href="//localhost:5002/css/index.css"> | ||
19 | + {{^}} | ||
20 | + <link rel="stylesheet" href="//cdn.yoho.cn/yohobuy-node/{{version}}/index.css"> | ||
21 | + {{/if}} | ||
22 | + </head> | ||
23 | + <body> | ||
24 | + {{> header}} | ||
25 | + {{> common/simple-header}} | ||
26 | + {{#if pageErr}} | ||
27 | + {{> 404}} | ||
28 | + {{^}} | ||
29 | + {{{body}}} | ||
30 | + {{/if}} | ||
31 | + {{> footer}} | ||
32 | + {{#if devEnv}} | ||
33 | + <script src="//localhost:5002/libs.js"></script> | ||
34 | + <script src="//localhost:5002/{{module}}.{{page}}.js"></script> | ||
35 | + {{^}} | ||
36 | + <script src="//cdn.yoho.cn/yohobuy-node/{{version}}/libs.js"></script> | ||
37 | + <script src="//cdn.yoho.cn/yohobuy-node/{{version}}/{{module}}.{{page}}.js"></script> | ||
38 | + {{> analysis}} | ||
39 | + {{/if}} | ||
40 | + </body> | ||
41 | +</html> |
@@ -809,6 +809,19 @@ window.fetchReturn = fetchReturn; | @@ -809,6 +809,19 @@ window.fetchReturn = fetchReturn; | ||
809 | $('.main').html(result); | 809 | $('.main').html(result); |
810 | bindEvent.fire(); | 810 | bindEvent.fire(); |
811 | }); | 811 | }); |
812 | + | ||
813 | + $.ajax({ | ||
814 | + type: 'GET', | ||
815 | + url: '/product/index/isfav', | ||
816 | + data: { | ||
817 | + brandId: $('#brand-favour').data('id') | ||
818 | + } | ||
819 | + }).then(function(result) { | ||
820 | + if (result.code === 200) { | ||
821 | + $('#brand-favour').addClass('coled'); | ||
822 | + } | ||
823 | + }); | ||
824 | + | ||
812 | }()); | 825 | }()); |
813 | 826 | ||
814 | // 数据懒加载 | 827 | // 数据懒加载 |
@@ -72,3 +72,22 @@ if ($brandFavor && $brandFavor.length) { | @@ -72,3 +72,22 @@ if ($brandFavor && $brandFavor.length) { | ||
72 | } | 72 | } |
73 | }); | 73 | }); |
74 | } | 74 | } |
75 | + | ||
76 | +// 页面进入更新收藏状态 | ||
77 | +if ($shopFavor && $shopFavor.length) { | ||
78 | + $.ajax({ | ||
79 | + type: 'POST', | ||
80 | + url: '/product/index/isFavoriteShop', | ||
81 | + data: { | ||
82 | + shopId: shopId | ||
83 | + } | ||
84 | + }).then(function(data) { | ||
85 | + if (data.code === 200 && data.data) { | ||
86 | + // 已收藏 | ||
87 | + $shopFavor.find('i').addClass('coled'); | ||
88 | + return; | ||
89 | + } | ||
90 | + | ||
91 | + $shopFavor.find('i').removeClass('coled'); | ||
92 | + }); | ||
93 | +} |
@@ -11,12 +11,16 @@ var product = require('./index/product'); | @@ -11,12 +11,16 @@ var product = require('./index/product'); | ||
11 | 11 | ||
12 | var $shopIntro = $('.shop-intro'), | 12 | var $shopIntro = $('.shop-intro'), |
13 | $shopCollect = $('.shop-collect'), | 13 | $shopCollect = $('.shop-collect'), |
14 | + $colloectIcon = $shopCollect.find('.shop-collect-ico'), | ||
15 | + $colloectText = $shopCollect.find('.shop-collect-text'), | ||
14 | $searchForm = $('#shop-search-form'), | 16 | $searchForm = $('#shop-search-form'), |
15 | $sliderLeft = $('.slider-left'), | 17 | $sliderLeft = $('.slider-left'), |
16 | $allGoods = $('.all-goods'), | 18 | $allGoods = $('.all-goods'), |
17 | $fixedArea = $allGoods.find('.fixed-area'), | 19 | $fixedArea = $allGoods.find('.fixed-area'), |
18 | fixedAreaTop = $fixedArea.offset() ? $fixedArea.offset().top : 0; | 20 | fixedAreaTop = $fixedArea.offset() ? $fixedArea.offset().top : 0; |
19 | 21 | ||
22 | +var shopId = $shopCollect.data('id'); | ||
23 | + | ||
20 | // Pjax | 24 | // Pjax |
21 | require('yoho-jquery-pjax'); | 25 | require('yoho-jquery-pjax'); |
22 | 26 | ||
@@ -36,6 +40,26 @@ if ($sliderLeft.length) { | @@ -36,6 +40,26 @@ if ($sliderLeft.length) { | ||
36 | $sliderLeft.slider(); | 40 | $sliderLeft.slider(); |
37 | } | 41 | } |
38 | 42 | ||
43 | +if ($shopCollect && $shopCollect.length) { | ||
44 | + $.ajax({ | ||
45 | + type: 'POST', | ||
46 | + url: '/product/index/isFavoriteShop', | ||
47 | + data: { | ||
48 | + shopId: shopId | ||
49 | + } | ||
50 | + }).then(function(data) { | ||
51 | + if (data.code === 200 && data.data) { | ||
52 | + // 已收藏 | ||
53 | + $colloectIcon.addClass('on'); | ||
54 | + $colloectText.html('已收藏'); | ||
55 | + return; | ||
56 | + } | ||
57 | + | ||
58 | + $colloectIcon.removeClass('on'); | ||
59 | + $colloectText.html('收藏'); | ||
60 | + }); | ||
61 | +} | ||
62 | + | ||
39 | $shopIntro.on('click', function() { | 63 | $shopIntro.on('click', function() { |
40 | $('.pop-shop-intro').show(); | 64 | $('.pop-shop-intro').show(); |
41 | $('.mask').show(); | 65 | $('.mask').show(); |
@@ -53,9 +77,7 @@ $('.shop-query-submit').on('click', function() { | @@ -53,9 +77,7 @@ $('.shop-query-submit').on('click', function() { | ||
53 | 77 | ||
54 | // 收藏店铺 | 78 | // 收藏店铺 |
55 | function colloectAction() { | 79 | function colloectAction() { |
56 | - var $colloectIcon = $shopCollect.find('.shop-collect-ico'), | ||
57 | - $colloectText = $shopCollect.find('.shop-collect-text'), | ||
58 | - isFavorite = $colloectIcon.hasClass('on'), | 80 | + var isFavorite = $colloectIcon.hasClass('on'), |
59 | needColloect = window.cookie('needColloect'); | 81 | needColloect = window.cookie('needColloect'); |
60 | 82 | ||
61 | $.ajax({ | 83 | $.ajax({ |
@@ -64,7 +86,7 @@ function colloectAction() { | @@ -64,7 +86,7 @@ function colloectAction() { | ||
64 | data: { | 86 | data: { |
65 | isFavorite: isFavorite ? 0 : 1, | 87 | isFavorite: isFavorite ? 0 : 1, |
66 | needColloect: needColloect, | 88 | needColloect: needColloect, |
67 | - shopId: $shopCollect.data('id') | 89 | + shopId: shopId |
68 | }, | 90 | }, |
69 | success: function(res) { | 91 | success: function(res) { |
70 | if (res.code === 200) { | 92 | if (res.code === 200) { |
@@ -448,7 +448,7 @@ $couponDia.on('click', function() { | @@ -448,7 +448,7 @@ $couponDia.on('click', function() { | ||
448 | $rightDia.on('click', function() { | 448 | $rightDia.on('click', function() { |
449 | var cont = '<h3 class="dia-title">特权详细说明</h3>' + | 449 | var cont = '<h3 class="dia-title">特权详细说明</h3>' + |
450 | '<p>权益1:新品立享9折</p>' + | 450 | '<p>权益1:新品立享9折</p>' + |
451 | - '<p>学生购买原价新品时,可立即享受9折优惠,与VIP折扣不可同时享受。</p><br>' + | 451 | + '<p>学生购买指定原价新品时,可立即享受9折优惠,与VIP折扣不可同时享受。</p><br>' + |
452 | '<p>权益2:每1元返1个有货币</p>' + | 452 | '<p>权益2:每1元返1个有货币</p>' + |
453 | '<p>学生购买指定商品时,以商品的实际成交金额计算,每1元返1个有货币;</p>' + | 453 | '<p>学生购买指定商品时,以商品的实际成交金额计算,每1元返1个有货币;</p>' + |
454 | '<p>返有货币时间:确认收货7日后,系统将自动将对应数量的有货币返至购买账户;</p>' + | 454 | '<p>返有货币时间:确认收货7日后,系统将自动将对应数量的有货币返至购买账户;</p>' + |
@@ -662,7 +662,7 @@ $(function() { | @@ -662,7 +662,7 @@ $(function() { | ||
662 | 662 | ||
663 | var rightsFirst = '<div class="item-content hide">' + | 663 | var rightsFirst = '<div class="item-content hide">' + |
664 | '<p class="item-title">新品立享9折</p>' + | 664 | '<p class="item-title">新品立享9折</p>' + |
665 | - '<p>学生购买原价新品时,可立即享受9折优惠,与VIP折扣不可同时享受。</p></div>'; | 665 | + '<p>学生购买指定原价新品时,可立即享受9折优惠,与VIP折扣不可同时享受。</p></div>'; |
666 | 666 | ||
667 | var rightsSecond = '<div class="item-content hide">' + | 667 | var rightsSecond = '<div class="item-content hide">' + |
668 | '<p class="item-title">每1元返1个有货币</p>' + | 668 | '<p class="item-title">每1元返1个有货币</p>' + |
@@ -824,10 +824,12 @@ $(function() { | @@ -824,10 +824,12 @@ $(function() { | ||
824 | $('#stuRights .stu-rights-item:eq(0), #stuRights .stu-rights-item:eq(1),' + | 824 | $('#stuRights .stu-rights-item:eq(0), #stuRights .stu-rights-item:eq(1),' + |
825 | '#stuRights .stu-rights-item:eq(2), #stuRights .stu-rights-item:eq(3)').hover(function() { | 825 | '#stuRights .stu-rights-item:eq(2), #stuRights .stu-rights-item:eq(3)').hover(function() { |
826 | var content = $(this).find('.item-content'); | 826 | var content = $(this).find('.item-content'); |
827 | + | ||
828 | + var gapHeight; | ||
827 | 829 | ||
828 | content.removeClass('hide'); | 830 | content.removeClass('hide'); |
829 | 831 | ||
830 | - let gapHeight = parseInt(content.height(), 10) + 40 - parseInt($(this).height(), 10); | 832 | + gapHeight = parseInt(content.height(), 10) + 40 - parseInt($(this).height(), 10); |
831 | 833 | ||
832 | if (gapHeight > 0) { | 834 | if (gapHeight > 0) { |
833 | content.css('margin-top', -(gapHeight) + 'px'); | 835 | content.css('margin-top', -(gapHeight) + 'px'); |
@@ -57,6 +57,13 @@ | @@ -57,6 +57,13 @@ | ||
57 | width: 1150px; | 57 | width: 1150px; |
58 | margin: 0 auto; | 58 | margin: 0 auto; |
59 | 59 | ||
60 | + .shop-name { | ||
61 | + margin-left: 60px; | ||
62 | + font-size: 32px; | ||
63 | + float: left; | ||
64 | + border: none; | ||
65 | + } | ||
66 | + | ||
60 | .shop-favor { | 67 | .shop-favor { |
61 | margin-right: 60px; | 68 | margin-right: 60px; |
62 | } | 69 | } |
@@ -116,9 +116,10 @@ | @@ -116,9 +116,10 @@ | ||
116 | .stu-rights-item .item-content { | 116 | .stu-rights-item .item-content { |
117 | position: absolute; | 117 | position: absolute; |
118 | top: 0; | 118 | top: 0; |
119 | + min-height: 160px; | ||
119 | padding: 20px; | 120 | padding: 20px; |
120 | margin-top: 0; | 121 | margin-top: 0; |
121 | - transition: margin-top 2s linear; | 122 | + transition: margin-top 2.5s linear; |
122 | background: rgba(255,255,255,.95); | 123 | background: rgba(255,255,255,.95); |
123 | } | 124 | } |
124 | 125 |
@@ -16,9 +16,6 @@ const itemFromBase = { | @@ -16,9 +16,6 @@ const itemFromBase = { | ||
16 | saleSpecial: {domain: 'sale', module: 's'}// sale.yohobuy.com | 16 | saleSpecial: {domain: 'sale', module: 's'}// sale.yohobuy.com |
17 | }; | 17 | }; |
18 | 18 | ||
19 | -// NOTE: 这里修改了图片质量的参数 | ||
20 | -helpers.image = _.flow(helpers.image, fp.replace(/\/quality\/\d*$/, '/quality/90')); | ||
21 | - | ||
22 | /** | 19 | /** |
23 | * 根据性别来决定 默认图片获取字段 如果是 2、3 | 20 | * 根据性别来决定 默认图片获取字段 如果是 2、3 |
24 | * | 21 | * |
-
Please register or login to post a comment