Commit 0e306cd7 by 肖康

首页搜索修改

parent 469ae2e2
...@@ -133,15 +133,9 @@ ...@@ -133,15 +133,9 @@
line-height: 41rpx; line-height: 41rpx;
font-size: 24rpx; font-size: 24rpx;
color:$uni-color999; color:$uni-color999;
.pi1{width:139rpx;} .pi1{flex: 2;}
.pi2{width:318rpx;} .pi2{flex: 3;}
.w140{width:140rpx;} .pi3{flex: 3;}
.w120{width:120rpx;}
.hxj{
color:#C2C4CC!important;
font-weight: normal!important;
text-decoration-line: line-through;
}
&.titso{ &.titso{
color:$uni-color666; color:$uni-color666;
font-weight: 600; font-weight: 600;
......
...@@ -165,7 +165,12 @@ export default { ...@@ -165,7 +165,12 @@ export default {
intervalHandler: null intervalHandler: null
}; };
}, },
mounted() {
setTimeout(() => {
this.pbobj = this.$globalData;
this.kfurl = this.$globalData.kfqq_xk;
}, 500);
},
onShow() { onShow() {
this.getData(); this.getData();
}, },
...@@ -209,12 +214,7 @@ export default { ...@@ -209,12 +214,7 @@ export default {
}, 10000); }, 10000);
} }
}); });
this.request(Ichunt_Api + '/api/common/data', 'GET', {}).then(res => {
if (res.err_code === 0) {
this.pbobj = res.data;
this.kfurl = this.pbobj.kfqq_xk.data;
}
});
this.request(Api_Url + '/msg/allnum', 'POST', {}, false, true).then(res => { this.request(Api_Url + '/msg/allnum', 'POST', {}, false, true).then(res => {
if (res.err_code === 0) { if (res.err_code === 0) {
this.newscount = res.data; this.newscount = res.data;
......
...@@ -65,11 +65,14 @@ ...@@ -65,11 +65,14 @@
console.log(option); console.log(option);
this.searchVal=option.k||"" this.searchVal=option.k||""
}, },
mounted() {
setTimeout(() => {
this.obj = this.$globalData;
}, 500);
},
onShow:function(){ onShow:function(){
//获取历史记录 //获取历史记录
console.log(this.searchVal)
this.getsearchHistory() this.getsearchHistory()
this.getData()
}, },
methods: { methods: {
getListPOI(val_){ getListPOI(val_){
...@@ -79,13 +82,6 @@ ...@@ -79,13 +82,6 @@
} }
}); });
}, },
getData(){
this.request(Ichunt_Api + "/api/common/data", 'GET', {}, ).then(res => {
if (res.err_code === 0) {
this.obj = res.data;
}
});
},
getsearchHistory(){ getsearchHistory(){
let listhis_=uni.getStorageSync('historyItems'); let listhis_=uni.getStorageSync('historyItems');
if(listhis_){ if(listhis_){
......
...@@ -140,7 +140,13 @@ ...@@ -140,7 +140,13 @@
onLoad: function(option) { onLoad: function(option) {
this.searchVal = option.k; this.searchVal = option.k;
this.setHistoryItems(this.searchVal) this.setHistoryItems(this.searchVal)
this.getData() },
mounted() {
setTimeout(() => {
this.SEARCH_SUPPLIER_SINGLE=this.$globalData.SEARCH_SUPPLIER_SINGLE;
this.kfqqurl=this.$globalData.kfqq_xk
this.getSupplierData()
}, 500);
}, },
methods: { methods: {
//创建历史搜索缓存 最大10个 //创建历史搜索缓存 最大10个
...@@ -161,22 +167,76 @@ ...@@ -161,22 +167,76 @@
uni.setStorageSync('historyItems', historyItems); uni.setStorageSync('historyItems', historyItems);
} }
}, },
getData() { //综合排序
this.request(Ichunt_Api + "/api/common/data", 'GET', {}, ).then(res => { rankTotal(){
if (res.err_code === 0) { //按供应商排序
this.SEARCH_SUPPLIER_SINGLE=res.data.SEARCH_SUPPLIER_SINGLE; this.list.sort((a, b) => {
this.kfqqurl=res.data.kfqq_xk.data if (a.supplier_name == '国内现货') {
this.getSupplierData() return -1;
} } else if (b.supplier_name == '国内现货') {
return 1;
} else if (a.supplier_name == '国际现货') {
return -1;
} else if (b.supplier_name == '国际现货') {
return 1;
}
return 0;
}); });
//价格排序
this.list.forEach(item=>{
item.data.sort((a, b) => Number(a.ladder_price[0].price_ac||a.ladder_price[0].price_cn) - Number(b.ladder_price[0].price_ac||b.ladder_price[0].price_cn));
})
//完全匹配
this.list.forEach(item=>{
let piarr_=JSON.parse(JSON.stringify(item.data))
let arr1=[]
let arr2=[]
piarr_.forEach((iy,index)=>{
if (iy.goods_name.toLowerCase()==this.searchVal.toLowerCase()) {
arr1.push(iy)
}else{
arr2.push(iy)
}
})
item.data=[]
item.data=item.data.concat(arr1,arr2)
// console.log(piarr_)
// item.data.sort((a, b) => {
// if (a.goods_name.toLowerCase()==this.searchVal.toLowerCase()) {
// return -1;
// } else if (b.goods_name.toLowerCase()==this.searchVal.toLowerCase()) {
// return 1;
// }
// return 0;
// });
})
}, },
tab(type){ tab(type){
this.tabType=type; this.tabType=type;
if(type==2){ if(type==1){
this.stocksort=!this.stocksort this.rankTotal()
} }else if(type==2){
if(type==3){ this.stocksort=!this.stocksort;
if(this.stocksort){
this.list.forEach(item=>{
item.data.sort((b, a) => Number(a.stock) - Number(b.stock));
})
}else{
this.list.forEach(item=>{
item.data.sort((a, b) => Number(a.stock) - Number(b.stock));
})
}
}else if(type==3){
this.pricesort=!this.pricesort this.pricesort=!this.pricesort
if(this.pricesort){
this.list.forEach(item=>{
item.data.sort((b, a) => Number(a.ladder_price[0].price_ac||a.ladder_price[0].price_cn) - Number(b.ladder_price[0].price_ac||b.ladder_price[0].price_cn));
})
}else{
this.list.forEach(item=>{
item.data.sort((a, b) => Number(a.ladder_price[0].price_ac||a.ladder_price[0].price_cn) - Number(b.ladder_price[0].price_ac||b.ladder_price[0].price_cn));
})
}
} }
}, },
//品牌供应商搜索 //品牌供应商搜索
...@@ -285,15 +345,21 @@ ...@@ -285,15 +345,21 @@
name:key, name:key,
checked:false checked:false
} }
if(key=="国内现货"){ this.supplierArr.push(is_)
this.supplierArr.unshift(is_)
}else if(key=="猎芯期货"){
this.supplierArr.push(is_)
}else{
this.supplierArr.splice(1, 0, is_);
}
}) })
this.supplierArr.sort((a, b) => {
if (a.name == '国内现货') {
return -1;
} else if (b.name == '国内现货') {
return 1;
} else if (a.name == '国际现货') {
return -1;
} else if (b.name == '国际现货') {
return 1;
}
return 0;
});
//品牌处理 //品牌处理
obj.data.forEach(item=>{ obj.data.forEach(item=>{
let keys_=(item.standard_brand_name||item.brand_name) let keys_=(item.standard_brand_name||item.brand_name)
...@@ -329,19 +395,15 @@ ...@@ -329,19 +395,15 @@
obj_.data.forEach(it=>{ obj_.data.forEach(it=>{
it.isshow=true it.isshow=true
}) })
if(obj_.supplier_name=="国内现货"){ this.list.push(obj_)
this.list.unshift(obj_)
}else if(obj_.supplier_name=="猎芯期货"){
this.list.push(obj_)
}else{
this.list.splice(1, 0, obj_);
}
this.getBrandAndSupplier(obj_) this.getBrandAndSupplier(obj_)
} }
//数据加载完 //数据加载完
if(this.loadcount==Object.keys(this.SEARCH_SUPPLIER_SINGLE)){ if(this.loadcount==Object.keys(this.SEARCH_SUPPLIER_SINGLE).length){
if(this.list.length==0){ if(this.list.length==0){
this.isNOdata=1; this.isNOdata=1;
}else{
this.rankTotal()
} }
} }
}); });
...@@ -373,9 +435,12 @@ ...@@ -373,9 +435,12 @@
} }
//数据加载完 //数据加载完
if(this.loadcount==Object.keys(this.SEARCH_SUPPLIER_SINGLE)){ if(this.loadcount==Object.keys(this.SEARCH_SUPPLIER_SINGLE).length){
if(this.list.length==0){ if(this.list.length==0){
this.isNOdata=1; this.isNOdata=1;
}else{
this.rankTotal()
} }
} }
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment