Commit 0e306cd7 by 肖康

首页搜索修改

parent 469ae2e2
......@@ -133,15 +133,9 @@
line-height: 41rpx;
font-size: 24rpx;
color:$uni-color999;
.pi1{width:139rpx;}
.pi2{width:318rpx;}
.w140{width:140rpx;}
.w120{width:120rpx;}
.hxj{
color:#C2C4CC!important;
font-weight: normal!important;
text-decoration-line: line-through;
}
.pi1{flex: 2;}
.pi2{flex: 3;}
.pi3{flex: 3;}
&.titso{
color:$uni-color666;
font-weight: 600;
......
......@@ -165,7 +165,12 @@ export default {
intervalHandler: null
};
},
mounted() {
setTimeout(() => {
this.pbobj = this.$globalData;
this.kfurl = this.$globalData.kfqq_xk;
}, 500);
},
onShow() {
this.getData();
},
......@@ -209,12 +214,7 @@ export default {
}, 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 => {
if (res.err_code === 0) {
this.newscount = res.data;
......
......@@ -65,11 +65,14 @@
console.log(option);
this.searchVal=option.k||""
},
mounted() {
setTimeout(() => {
this.obj = this.$globalData;
}, 500);
},
onShow:function(){
//获取历史记录
console.log(this.searchVal)
this.getsearchHistory()
this.getData()
},
methods: {
getListPOI(val_){
......@@ -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(){
let listhis_=uni.getStorageSync('historyItems');
if(listhis_){
......
......@@ -140,7 +140,13 @@
onLoad: function(option) {
this.searchVal = option.k;
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: {
//创建历史搜索缓存 最大10个
......@@ -161,22 +167,76 @@
uni.setStorageSync('historyItems', historyItems);
}
},
getData() {
this.request(Ichunt_Api + "/api/common/data", 'GET', {}, ).then(res => {
if (res.err_code === 0) {
this.SEARCH_SUPPLIER_SINGLE=res.data.SEARCH_SUPPLIER_SINGLE;
this.kfqqurl=res.data.kfqq_xk.data
this.getSupplierData()
}
//综合排序
rankTotal(){
//按供应商排序
this.list.sort((a, b) => {
if (a.supplier_name == '国内现货') {
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){
this.tabType=type;
if(type==2){
this.stocksort=!this.stocksort
}
if(type==3){
if(type==1){
this.rankTotal()
}else if(type==2){
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
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 @@
name:key,
checked:false
}
if(key=="国内现货"){
this.supplierArr.unshift(is_)
}else if(key=="猎芯期货"){
this.supplierArr.push(is_)
}else{
this.supplierArr.splice(1, 0, is_);
}
this.supplierArr.push(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=>{
let keys_=(item.standard_brand_name||item.brand_name)
......@@ -329,19 +395,15 @@
obj_.data.forEach(it=>{
it.isshow=true
})
if(obj_.supplier_name=="国内现货"){
this.list.unshift(obj_)
}else if(obj_.supplier_name=="猎芯期货"){
this.list.push(obj_)
}else{
this.list.splice(1, 0, obj_);
}
this.list.push(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){
this.isNOdata=1;
}else{
this.rankTotal()
}
}
});
......@@ -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){
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