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;
......
......@@ -2,13 +2,13 @@
<view>
<uni-popup ref="popup" type="bottom">
<view class="addcar " >
<view class="addcar-pop ">
<view class="addcar-pop " :class="{'actpop':obj.ac_type==10}">
<view class="addcarpopbox" >
<view class="cons" >
<view class="pophead row bothSide">
<view class="tits row">
<text class="goodsName elep">lm358asdasdasdasdasdads</text>
<text class="actag">91折</text>
<text class="goodsName elep">{{obj.goods_name}}</text>
<text class="actag" v-if="obj.ac_type==10">{{obj.activity_info.sign}}</text>
</view>
<text class="icon iconfont icon-xxx" @click="close()"></text>
</view>
......@@ -17,49 +17,49 @@
<view class="itemone row bothSide">
<view class="il elep">
<text class="label">品牌:</text>
<text>Rice Lake Weighing</text>
<text>{{obj.brand_name}}</text>
</view>
<view class="ir">
<text class="label">ECCN:</text>
<text>ERA3006</text>
<text>{{obj.eccn||'--'}}</text>
</view>
</view>
<view class="itemone row bothSide">
<view class="il elep">
<text class="label">供应商:</text>
<text>Mouser</text>
<text>{{obj.supplier_name||'--'}}</text>
</view>
<view class="ir">
<text class="label">递增量:</text>
<text>66666</text>
<text>{{obj.multiple||obj.mpl}}</text>
</view>
</view>
<view class="itemone row bothSide">
<view class="il elep">
<text class="label">封装:</text>
<text>asdad</text>
<text>{{obj.encap||'--'}}</text>
</view>
<view class="ir">
<text class="label">起订量:</text>
<text>500</text>
<text>{{obj.min_buy}}</text>
</view>
</view>
<view class="itemone row bothSide">
<view class="il elep">
<text class="label">包装:</text>
<text>Cut Tape</text>
<text>{{obj.packing_name||'--'}}</text>
</view>
<view class="ir">
<text class="label">库存:</text>
<text class="kcty">654564654</text>
<text class="kcty">{{obj.goods_number}}</text>
</view>
</view>
<view class="itemone row bothSide">
<view class="il elep">
<text class="label">类别:</text>
<text>Cut Tape</text>
<text>{{obj.class1_name||obj.class2_name||'--'}}</text>
</view>
</view>
</view>
......@@ -67,19 +67,19 @@
<view class="pricet row">
<view class="pl row">
<text class="label">交期:</text>
<view class="row hqitem">
<text class="checkbox checked"><text class="icon iconfont icon-xzs"></text></text>
<text>大陆3-5日</text>
<view class="row hqitem" @click="tabhuoqi(1)" v-if="obj.delivery_cn">
<text class="checkbox " :class="{'checked':isdl==1}"><text class="icon iconfont icon-xzs"></text></text>
<text>大陆{{obj.delivery_time['1']}}</text>
</view>
<view class="row hqitem">
<text class="checkbox"></text>
<text>香港3-5日</text>
<view class="row hqitem" @click="tabhuoqi(2)" v-if="obj.delivery_hk">
<text class="checkbox" :class="{'checked':isdl==2}"><text class="icon iconfont icon-xzs"></text></text>
<text>香港{{obj.delivery_time['2']}}</text>
</view>
</view>
<view class="pr row " >
<text>-</text>
<input type="number" />
<text>+</text>
<text @click="stepgo('small')">-</text>
<input type="number" v-model="num" @input="onInput"/>
<text @click="stepgo('big')">+</text>
</view>
</view>
<view class="priceb">
......@@ -88,33 +88,25 @@
<view class="pi2">大陆交货(含税)</view>
<view class="pi3">香港交货</view>
</view>
<view class="pitem row " >
<view class="pi1">50000+:</view>
<view class="pi2 row"><text class="w140">¥130.856</text><text class="hxj">¥130.856</text></view>
<view class="pi3 row"> <text class="w120">$130.856</text><text class="hxj">$130.856</text></view>
</view>
<view class="pitem row " >
<view class="pi1">50000+:</view>
<view class="pi2 row"><text class="w140">¥130.856</text><text class="hxj">¥130.856</text></view>
<view class="pi3 row"> <text class="w120">$130.856</text><text class="hxj">$130.856</text></view>
</view>
<view class="pitem row act" >
<view class="pi1">50000+:</view>
<view class="pi2 row"><text class="w140">¥130.856</text><text class="hxj">¥130.856</text></view>
<view class="pi3 row"> <text class="w120">$130.856</text><text class="hxj">$130.856</text></view>
<view v-if="pticearr.length>0">
<view class="pitem row " :class="{'act':item.checked}" v-for="(item,index) in pticearr" :key="index">
<view class="pi1">{{item.purchases}}+:</view>
<view class="pi2 row"><text class="w140">{{item.price_ac||item.price_cn||'--'}}</text></view>
<view class="pi3 row"> <text class="w120">${{item.price_ac_us||item.price_us||'--'}}</text></view>
</view>
</view>
<view class="noprice" style="display:none;">
<view class="noprice" v-if="pticearr.length==0">
<text class="icon iconfont icon-sanjiaoji"></text>
暂无阶梯价格
</view>
</view>
</view>
<view class="btnbox">
<view class="totalpricebox row bothSide" >
<view class="hej">合计:<text class="tje">¥3235.6856</text></view>
<view class="totalpricebox row bothSide" v-if="obj.is_buy==1">
<view class="hej">合计:<text class="tje">{{isdl==1?'¥':'$'}}{{totalmoney}}</text></view>
<view class="addcarbtn">加入购物车</view>
</view>
<a class="kfbtn row verCenter rowCenter" href="#" target="_blank" style="display:none">
<a class="kfbtn row verCenter rowCenter" v-else href="#" target="_blank" style="display:none">
<text class="icon iconfont icon-qq"></text>
联系客服
</a>
......@@ -142,13 +134,75 @@
},
data() {
return {
timeout:"",//请求延迟定时器
obj:{},
num:1,
isdl:1,
pticearr:[],
totalmoney:0.00,
}
},
onLoad: function() {
},
methods: {
onInput(e){
clearTimeout(this.timeout);
this.timeout = setTimeout(() => {
let mpl = Number(this.obj.multiple||this.obj.mpl);//倍数 加减的数量基数
let stock = Number(this.obj.goods_number);//库存
let moq = Number(this.obj.min_buy);//起订量
let value_ = Number(e.detail.value);//当前的数量
console.log(value_)
value_ = Math.ceil(value_ / mpl) * mpl;//失去焦点数量
this.num = value_;//最终的数量
if (value_ < moq) {
this.num = moq
}
if (value_ > stock) {
this.num = Math.floor(stock / mpl) * mpl;
}
this.pticeui()
}, 800);
},
stepgo(type){
let mpl = Number(this.obj.multiple||this.obj.mpl);//倍数 加减的数量基数
let stock = Number(this.obj.goods_number);//库存
let moq = Number(this.obj.min_buy);//起订量
let value_ = this.num;//当前的数量
if(type=="small"){
//减法
var down_value = value_ - mpl;//减过后的值
if (down_value < moq) {
this.num = moq;
uni.showToast({
title: '数量不能小于起订量',
duration: 2000,
icon:"none"
})
} else {
this.num = down_value
}
}else{
//加法
var up_value = value_ + mpl;//加过后的值
if (up_value > stock) {
uni.showToast({
title: '数量不能大于库存',
duration: 2000,
icon:"none"
})
this.num = Math.floor(stock / mpl) * mpl;
} else {
this.num = up_value
}
}
this.pticeui()
},
tabhuoqi(guid){
this.isdl=guid;
this.pticeui()
},
open() {
this.$refs.popup.open('bottom');
},
......@@ -160,10 +214,73 @@
this.getData(goods_id)
}
},
//计算阶梯价格 总价
pticeui(){
if(this.pticearr.length==0){return}
//渲染阶梯价格
this.pticearr.forEach((item,index)=>{
item.checked=false
})
this.pticearr.forEach((item,index)=>{
let value_=this.num
let pus=item.purchases
var next_pus=""
var prev_pus=""
if(index!=this.pticearr.length-1){
next_pus=this.pticearr[index+1].purchases
}
if(index!=0){
prev_pus=this.pticearr[index-1].purchases
}
if (value_ == pus) {
item.checked=true
return false;
}
if(index==0){
if(value_>pus){
item.checked=true
return false;
}
}
if(index==this.pticearr.length-1){
if(value_<pus){
item.checked=true
return false;
}
}
if (value_ < pus && value_ > next_pus) {
this.pticearr[index+1].checked=true
return false;
}
if (value_ > pus && value_ < prev_pus) {
item.checked=true
return false;
}
})
//计算价格
let actitem={};
this.pticearr.forEach((item,index)=>{
if(item.checked){
actitem=item
}
})
let price_=Number(this.isdl==1?(actitem.price_ac||actitem.price_cn||0):(actitem.price_ac_us||actitem.price_us||0));
this.totalmoney=(price_*this.num).toFixed(2)
},
getData:function(goods_id){
this.request(Api_Url + "/goods/detail", 'POST', {id:goods_id},true,true).then(res => {
//110225
this.request(Api_Url + "/goods/detail", 'POST', {id:"1168482547080619839"},true,true).then(res => {
if (res.err_code == 0) {
this.obj=res.data;
this.num=this.obj.min_buy
this.pticearr=res.data.tiered||[]
if((!this.obj.delivery_cn)&&this.delivery_hk){
this.isdl=2
}
this.open()
this.pticeui()
}else{
}
......
......@@ -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