From 96eaf15911aa45d07d6be0d57275d067d6abbda9 Mon Sep 17 00:00:00 2001 From: Enzo <1284707383@qq.com> Date: Wed, 22 Sep 2021 14:59:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E7=8E=B0=E6=88=91=E7=9A=84=E4=B8=AD?= =?UTF-8?q?=E5=BF=83=E4=BC=98=E5=8C=96/=E5=8F=91=E7=8E=B0=E8=AF=84?= =?UTF-8?q?=E8=AE=BA=E8=B7=B3=E8=BD=AC=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/coupon/index/index.vue | 2 +- pages/discover/discoverdetails.vue | 4 +- pages/index/collectCoupons/collectCoupons.vue | 2 +- pages/user/my/my.vue | 111 ++++++++++++++---- 4 files changed, 89 insertions(+), 30 deletions(-) diff --git a/pages/coupon/index/index.vue b/pages/coupon/index/index.vue index 3872da5..879d3d0 100644 --- a/pages/coupon/index/index.vue +++ b/pages/coupon/index/index.vue @@ -38,7 +38,7 @@ {{item.discount.title}} - 有效期{{item.discount.ends_at}} + 有效期{{item.discount.starts_at}}~{{item.discount.ends_at}} diff --git a/pages/discover/discoverdetails.vue b/pages/discover/discoverdetails.vue index 5882da9..e2111ea 100644 --- a/pages/discover/discoverdetails.vue +++ b/pages/discover/discoverdetails.vue @@ -45,7 +45,7 @@ - + @@ -66,7 +66,7 @@ - + diff --git a/pages/index/collectCoupons/collectCoupons.vue b/pages/index/collectCoupons/collectCoupons.vue index f611cda..7ce76a9 100644 --- a/pages/index/collectCoupons/collectCoupons.vue +++ b/pages/index/collectCoupons/collectCoupons.vue @@ -23,7 +23,7 @@ {{item.title}} - 有效期{{item.starts_at}}-{{item.ends_at}} + 有效期{{item.starts_at}}~{{item.ends_at}} diff --git a/pages/user/my/my.vue b/pages/user/my/my.vue index 04a7964..9fb0185 100644 --- a/pages/user/my/my.vue +++ b/pages/user/my/my.vue @@ -20,32 +20,41 @@ - - - {{item.create_time[0]}} - - - {{item.create_time[1]}} - - - - - - - - - {{item.likes_count}} + + + + {{item.create_time[0]}} + + + {{item.create_time[1]}} - - - {{item.view_count}} + + - - - {{item.comments_count}} + + + + + {{item.likes_count}} + + + + {{item.view_count}} + + + + {{item.comments_count}} + - + + + {{ loadingText }} + + + @@ -57,14 +66,32 @@ user_id: 0, page: 1, page_size: 15, - discover_info: '' + discover_info: '', + isPage: true, + loadingClass: true, + loadingText: '正在加载中', + isRefresher: false, + scrollH: 0, + nav_height: 0, } }, onLoad(e) { + let info = uni.getSystemInfoSync(); + this.scrollH = info.screenHeight; this.user_id = e.user_id; this.loginList(); }, + computed: { + autoHeight(){ + return `calc(${this.scrollH}px - ${this.nav_height}px - 460rpx)`; + } + }, methods: { + // scroll-view 下拉刷新 + onRefresherrefresh(){ + this.isRefresher = true; + this.refreshFn({type: 'scrollRefresh'}); + }, //关注 payAttention() { this.$http @@ -104,6 +131,22 @@ }); }); }, + // 下拉刷新处理 + refreshFn(options){ + this.page = 1; + this.isPage = true; + this.loadingClass = true; + this.discover_info.list.data = []; + this.loadingText = '正在加载中'; + this.loginList(options); + }, + // 页面触底,加载下一页 + onScrolltolower(){ + if(this.isPage){ + this.page = this.page + 1; + this.loginList(); + } + }, //点赞发现 addLike(id) { let user_info = this.$cookieStorage.get('user_token'); @@ -121,7 +164,7 @@ .then(res => { if (res.data.code == 200) { if (res.data.status) { - this.loginList(); + this.refreshFn({type: 'scrollRefresh'}); } else { wx.showModal({ content: res.data.message || '请下拉页面刷新重试', @@ -151,7 +194,7 @@ this.$url('/pages/discover/discoverdetails?discover_id='+id) }, //登录时的发现列表 - loginList() { + loginList(options = {}) { this.$http .get({ api: 'api/discover/user/'+this.user_id, @@ -166,7 +209,23 @@ .then(res => { if (res.data.code == 200) { if (res.data.status) { - this.discover_info = res.data.data; + this.discover_info = res.data.data; + let isPage = res.data.data.list.last_page == this.page?false:true; + this.isPage = isPage; + if(!isPage) { + this.loadingClass = false; + this.loadingText = '没有更多数据啦~'; + } + if(options.type == 'pageRefresh') { + uni.stopPullDownRefresh(); + }else if(options.type == 'scrollRefresh') { + this.isRefresher = false; + } + if(this.page == 1) { + this.discover_info.list.data = res.data.data.list.data; + }else { + this.discover_info.list.data.push(...res.data.data.list.data); + } console.log('登录时的发现列表',this.discover_info); } else { wx.showModal({