Authored by yyq

Merge branch 'release/1.0' of git.yoho.cn:fe/yoho-blk into release/1.0

@@ -11,6 +11,7 @@ const list = { @@ -11,6 +11,7 @@ const list = {
11 let q = req.query; 11 let q = req.query;
12 12
13 q.page = parseInt(q.page || 1, 10); 13 q.page = parseInt(q.page || 1, 10);
  14 + q.order = q.order || 's_n_desc';
14 15
15 let retData = { 16 let retData = {
16 module: 'product', 17 module: 'product',
@@ -55,6 +56,7 @@ const list = { @@ -55,6 +56,7 @@ const list = {
55 let q = req.query; 56 let q = req.query;
56 57
57 q.page = parseInt(q.page || 1, 10); 58 q.page = parseInt(q.page || 1, 10);
  59 + q.order = q.order || 's_n_desc';
58 60
59 let retData = { 61 let retData = {
60 module: 'product', 62 module: 'product',
@@ -16,8 +16,10 @@ const DataHelper = require('../models/helpers'); @@ -16,8 +16,10 @@ const DataHelper = require('../models/helpers');
16 const Query = { 16 const Query = {
17 index: (req, res, next) => { 17 index: (req, res, next) => {
18 let q = req.query; 18 let q = req.query;
  19 + let query = q.query || '';
19 20
20 q.page = parseInt(q.page || 1, 10); 21 q.page = parseInt(q.page || 1, 10);
  22 + q.order = q.order || 's_n_desc';
21 23
22 let retData = { 24 let retData = {
23 module: 'product', 25 module: 'product',
@@ -32,11 +34,12 @@ const Query = { @@ -32,11 +34,12 @@ const Query = {
32 let nav = [DataHelper.getChannelNav()]; 34 let nav = [DataHelper.getChannelNav()];
33 35
34 nav.push({ 36 nav.push({
35 - name: `"${q.query}" ${data.total}个结果` 37 + name: `"${query}" ${data.total}个结果`
36 }); 38 });
37 39
38 if (data.filter) { 40 if (data.filter) {
39 retData.filter = DataHelper.filterHandle(data.filter, q); 41 retData.filter = DataHelper.filterHandle(data.filter, q);
  42 + retData.filter.showPrice = data.total > 10;
40 } 43 }
41 44
42 retData.navPath = { 45 retData.navPath = {
@@ -92,6 +92,7 @@ const shop = { @@ -92,6 +92,7 @@ const shop = {
92 let uid = cookie.getUid(req); 92 let uid = cookie.getUid(req);
93 let q = req.query; 93 let q = req.query;
94 94
  95 + q.order = q.order || 's_n_desc';
95 q.page = parseInt(q.page || 1, 10); 96 q.page = parseInt(q.page || 1, 10);
96 97
97 ShopData.getShopHeadData(domain, uid).then(result => { 98 ShopData.getShopHeadData(domain, uid).then(result => {
@@ -43,6 +43,7 @@ const helpers = { @@ -43,6 +43,7 @@ const helpers = {
43 }, 43 },
44 44
45 colorConvert(colors) { 45 colorConvert(colors) {
  46 + if (colors) {
46 return colors.map((c) => { 47 return colors.map((c) => {
47 return { 48 return {
48 id: c.colorId, 49 id: c.colorId,
@@ -50,6 +51,9 @@ const helpers = { @@ -50,6 +51,9 @@ const helpers = {
50 rgb: c.colorValue ? `url(${c.colorValue})` : '#' + c.colorCode 51 rgb: c.colorValue ? `url(${c.colorValue})` : '#' + c.colorCode
51 }; 52 };
52 }); 53 });
  54 + } else {
  55 + return [];
  56 + }
53 }, 57 },
54 58
55 getChannelNav() { 59 getChannelNav() {
@@ -119,6 +123,7 @@ const helpers = { @@ -119,6 +123,7 @@ const helpers = {
119 123
120 let matchPrice = false; 124 let matchPrice = false;
121 125
  126 + if (priceRange) {
122 priceRange = Object.keys(priceRange).map((k) => { 127 priceRange = Object.keys(priceRange).map((k) => {
123 let prices = k.split(','); 128 let prices = k.split(',');
124 let p = { 129 let p = {
@@ -129,6 +134,7 @@ const helpers = { @@ -129,6 +134,7 @@ const helpers = {
129 if (k === q.price) { 134 if (k === q.price) {
130 p.checked = true; 135 p.checked = true;
131 matchPrice = true; 136 matchPrice = true;
  137 + filters.push(this.newFilter('price', q.price, ${prices[0]}-¥${prices[1]}`));
132 } 138 }
133 return p; 139 return p;
134 }).sort((a, b) => { 140 }).sort((a, b) => {
@@ -137,14 +143,23 @@ const helpers = { @@ -137,14 +143,23 @@ const helpers = {
137 143
138 if (!matchPrice && q.price) { 144 if (!matchPrice && q.price) {
139 let prices = q.price.split(','); 145 let prices = q.price.split(',');
  146 + let priceTxt = ${prices[0]}-¥${prices[1]}`;
140 147
141 - filters.push(this.newFilter('price', q.price, ${prices[0]}-¥${prices[1]}`));  
142 customPriceLow = prices[0]; 148 customPriceLow = prices[0];
143 customPriceHigh = prices[1]; 149 customPriceHigh = prices[1];
  150 +
  151 + if (prices[1] === Number.MAX_SAFE_INTEGER.toString()) {
  152 + priceTxt = `大于¥${prices[0]}`;
  153 + customPriceHigh = '';
  154 + }
  155 +
  156 + filters.push(this.newFilter('price', q.price, priceTxt));
  157 +
  158 + }
144 } 159 }
145 160
146 161
147 - if (!_.isArray(sizeInfo)) { 162 + if (!_.isArray(sizeInfo) && sizeInfo) {
148 sizeInfo.checked = true; 163 sizeInfo.checked = true;
149 sizeInfo = [sizeInfo]; 164 sizeInfo = [sizeInfo];
150 } 165 }
@@ -197,6 +212,7 @@ const helpers = { @@ -197,6 +212,7 @@ const helpers = {
197 customPriceLow: customPriceLow, 212 customPriceLow: customPriceLow,
198 customPriceHigh: customPriceHigh, 213 customPriceHigh: customPriceHigh,
199 showSize: !!q.sort, 214 showSize: !!q.sort,
  215 + showPrice: true,
200 nav: this.getSortNav(q.sort, sorts) 216 nav: this.getSortNav(q.sort, sorts)
201 }; 217 };
202 }, 218 },
@@ -3,12 +3,22 @@ @@ -3,12 +3,22 @@
3 const api = global.yoho.API; 3 const api = global.yoho.API;
4 const _ = require('lodash'); 4 const _ = require('lodash');
5 5
6 -function clearEmptyVal(obj) { 6 +function _paramHanlde(obj) {
7 _.keys(obj).forEach(k => { 7 _.keys(obj).forEach(k => {
8 if (obj[k] === null || obj[k] === '') { 8 if (obj[k] === null || obj[k] === '') {
9 _.unset(obj, k); 9 _.unset(obj, k);
10 } 10 }
11 }); 11 });
  12 +
  13 + if (obj.price) {
  14 + let prices = obj.price.split(',');
  15 +
  16 + if (!prices[1]) {
  17 + prices[1] = Number.MAX_SAFE_INTEGER;
  18 + obj.price = prices.join(',');
  19 + }
  20 + }
  21 +
12 return obj; 22 return obj;
13 } 23 }
14 24
@@ -20,7 +30,7 @@ const Search = { @@ -20,7 +30,7 @@ const Search = {
20 limit: 45 30 limit: 45
21 }; 31 };
22 32
23 - Object.assign(finalParams, clearEmptyVal(params)); 33 + Object.assign(finalParams, _paramHanlde(params));
24 34
25 return api.get('', finalParams); 35 return api.get('', finalParams);
26 }, 36 },
@@ -30,7 +40,7 @@ const Search = { @@ -30,7 +40,7 @@ const Search = {
30 limit: 45 40 limit: 45
31 }; 41 };
32 42
33 - Object.assign(finalParams, clearEmptyVal(params)); 43 + Object.assign(finalParams, _paramHanlde(params));
34 44
35 return api.get('', finalParams); 45 return api.get('', finalParams);
36 }, 46 },
@@ -40,7 +50,7 @@ const Search = { @@ -40,7 +50,7 @@ const Search = {
40 limit: 45 50 limit: 45
41 }; 51 };
42 52
43 - Object.assign(finalParams, clearEmptyVal(params)); 53 + Object.assign(finalParams, _paramHanlde(params));
44 54
45 return api.get('', finalParams); 55 return api.get('', finalParams);
46 }, 56 },
@@ -122,8 +122,6 @@ const ShopService = { @@ -122,8 +122,6 @@ const ShopService = {
122 let brandId = domainInfo.id; 122 let brandId = domainInfo.id;
123 let brandInfo = yield BrandService.getBrandInfo(brandId, uid); 123 let brandInfo = yield BrandService.getBrandInfo(brandId, uid);
124 124
125 - console.log(brandInfo);  
126 -  
127 info.name = brandInfo.brandName; 125 info.name = brandInfo.brandName;
128 info.info = brandInfo.brandIntro; 126 info.info = brandInfo.brandIntro;
129 info.btnName = '品牌介绍'; 127 info.btnName = '品牌介绍';
@@ -71,6 +71,7 @@ @@ -71,6 +71,7 @@
71 </div> 71 </div>
72 {{/if}} 72 {{/if}}
73 73
  74 +{{#if showPrice}}
74 <div class="yoho-ui-accordion"> 75 <div class="yoho-ui-accordion">
75 <h3>价格</h3> 76 <h3>价格</h3>
76 <div class="body price-body"> 77 <div class="body price-body">
@@ -94,6 +95,7 @@ @@ -94,6 +95,7 @@
94 </div> 95 </div>
95 </div> 96 </div>
96 </div> 97 </div>
  98 +{{/if}}
97 99
98 {{#if showSize}} 100 {{#if showSize}}
99 <div class="yoho-ui-accordion"> 101 <div class="yoho-ui-accordion">
@@ -2,13 +2,15 @@ @@ -2,13 +2,15 @@
2 {{#each products}} 2 {{#each products}}
3 <div class="goods" data-id="{{productId}}" data-url="{{url}}"> 3 <div class="goods" data-id="{{productId}}" data-url="{{url}}">
4 <div class="goods-img"> 4 <div class="goods-img">
  5 + <a href="{{url}}">
5 <img class="lazy" data-original="{{image defaultImages 263 344}}" width="263" height="344" alt=""> 6 <img class="lazy" data-original="{{image defaultImages 263 344}}" width="263" height="344" alt="">
  7 + </a>
6 </div> 8 </div>
7 <div class="goods-brand"> 9 <div class="goods-brand">
8 - {{brandName}} 10 + <a href="/product/shop/{{brandDomain}}" target="_blank">{{brandName}}</a>
9 </div> 11 </div>
10 <div class="goods-name"> 12 <div class="goods-name">
11 - {{productName}} 13 + <a href="{{url}}">{{productName}}</a>
12 </div> 14 </div>
13 <div class="goods-price"> 15 <div class="goods-price">
14 <span>¥{{round salesPrice}}</span> 16 <span>¥{{round salesPrice}}</span>
@@ -18,7 +20,7 @@ @@ -18,7 +20,7 @@
18 </div> 20 </div>
19 <div class="goods-list hide"> 21 <div class="goods-list hide">
20 {{#each goodsList}} 22 {{#each goodsList}}
21 - <i data-url="{{url}}">{{image imagesUrl 265 344}}</i> 23 + <i data-url="{{url}}">{{image imagesUrl 256 343}}</i>
22 {{/each}} 24 {{/each}}
23 </div> 25 </div>
24 </div> 26 </div>
1 <div class="order-area"> 1 <div class="order-area">
2 - <div class="order {{#if order}}{{^}}selected{{/if}}" data-order="">综合</div> 2 + <div class="order {{#isEqual order 's_n_desc'}}selected{{/isEqual}}" data-order="s_n_desc">综合</div>
3 <div class="order {{#isEqual order 's_t_desc'}}selected{{/isEqual}}" data-order="s_t_desc">上新时间</div> 3 <div class="order {{#isEqual order 's_t_desc'}}selected{{/isEqual}}" data-order="s_t_desc">上新时间</div>
4 <div class="order order-price {{#isEqual order 's_p_asc'}}selected{{/isEqual}}{{#isEqual order 's_p_desc'}}selected{{/isEqual}}" data-order="s_p_asc,s_p_desc" data-target="price-dest">价格</div> 4 <div class="order order-price {{#isEqual order 's_p_asc'}}selected{{/isEqual}}{{#isEqual order 's_p_desc'}}selected{{/isEqual}}" data-order="s_p_asc,s_p_desc" data-target="price-dest">价格</div>
5 <div class="dest price-dest"> 5 <div class="dest price-dest">
@@ -26,9 +26,9 @@ module.exports = { @@ -26,9 +26,9 @@ module.exports = {
26 useOneapm: false, 26 useOneapm: false,
27 useCache: false, 27 useCache: false,
28 memcache: { 28 memcache: {
29 - master: ['192.168.102.168:11211'],  
30 - slave: ['192.168.102.168:11211'],  
31 - session: ['192.168.102.168:11211'], 29 + master: ['127.0.0.1:11211'],
  30 + slave: ['127.0.0.1:11211'],
  31 + session: ['127.0.0.1:11211'],
32 timeout: 1000, 32 timeout: 1000,
33 retries: 0 33 retries: 0
34 }, 34 },
@@ -112,9 +112,13 @@ var YohoListPage = { @@ -112,9 +112,13 @@ var YohoListPage = {
112 } 112 }
113 }); 113 });
114 114
  115 + $('.price-input input', this.rootDoc).keyup(function() {
  116 + $(this)[0].value = $(this)[0].value.replace(/\D+/g, '');
  117 + });
  118 +
115 $('.price-btns .confirm', this.rootDoc).click(function() { 119 $('.price-btns .confirm', this.rootDoc).click(function() {
116 var priceLow = $('.price-low', $(this).parent()).val() || 0; 120 var priceLow = $('.price-low', $(this).parent()).val() || 0;
117 - var priceHigh = $('.price-high', $(this).parent()).val() || 0; 121 + var priceHigh = $('.price-high', $(this).parent()).val() || '';
118 122
119 if (priceLow > 0 || priceHigh > 0) { 123 if (priceLow > 0 || priceHigh > 0) {
120 YohoListPage.go({ 124 YohoListPage.go({
@@ -139,7 +143,7 @@ var YohoListPage = { @@ -139,7 +143,7 @@ var YohoListPage = {
139 YohoListPage.openWin(url); 143 YohoListPage.openWin(url);
140 }); 144 });
141 145
142 - $('.goods-wrapper > .goods').click(function() { 146 + $('.goods-wrapper > .goods > img').click(function() {
143 var url = $(this).data('url'); 147 var url = $(this).data('url');
144 148
145 YohoListPage.openWin(url); 149 YohoListPage.openWin(url);