From 1e1ef2eed996c0dc3432d64a328ff4c7b0dcd4e1 Mon Sep 17 00:00:00 2001 From: aixianling Date: Thu, 5 Jan 2023 08:42:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E9=A1=B5=E5=8A=A0=E6=94=B9=E6=A0=87?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/project/fengdu/AppVote/AppVote.vue | 39 +++++++++++++++++--------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/src/project/fengdu/AppVote/AppVote.vue b/src/project/fengdu/AppVote/AppVote.vue index 888e6f9e..5851a30d 100644 --- a/src/project/fengdu/AppVote/AppVote.vue +++ b/src/project/fengdu/AppVote/AppVote.vue @@ -28,37 +28,44 @@ import WeixinLogin from "./component/weixinLogin"; export default { name: "AppVote", components: {WeixinLogin}, - appName: "公众投票", + appName: "微视频", data() { return { detail: {}, list: [], - wxLogin: 0 + wxLogin: 0, + current: 1, + total: 0 } }, computed: { ...mapState(['user']), }, methods: { - getDetail() { + getDetail(retry = false) { this.$http.post("/app/appvideovoteconfig/queryDetailByCorpId", null, { - withoutToken: true + withoutToken: !this.user.token || retry }).then(res => { if (res?.data) { this.detail = res.data } - }) - }, - getList(retry = false) { - this.$http.post("/app/appvideoinfo/list", null, { - withoutToken: !this.user.token || retry, - params: {size: 20} - }).then(res => { - if (res?.data) { - this.list = res.data.records - } }).catch(() => !retry && this.getList(true)) }, + getList() { + const {current, total, list} = this + if (current == 1 || list.length < total) { + current == 1 && (this.list = []) + this.$http.post("/app/appvideoinfo/list", null, { + withoutToken: true, + params: {current} + }).then(res => { + if (res?.data) { + this.list = [this.list, res.data.records].flat().filter(Boolean) + this.total = res.data.total + } + }) + } + }, handleDetail(id) { if (!this.user.token) this.wxLogin++ else uni.navigateTo({url: './voteDetail?id=' + id}) @@ -68,6 +75,10 @@ export default { this.getDetail() this.getList() }, + onReachBottom() { + this.current++ + this.getList() + } }