Authored by 周少峰

Merge branch 'hotfix/productMaterial' into gray

@@ -36,9 +36,9 @@ @@ -36,9 +36,9 @@
36 </div> 36 </div>
37 <div class="line"> 37 <div class="line">
38 <label for="">品类:</label> 38 <label for="">品类:</label>
39 - <select name="" id="category-1" class="sel"></select>  
40 - <select name="" id="category-2" class="sel"></select>  
41 - <select name="" id="category-3" class="sel"></select> 39 + <select name="" id="category-1" class="sel"><option value="">--请选择--</option></select>
  40 + <select name="" id="category-2" class="sel"><option value="">--请选择--</option></select>
  41 + <select name="" id="category-3" class="sel"><option value="">--请选择--</option></select>
42 <div class="search-recommend-btn">自动推荐</div> 42 <div class="search-recommend-btn">自动推荐</div>
43 <div class="search-btn">搜索</div> 43 <div class="search-btn">搜索</div>
44 </div> 44 </div>
@@ -11,8 +11,8 @@ @@ -11,8 +11,8 @@
11 {{#each product_list}} 11 {{#each product_list}}
12 <tr> 12 <tr>
13 <td>{{productSkn}}</td> 13 <td>{{productSkn}}</td>
14 - <td><a href="/p{{productId}}.html" target="_blank">{{productName}}</a></td>  
15 - <td><a href="/p{{productId}}.html" target="_blank"><img src="{{picImgUrl}}" alt=""></a></td> 14 + <td><a href="//item.yohobuy.com/p{{productId}}.html" target="_blank">{{productName}}</a></td>
  15 + <td><a href="//item.yohobuy.com/p{{productId}}.html" target="_blank"><img src="{{picImgUrl}}" alt=""></a></td>
16 <td>{{standardVal}}</td> 16 <td>{{standardVal}}</td>
17 <td>{{style}}</td> 17 <td>{{style}}</td>
18 <td>{{pattern}}</td> 18 <td>{{pattern}}</td>
@@ -11,8 +11,8 @@ @@ -11,8 +11,8 @@
11 {{#each product_list}} 11 {{#each product_list}}
12 <tr> 12 <tr>
13 <td>{{productSkn}}</td> 13 <td>{{productSkn}}</td>
14 - <td><a href="/p{{productId}}.html" target="_blank">{{productName}}</a></td>  
15 - <td><a href="/p{{productId}}.html" target="_blank"><img src="{{picImgUrl}}" alt=""></a></td> 14 + <td><a href="//item.yohobuy.com/p{{productId}}.html" target="_blank">{{productName}}</a></td>
  15 + <td><a href="//item.yohobuy.com/p{{productId}}.html" target="_blank"><img src="{{picImgUrl}}" alt=""></a></td>
16 <td>{{standardVal}}</td> 16 <td>{{standardVal}}</td>
17 <td>{{style}}</td> 17 <td>{{style}}</td>
18 <td>{{pattern}}</td> 18 <td>{{pattern}}</td>

6.57 KB | W: | H:

7.35 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
1 var $ = require('yoho-jquery'); 1 var $ = require('yoho-jquery');
2 -var _ = require('lodash');  
3 var brandTmp = require('hbs/material/brand.hbs'); 2 var brandTmp = require('hbs/material/brand.hbs');
4 var tableTmp = require('hbs/material/tbl.hbs'); 3 var tableTmp = require('hbs/material/tbl.hbs');
5 var $mask = $('.mask'); 4 var $mask = $('.mask');
6 var $brand = $('#brand_container'); 5 var $brand = $('#brand_container');
7 var query = { 6 var query = {
8 page: 1, 7 page: 1,
9 - maxSortId: 0,  
10 - middleSortId: 0,  
11 - smallSortId: 0 8 + maxSortId: '',
  9 + middleSortId: '',
  10 + smallSortId: ''
12 }; 11 };
13 var brandList = { 12 var brandList = {
14 list1: [], 13 list1: [],
@@ -16,6 +15,7 @@ var brandList = { @@ -16,6 +15,7 @@ var brandList = {
16 list3: [], 15 list3: [],
17 list4: [] 16 list4: []
18 }; 17 };
  18 +var option0 = '<option value="">--请选择--</option>';
19 19
20 function brandItemEventBind() { 20 function brandItemEventBind() {
21 $('#brand_container .item').off().on('click', function() { 21 $('#brand_container .item').off().on('click', function() {
@@ -45,7 +45,7 @@ function getBrandList(_index, yhChannel) { @@ -45,7 +45,7 @@ function getBrandList(_index, yhChannel) {
45 } 45 }
46 46
47 function getCategoryOpt(opts) { 47 function getCategoryOpt(opts) {
48 - var html = ''; 48 + var html = option0;
49 49
50 $.each(opts, function(k, c) { 50 $.each(opts, function(k, c) {
51 html += '<option value="' + c.sort_id + '">' + c.sort_name + '</option>'; 51 html += '<option value="' + c.sort_id + '">' + c.sort_name + '</option>';
@@ -54,6 +54,18 @@ function getCategoryOpt(opts) { @@ -54,6 +54,18 @@ function getCategoryOpt(opts) {
54 return html; 54 return html;
55 } 55 }
56 56
  57 +function findSub(data, id) {
  58 + var sub = [];
  59 +
  60 + $.each(data, function(k, c) {
  61 + if (c.sort_id === id) {
  62 + sub = c.sub;
  63 + }
  64 + });
  65 +
  66 + return sub;
  67 +}
  68 +
57 getBrandList(1, 1); 69 getBrandList(1, 1);
58 70
59 /* 获取品类数据*/ 71 /* 获取品类数据*/
@@ -72,21 +84,34 @@ $.get('/3party/material/getCategory', function(res) { @@ -72,21 +84,34 @@ $.get('/3party/material/getCategory', function(res) {
72 84
73 $category1.on('change', function() { 85 $category1.on('change', function() {
74 var id = $(this).val(); 86 var id = $(this).val();
  87 + var html = option0;
75 88
76 - sub = _.find(categoryData, {sort_id: id}).sub;  
77 - $category2.html(getCategoryOpt(sub)).show();  
78 - $category3.html('').hide(); 89 + query.maxSortId = '';
  90 + query.middleSortId = '';
  91 + query.smallSortId = '';
  92 +
  93 + if ($(this).find('option:selected').index() !== 0) {
  94 + sub = findSub(categoryData, id);
  95 + html = getCategoryOpt(sub);
79 query.maxSortId = id; 96 query.maxSortId = id;
80 - query.middleSortId = $category2.find('option').eq(0).attr('value'); 97 + }
  98 +
  99 + $category2.html(html);
  100 + $category3.html(option0);
81 }); 101 });
82 102
83 $category2.on('change', function() { 103 $category2.on('change', function() {
84 var id = $(this).val(); 104 var id = $(this).val();
85 - var third = _.find(sub, {sort_id: id}).sub; 105 + var third = [];
86 106
87 - $category3.html(getCategoryOpt(third)).show(); 107 + query.smallSortId = '';
  108 + query.middleSortId = '';
  109 +
  110 + if ($(this).find('option:selected').index() !== 0) {
  111 + third = findSub(sub, id);
  112 + $category3.html(getCategoryOpt(third));
88 query.middleSortId = id; 113 query.middleSortId = id;
89 - query.smallSortId = $category3.find('option').eq(0).attr('value'); 114 + }
90 }); 115 });
91 116
92 $category3.on('change', function() { 117 $category3.on('change', function() {
@@ -133,14 +133,6 @@ @@ -133,14 +133,6 @@
133 } 133 }
134 } 134 }
135 135
136 - #category-2 {  
137 - display: none;  
138 - }  
139 -  
140 - #category-3 {  
141 - display: none;  
142 - }  
143 -  
144 .search-btn { 136 .search-btn {
145 float: right; 137 float: right;
146 border-radius: 4px; 138 border-radius: 4px;