|
|
@@ -13,23 +13,32 @@ const useSearch = defineStore({
|
|
|
pagesize: 10,
|
|
|
q: '',
|
|
|
prefix: '',
|
|
|
- isLoading: true
|
|
|
+ total: 0,
|
|
|
+ isClean: true
|
|
|
}),
|
|
|
actions: {
|
|
|
setSearchText(data) {
|
|
|
this.searchText = data
|
|
|
// console.log('this.searchText', this.searchText);
|
|
|
},
|
|
|
+ setSearchPage(){
|
|
|
+ this.page += 1
|
|
|
+ this.setSearchLis()
|
|
|
+ },
|
|
|
+ setClean(data){
|
|
|
+ this.isClean = data
|
|
|
+ },
|
|
|
async setSearchLis(data) {
|
|
|
this.q = data
|
|
|
- // console.log('5555', this.searchText);
|
|
|
+ console.log('5555', this.page);
|
|
|
|
|
|
- if (this.searchText) {
|
|
|
+ if (this.searchText.length > 0) {
|
|
|
+ this.page = 1
|
|
|
await getGameList({ type: this.type, tag_id: this.tag_id, page: this.page, pagesize: this.pagesize, q: this.q }).then(res => {
|
|
|
if (res.data.code === 200 && res.data.data) {
|
|
|
// console.log('res', res);
|
|
|
- this.isLoading = false
|
|
|
this.prefix = res.data.data.prefix
|
|
|
+ this.total = res.data.data.total
|
|
|
this.searchLis = []
|
|
|
this.searchLis = this.searchLis.concat(res.data.data.lists.filter(item => item.screen_name.includes(this.q)))
|
|
|
console.log('this.searchLis', this.searchLis);
|
|
|
@@ -39,13 +48,15 @@ const useSearch = defineStore({
|
|
|
})
|
|
|
}
|
|
|
else {
|
|
|
- console.log(222);
|
|
|
+ // console.log(222);
|
|
|
await getGameList({ type: this.type, tag_id: this.tag_id, page: this.page, pagesize: this.pagesize, q: this.q }).then(res => {
|
|
|
if (res.data.code === 200 && res.data.data) {
|
|
|
- // console.log('res', res);
|
|
|
- this.isLoading = false
|
|
|
+ console.log('res', res);
|
|
|
this.prefix = res.data.data.prefix
|
|
|
- this.searchLis = [...this.searchLis, ...res.data.data.lists]
|
|
|
+ this.total = res.data.data.total
|
|
|
+ if(this.isClean) this.searchLis = []
|
|
|
+ this.searchLis = this.searchLis.concat(res.data.data.lists)
|
|
|
+ console.log('searchLis====>', this.searchLis);
|
|
|
}
|
|
|
}).catch(err => {
|
|
|
Message.error(err.data.msg)
|
|
|
@@ -60,11 +71,17 @@ const useSearch = defineStore({
|
|
|
getSearchLis(state) {
|
|
|
return state.searchLis
|
|
|
},
|
|
|
- getLoading(state) {
|
|
|
- return state.isLoading
|
|
|
- },
|
|
|
getPrefix(state) {
|
|
|
return state.prefix
|
|
|
+ },
|
|
|
+ getPage(state){
|
|
|
+ return state.page
|
|
|
+ },
|
|
|
+ getPagesize(state){
|
|
|
+ return state.pagesize
|
|
|
+ },
|
|
|
+ getTotal(state){
|
|
|
+ return state.total
|
|
|
}
|
|
|
}
|
|
|
})
|