From feab27b94e1c76d6826267454a0f5c06eb198f81 Mon Sep 17 00:00:00 2001 From: fanfan Date: Wed, 3 Jul 2024 18:41:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages.json | 2 +- pages/merchantTutorial/tutorial.vue | 59 ++++++++++++++++++++++------- 2 files changed, 47 insertions(+), 14 deletions(-) diff --git a/pages.json b/pages.json index 41c42c7..9ba7c6b 100644 --- a/pages.json +++ b/pages.json @@ -1186,7 +1186,7 @@ "path": "tutorial", "style": { "navigationStyle": "custom", - "enablePullDownRefresh": false, + "enablePullDownRefresh": true, "navigationBarTitleText": "商家教程" } } diff --git a/pages/merchantTutorial/tutorial.vue b/pages/merchantTutorial/tutorial.vue index 8653f13..6b67116 100644 --- a/pages/merchantTutorial/tutorial.vue +++ b/pages/merchantTutorial/tutorial.vue @@ -19,9 +19,8 @@ active-color="rgba(243, 74, 64, 1)" inactive-color="rgba(102, 102, 102, 1)" font-size="32" bar-width="55" bar-height="6" :current="current" @change="change"> - - + + @@ -35,8 +34,9 @@ 观看 - + + @@ -57,7 +57,17 @@ current: 0, courseList: [], show: false, - video_url: '' + video_url: '', + page: 1, + pageSize: 6, + iconType: 'flower', + status: 'loadmore', + total: 0, + loadText: { + loadmore: '上拉加载更多', + loading: '正在加载', + nomore: '没有更多了 ' + } } }, onLoad() { @@ -65,6 +75,19 @@ }, onShow() { + }, + // 下拉刷新 + onPullDownRefresh() { + this.courseList = []; + this.page = 1; + this.getCourseList(); + uni.stopPullDownRefresh(); //停止刷新 + }, + onReachBottom() { + if (this.page * this.pageSize >= this.total) return + this.page++; + this.status = 'loading' + this.getCourseList(); }, methods: { pauseVideo() { @@ -74,6 +97,8 @@ this.show = false }, change(index) { + this.courseList = []; + this.page = 1; this.current = index; this.getCourseList() }, @@ -105,9 +130,10 @@ // 列表 async getCourseList() { let that = this; - that.courseList = [] let pames = { - courseCategoryId: that.courseTypeList[that.current].course_category_id + courseCategoryId: that.courseTypeList[that.current].course_category_id, + page: that.page, + pageSize: that.pageSize } let { status, @@ -115,9 +141,16 @@ data } = await api.courseList(pames); if (status == 200) { - that.courseList = data.list + const newData = data.list.data || []; + that.courseList = [...that.courseList, ...newData]; // 将新数据添加到已有数据的尾部 + that.total = data.list.total; + if (that.courseList.length >= that.total) { + that.status = 'nomore' + } else { + that.status = 'loadmore' + } } else { - that.list = [] + that.total = 0 that.$toast(message) } }, @@ -133,7 +166,7 @@ ::v-deep .u-empty { padding: 100rpx 0; } - + .warp { display: flex; align-items: center; @@ -152,7 +185,7 @@ .park-top { width: 100%; - height: 420rpx; + height: 450rpx; background: url(https://www.royaum.com.cn/static/user/courseBg.png); background-size: 100%; @@ -163,8 +196,7 @@ color: rgba(51, 51, 51, 1); text-align: left; vertical-align: top; - padding-top: 30rpx; - padding-left: 48rpx; + padding: 30rpx 0rpx 20rpx 48rpx; } .top-marker { @@ -184,6 +216,7 @@ background: #fff; width: 100%; overflow: hidden; + padding-bottom: 50rpx; .center-box { overflow: hidden;