搜索页

This commit is contained in:
”chenxuelian“
2022-12-25 14:50:29 +08:00
parent 801e0e9995
commit 09855d7da1
3 changed files with 31 additions and 27 deletions

View File

@@ -32,7 +32,7 @@
</view>
<view class="found-record">
<view v-for="(item, index) in foundList" :key="index" class="tag-item">
<u-tag bg-color="#eee" borderColor="#eee" color="#666" :text="item" @click="recentSearch(item)" />
<u-tag bg-color="#eee" borderColor="#eee" color="#666" :text="item.name" @click="recentSearch(item.name)" />
</view>
</view>
</view>
@@ -49,26 +49,15 @@
searchBarTop: 0, //搜索栏的外边框高度单位px
searchBarHeight: 0, //搜索栏的高度单位px
queryParam: '',
recentRecordList: [
'烘焙宝典1',
'烘焙宝典2',
'烘焙宝典3',
'烘焙宝典4',
'无添加剂5',
'烘焙宝典&无添加剂',
'无添加剂6'
],
foundList: [
'烘焙宝典1',
'烘焙宝典2',
'烘焙宝典3',
'烘焙宝典4',
'烘焙宝典&无添加剂',
'无添加剂5'
]
recentRecordList: [],
foundList: []
}
},
onLoad() {
this.getDiscover()
const tempList = uni.getStorageSync('storage_search_record')
this.recentRecordList = tempList ? tempList : [];
console.log(this.recentRecordList)
const menuButtonInfo = uni.getMenuButtonBoundingClientRect();
this.searchBarTop = menuButtonInfo.top;
this.searchBarHeight = menuButtonInfo.height;
@@ -87,6 +76,11 @@
this.recentRecordList.splice(index, 1)
}
this.recentRecordList.unshift(param)
try {
uni.setStorageSync('storage_search_record', this.recentRecordList);
} catch (e) {
// error
}
},
goBack() {
uni.navigateBack()
@@ -97,6 +91,17 @@
},
clearRecentSearch() {
this.recentRecordList = []
try {
uni.setStorageSync('storage_search_record', this.recentRecordList);
} catch (e) {
// error
}
},
getDiscover() {
this.$apiServe.getDiscover().then(res => {
this.foundList = res.data.data
console.log(res.data.data)
}).finally(_ => {})
}
}
}