增加搜索功能

This commit is contained in:
2024-10-11 17:47:24 +08:00
parent 9eb875ea08
commit 0cfc3aebc7
2 changed files with 20 additions and 10 deletions

View File

@@ -97,9 +97,9 @@
<view class="u-font-28 color-666 ">搜索</view>
<view class="u-flex u-m-t-20 u-flex-wrap u-row-between">
<view class="u-m-b-30" v-for="(goodsItem, goodsIndex) in searchResult" :key="goodsIndex">
<goods-item :img="{width:'330rpx',height:'370rpx'}" @chooseGuige="chooseGuige($event,index)"
@add="goodsUpdate($event,index,true)" @reduce="goodsUpdate($event,index,false)"
:index="goodsIndex" :data="goodsItem"></goods-item>
<goods-item :img="{width:'330rpx',height:'330rpx'}" @chooseGuige="chooseGuige($event,goodsItem.index)"
@add="goodsUpdate($event,goodsItem.index,true)" @reduce="goodsUpdate($event,index,false)"
:index="goodsItem.goodsIndex" :data="goodsItem"></goods-item>
</view>
</view>
@@ -462,10 +462,21 @@
function returnSearchGoods() {
const newval = searchValue.value
let arr = []
let goods=[]
for(let i in data.tabbar){
const goodsArr=data.tabbar[i].foods||[]
for(let k in goodsArr){
goods.push({
...goodsArr[k],
index:i,
goodsIndex:k
})
}
}
if (newval == "") {
arr = $originGoods;
arr = goods;
} else {
arr = $originGoods.filter((v) =>
arr = goods.filter((v) =>
v.name.includes(newval.trim())
);
}
@@ -984,7 +995,6 @@
// watchChooseuser()
watchChooseTable()
watchUpdate()
init()
})
let isCreateOrderToDetail = ref(false)
onLoad((opt) => {
@@ -1002,7 +1012,7 @@
// go.back()
// }, 1500)
// }
// init()
init()
})
</script>