mirror of
https://github.com/Dichgrem/Vue.git
synced 2026-02-05 04:41:55 -05:00
fix:loveacts_select
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
"error": 0,
|
"error": 0,
|
||||||
"data": {
|
"data": {
|
||||||
"avatar": "./imgs/avatar.png",
|
"avatar": "./imgs/avatar.png",
|
||||||
"name": "666",
|
"name": "dich",
|
||||||
"code": 114514,
|
"code": 114514,
|
||||||
"gender": 0,
|
"gender": 0,
|
||||||
"phoneNum": "1919810",
|
"phoneNum": "1919810",
|
||||||
|
|||||||
@@ -12,13 +12,12 @@
|
|||||||
|
|
||||||
<div class="body">
|
<div class="body">
|
||||||
<van-list
|
<van-list
|
||||||
v-model:loading="loading"
|
:loading="loading"
|
||||||
:finished="finished"
|
:finished="true"
|
||||||
finished-text="没有更多了"
|
finished-text="没有更多了"
|
||||||
@load="onLoad"
|
|
||||||
>
|
>
|
||||||
<ActItem
|
<ActItem
|
||||||
v-for="item in actList"
|
v-for="item in filteredActList"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
:data="item"
|
:data="item"
|
||||||
@goDetails="goDetails"
|
@goDetails="goDetails"
|
||||||
@@ -40,48 +39,42 @@ export default {
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
actList: [],
|
allActList: [], // 用于存储所有活动数据
|
||||||
loading: false,
|
loading: false,
|
||||||
finished: false,
|
|
||||||
currentPage: 1,
|
|
||||||
keyword: "",
|
keyword: "",
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
// 创建一个计算属性来根据关键字筛选活动列表
|
||||||
|
filteredActList() {
|
||||||
|
if (!this.keyword.trim()) {
|
||||||
|
return this.allActList; // 如果关键字为空,返回所有活动
|
||||||
|
}
|
||||||
|
const searchTerm = this.keyword.trim().toLowerCase();
|
||||||
|
return this.allActList.filter(item => {
|
||||||
|
const title = (item.title || '').toLowerCase();
|
||||||
|
// 注意:模拟数据中的字段是 'palce' 而不是 'place'
|
||||||
|
const place = (item.palce || '').toLowerCase();
|
||||||
|
return title.includes(searchTerm) || place.includes(searchTerm);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
fetchActList(currentPage = 1) {
|
// 获取完整的活动列表
|
||||||
const that = this;
|
fetchActList() {
|
||||||
const payload = {
|
|
||||||
currentPage,
|
|
||||||
pageSize: 10,
|
|
||||||
keyword: this.keyword,
|
|
||||||
};
|
|
||||||
|
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
axios
|
axios
|
||||||
.get("/api/actList", { params: payload })
|
.get("/api/actList")
|
||||||
.then(function (response) {
|
.then(response => {
|
||||||
const { error, data = {} } = response.data;
|
const { error, data = {} } = response.data;
|
||||||
if (error === 0) {
|
if (error === 0) {
|
||||||
const currentPage = data.current;
|
this.allActList = data.list || [];
|
||||||
const list = data.list;
|
|
||||||
|
|
||||||
if (currentPage === 1) {
|
|
||||||
that.actList = list;
|
|
||||||
} else {
|
|
||||||
that.actList.push(...list);
|
|
||||||
}
|
|
||||||
|
|
||||||
that.currentPage = currentPage;
|
|
||||||
that.finished = data.pageCount === currentPage;
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.finally(function () {
|
.finally(() => {
|
||||||
that.loading = false;
|
this.loading = false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
onLoad() {
|
|
||||||
this.fetchActList(this.currentPage + 1);
|
|
||||||
},
|
|
||||||
goMyApply() {
|
goMyApply() {
|
||||||
this.$router.push("/myApply");
|
this.$router.push("/myApply");
|
||||||
},
|
},
|
||||||
@@ -89,14 +82,9 @@ export default {
|
|||||||
this.$router.push("/actDetails?id=" + id);
|
this.$router.push("/actDetails?id=" + id);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
|
||||||
keyword() {
|
|
||||||
this.currentPage = 1;
|
|
||||||
this.fetchActList(1);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
mounted() {
|
mounted() {
|
||||||
this.fetchActList(1);
|
// 组件加载时获取所有数据
|
||||||
|
this.fetchActList();
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user