Authored by Rock Zhang

Merge branch 'develop' of git.dev.yoho.cn:web/yohobuy into develop

@@ -70,43 +70,46 @@ function searchResult() { @@ -70,43 +70,46 @@ function searchResult() {
70 i = 0, 70 i = 0,
71 html = ''; 71 html = '';
72 72
73 - // 遍历首字母搜索  
74 - $.each(brandsData, function(k, v) {  
75 - if ($.isArray(v)) { 73 + if (keyword !== '') {
  74 +
  75 + // 遍历首字母搜索
  76 + $.each(brandsData, function(k, v) {
  77 + if ($.isArray(v)) {
  78 +
  79 + // 遍历品牌,进行匹配
  80 + $.each(v, function(i, brand) {
  81 + if (brand.name.toLowerCase().indexOf(keyword) > -1) {
  82 + result[k] = result[k] || [];
  83 + result[k].push(brand);
  84 + }
  85 + });
  86 + }
  87 + });
76 88
77 - // 遍历品牌,进行匹配 89 + // 根据搜索结果生成 HTML
  90 + $.each(result, function(k, v) {
  91 + var brandHtml = ['<div class="brand-list bar-', i, '">'];
  92 +
  93 + i++;
  94 + brandHtml.push('<div class="title-bar"><h2>');
  95 + brandHtml.push(k);
  96 + brandHtml.push('</h2></div>');
78 $.each(v, function(i, brand) { 97 $.each(v, function(i, brand) {
79 - if (brand.name.toLowerCase().indexOf(keyword) > -1) {  
80 - result[k] = result[k] || [];  
81 - result[k].push(brand); 98 +
  99 + brandHtml.push('<p><a href="' + brand.url + '">' + brand.name);
  100 + if (brand.isNew) {
  101 + brandHtml.push('<i class="icon-hot">HOT</i>');
82 } 102 }
  103 + if (brand.isHot) {
  104 + brandHtml.push('<i class="icon-new">NEW</i>');
  105 + }
  106 + brandHtml.push('</a></p>');
83 }); 107 });
84 - }  
85 - }); 108 + brandHtml.push('</div>');
  109 + html += brandHtml.join('');
86 110
87 - // 根据搜索结果生成 HTML  
88 - $.each(result, function(k, v) {  
89 - var brandHtml = ['<div class="brand-list bar-', i, '">'];  
90 -  
91 - i++;  
92 - brandHtml.push('<div class="title-bar"><h2>');  
93 - brandHtml.push(k);  
94 - brandHtml.push('</h2></div>');  
95 - $.each(v, function(i, brand) {  
96 -  
97 - brandHtml.push('<p><a href="' + brand.url + '">' + brand.name);  
98 - if (brand.isNew) {  
99 - brandHtml.push('<i class="icon-hot">HOT</i>');  
100 - }  
101 - if (brand.isHot) {  
102 - brandHtml.push('<i class="icon-new">NEW</i>');  
103 - }  
104 - brandHtml.push('</a></p>');  
105 }); 111 });
106 - brandHtml.push('</div>');  
107 - html += brandHtml.join('');  
108 -  
109 - }); 112 + }
110 113
111 // 插入 dom,绑定事件 114 // 插入 dom,绑定事件
112 $('.search-result').html(html); 115 $('.search-result').html(html);
@@ -118,7 +121,6 @@ if ($('.brand-search-page').length) { @@ -118,7 +121,6 @@ if ($('.brand-search-page').length) {
118 121
119 $keyword.on('input', function() { 122 $keyword.on('input', function() {
120 if ($keyword.val().length) { 123 if ($keyword.val().length) {
121 - searchResult();  
122 $icon.css('color', '#000'); 124 $icon.css('color', '#000');
123 $(this).closest('.search-box').css('width', '11.25rem'); 125 $(this).closest('.search-box').css('width', '11.25rem');
124 $('.search-action').show(); 126 $('.search-action').show();
@@ -127,6 +129,7 @@ if ($('.brand-search-page').length) { @@ -127,6 +129,7 @@ if ($('.brand-search-page').length) {
127 $(this).closest('.search-box').css('width', '12.5rem'); 129 $(this).closest('.search-box').css('width', '12.5rem');
128 $('.search-action').hide(); 130 $('.search-action').hide();
129 } 131 }
  132 + searchResult();
130 }).focus(); 133 }).focus();
131 134
132 clearTextHammer = new Hammer($('.clear-text')[0]); 135 clearTextHammer = new Hammer($('.clear-text')[0]);
@@ -19,6 +19,8 @@ var tip = require('../../plugin/tip'); @@ -19,6 +19,8 @@ var tip = require('../../plugin/tip');
19 19
20 var brandId = $('#brand-info').data('id'); 20 var brandId = $('#brand-info').data('id');
21 21
  22 +var jumpToApp = $('#jump-to-app').val();
  23 +
22 var mIntro, aIntro; 24 var mIntro, aIntro;
23 25
24 var moreHammer, likeHammer; 26 var moreHammer, likeHammer;
@@ -71,6 +73,12 @@ likeHammer.on('tap', function(e) { @@ -71,6 +73,12 @@ likeHammer.on('tap', function(e) {
71 var opt = 'ok', 73 var opt = 'ok',
72 $this = $(e.target); 74 $this = $(e.target);
73 75
  76 +
  77 + //jumpToApp = 1表示APP未登录的情况,此时不发送ajax请求而由a链接直接跳转APP
  78 + if (jumpToApp === '1') {
  79 + return;
  80 + }
  81 +
74 e.preventDefault(); 82 e.preventDefault();
75 83
76 if ($this.hasClass('like')) { 84 if ($this.hasClass('like')) {
1 .good-list-page { 1 .good-list-page {
2 .search-input { 2 .search-input {
3 position: relative; 3 position: relative;
4 - padding: 7px 46px 7px 15px; 4 + padding: 7px 15px;
5 background: #f8f8f8; 5 background: #f8f8f8;
6 6
  7 + > form {
  8 + position: relative;
  9 + }
  10 +
7 .search-icon { 11 .search-icon {
8 position: absolute; 12 position: absolute;
9 font-size: 12px; 13 font-size: 12px;
10 - top: 16px;  
11 - left: 24px; 14 + top: 9px;
  15 + left: 10px;
12 } 16 }
13 17
14 input { 18 input {
15 height: 30px; 19 height: 30px;
16 - width: 95%; 20 + width: 85%;
17 border-radius: 15px; 21 border-radius: 15px;
18 text-indent: 26px; 22 text-indent: 26px;
19 background: #fff; 23 background: #fff;
@@ -22,14 +26,13 @@ @@ -22,14 +26,13 @@
22 26
23 .clear-input { 27 .clear-input {
24 position: absolute; 28 position: absolute;
25 - top: 12px; 29 + top: 5px;
26 right: 50px; 30 right: 50px;
27 } 31 }
28 32
29 .search { 33 .search {
30 - position: absolute;  
31 - top: 12px;  
32 - right: .4rem; 34 + float: right;
  35 + margin-top: 6px;
33 border: none; 36 border: none;
34 background: transparent; 37 background: transparent;
35 font-size: 16px; 38 font-size: 16px;
@@ -52,6 +52,8 @@ @@ -52,6 +52,8 @@
52 </div> 52 </div>
53 {{/if}} 53 {{/if}}
54 54
  55 + <input id="jump-to-app" type="hidden" value={{jumpToApp}}>
  56 +
55 {{!-- wx-share --}} 57 {{!-- wx-share --}}
56 <input id="shareLink" type="hidden" value={{shareLink}}> 58 <input id="shareLink" type="hidden" value={{shareLink}}>
57 <input id="shareImg" type="hidden" value={{shareImg}}> 59 <input id="shareImg" type="hidden" value={{shareImg}}>