diff --git a/student-vol/mock/userInfo.json b/student-vol/mock/userInfo.json index 54ffa18..c2bfb56 100644 --- a/student-vol/mock/userInfo.json +++ b/student-vol/mock/userInfo.json @@ -2,7 +2,7 @@ "error": 0, "data": { "avatar": "./imgs/avatar.png", - "name": "666", + "name": "dich", "code": 114514, "gender": 0, "phoneNum": "1919810", diff --git a/student-vol/src/views/LoveActs.vue b/student-vol/src/views/LoveActs.vue index 037336e..e075f28 100644 --- a/student-vol/src/views/LoveActs.vue +++ b/student-vol/src/views/LoveActs.vue @@ -12,13 +12,12 @@
{ + const title = (item.title || '').toLowerCase(); + // 注意:模拟数据中的字段是 'palce' 而不是 'place' + const place = (item.palce || '').toLowerCase(); + return title.includes(searchTerm) || place.includes(searchTerm); + }); + } + }, methods: { - fetchActList(currentPage = 1) { - const that = this; - const payload = { - currentPage, - pageSize: 10, - keyword: this.keyword, - }; - + // 获取完整的活动列表 + fetchActList() { this.loading = true; axios - .get("/api/actList", { params: payload }) - .then(function (response) { + .get("/api/actList") + .then(response => { const { error, data = {} } = response.data; if (error === 0) { - const currentPage = data.current; - const list = data.list; - - if (currentPage === 1) { - that.actList = list; - } else { - that.actList.push(...list); - } - - that.currentPage = currentPage; - that.finished = data.pageCount === currentPage; + this.allActList = data.list || []; } }) - .finally(function () { - that.loading = false; + .finally(() => { + this.loading = false; }); }, - onLoad() { - this.fetchActList(this.currentPage + 1); - }, goMyApply() { this.$router.push("/myApply"); }, @@ -89,14 +82,9 @@ export default { this.$router.push("/actDetails?id=" + id); }, }, - watch: { - keyword() { - this.currentPage = 1; - this.fetchActList(1); - }, - }, mounted() { - this.fetchActList(1); + // 组件加载时获取所有数据 + this.fetchActList(); }, }; @@ -137,4 +125,4 @@ export default { box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2); cursor: pointer; } - + \ No newline at end of file