Authored by 姜敏

资源位-品牌搜索修改

@@ -109,26 +109,30 @@ var Bll = { @@ -109,26 +109,30 @@ var Bll = {
109 getBrands: function () { 109 getBrands: function () {
110 var Brand = {}; 110 var Brand = {};
111 $.get("/ajax/yohosearch", function (res) { 111 $.get("/ajax/yohosearch", function (res) {
112 - res.data.forEach(function (item, index) {  
113 - var brandAlif = (item.brand_alif || "").toUpperCase();  
114 - if (/^[0-9]$/.test(item.brand_alif)) {  
115 - brandAlif = "0-9"; 112 + if(!res.data||!res.data.brands){
  113 + return;
  114 + }
  115 + for(var key in res.data.brands){
  116 + var name=key;
  117 + if (/^[0-9]$/.test(name)) {
  118 + name = "0-9";
116 } 119 }
117 - if (/^\W$/.test(item.brand_alif)) {  
118 - brandAlif = "#"; 120 + if (name==="") {
  121 + name = "#";
119 } 122 }
120 - Brand[brandAlif] = Brand[brandAlif] || [];  
121 - Brand[brandAlif].push(item);  
122 - Bll.Brands1[item.id] = item;  
123 - }); 123 + for(var key2 in res.data.brands[key]){
  124 + var item=res.data.brands[key][key2];
  125 + Brand[name] = Brand[name] || [];
  126 + Brand[name].push(item);
  127 + Bll.Brands1[item.id] = item;
  128 + }
  129 + }
124 for (var i in Brand) { 130 for (var i in Brand) {
125 Brand[i].sort(function (a, b) { 131 Brand[i].sort(function (a, b) {
126 - if (a.brand_name && b.brand_name) {  
127 - var aName = a.brand_name.toLowerCase(),  
128 - bName = b.brand_name.toLowerCase();  
129 - if (aName < bName) return -1;  
130 - if (aName > bName) return 1;  
131 - } 132 + var aName = a.brand_name.toLowerCase(),
  133 + bName = b.brand_name.toLowerCase();
  134 + if (aName < bName) return -1;
  135 + if (aName > bName) return 1;
132 return 0; 136 return 0;
133 }); 137 });
134 Bll.Brands.push({ 138 Bll.Brands.push({