From 42bb7f3871b27f32737d5bca1ef915e25edf3b6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=93=E5=B9=B3=E8=89=BA?= <52643018@qq.com> Date: Fri, 27 Aug 2021 10:13:52 +0800 Subject: [PATCH] =?UTF-8?q?[=E4=BC=98=E5=8C=96]=20=E6=8E=A8=E8=8D=90?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/api.js | 2 +- components/lf-waterfall/lf-waterfall.vue | 19 ++++++---- pages/goodsDetail/index.vue | 2 +- pages/recommList/index.vue | 47 ++++++++++++------------ 4 files changed, 38 insertions(+), 32 deletions(-) diff --git a/common/api.js b/common/api.js index 54fd627..f28f032 100644 --- a/common/api.js +++ b/common/api.js @@ -1,7 +1,7 @@ // appId: 正式 null | 测试 wxb35ef055a4dd8ad4 export const DEV = "dev"; // dev 测试 | prod 正式 export const VERSION = '1.0.0'; // 版本号 -export const DEVURL = 'http://hainan.lanzulive.com'; // 测试服请求地址 +export const DEVURL = 'https://hainan.lanzulive.com'; // 测试服请求地址 // export const DEVURL = 'http://hainan.com'; // 测试服请求地址 export const PRODURL = ''; // 正式服请求地址 diff --git a/components/lf-waterfall/lf-waterfall.vue b/components/lf-waterfall/lf-waterfall.vue index 97ebc24..45e0f97 100644 --- a/components/lf-waterfall/lf-waterfall.vue +++ b/components/lf-waterfall/lf-waterfall.vue @@ -69,16 +69,21 @@ }, data(){ return { - + dataList: [] } }, - computed: { - dataList: { - get() { return this.list; }, - set(newValue) { console.log('newvalue',newValue) } - }, + watch: { + list(val){ + this.dataList = val; + } }, - onShow(){ + // computed: { + // dataList: { + // get() { return this.list; }, + // set(newValue) { console.log('newvalue',newValue) } + // }, + // }, + created(){ }, destroyed() { diff --git a/pages/goodsDetail/index.vue b/pages/goodsDetail/index.vue index 1dd6ad6..51cd1c3 100644 --- a/pages/goodsDetail/index.vue +++ b/pages/goodsDetail/index.vue @@ -207,7 +207,7 @@ let title = goods.name; let imageUrl = goods.share_cover || goods.cover; let path = '/pages/route/index?route=goods_detail&id='+ goods.id; - + console.log("path", path); return { title, path, diff --git a/pages/recommList/index.vue b/pages/recommList/index.vue index 6b78d09..fdaddae 100644 --- a/pages/recommList/index.vue +++ b/pages/recommList/index.vue @@ -12,7 +12,7 @@ {{tabItem.loadingText}} - @@ -29,7 +29,8 @@ return { tab_list: [], current: 0, - windowHeight: 0 + windowHeight: 0, + show_count: 0 } }, components: { @@ -37,10 +38,13 @@ }, onShow(){ this.windowHeight = getApp().globalData.windowHeight; - this.getCategory() - }, - onHide() { - this.$refs.uWaterfall[this.current].clear(); + if(this.show_count >= 1){ + this.clearTabItem(); + this.getData(); + }else{ + this.getCategory(); + } + this.show_count++; }, methods: { getCategory(options = {}) { @@ -58,11 +62,6 @@ isPage: true } }); - if(options.type == 'pageRefresh'){ - uni.stopPullDownRefresh(); - }else if(options.type == 'scrollRefresh'){ - this.tab_list[this.current].isRefresher = false; - } this.tab_list = tab_list; this.getData() }).catch(err => { @@ -79,6 +78,7 @@ tab_item.loadingClass = false; tab_item.loadingText = '没有更多数据啦~'; } + tab_item.isRefresher = false; if(tab_item.page == 1){ tab_item.list = res.data.data; }else{ @@ -89,10 +89,6 @@ }) }, tabChange(index){ - this.$refs.uWaterfall[index].clear(); - this.tab_list[index].list = []; - // this.getCategory({type: 'pageRefresh'}); - console.log(this.$refs) this.current = index; if(this.tab_list[index].list.length <= 0){ this.getData(); // tab下没有数据,请求第一页 @@ -117,16 +113,21 @@ // scroll-view 下拉刷新 onRefresherrefresh(){ this.$u.throttle(() => { - this.$refs.uWaterfall[this.current].clear(); - this.tab_list[this.current].isRefresher = true; - this.getCategory({type: 'scrollRefresh'}); + this.clearTabItem(); + this.getData(); }, 200); }, - // page 下拉刷新 - onPullDownRefresh(){ - // 新版逻辑,刷新则整个数据全部重新获取 - this.getCategory({type: 'pageRefresh'}); - }, + clearTabItem(){ + let tab_item = this.tab_list[this.current]; + tab_item.page = 1; + tab_item.isPage = true; + tab_item.isRefresher = true; + tab_item.loadingClass = true; + tab_item.loadingText = '正在加载中'; + tab_item.list = []; + this.$set(this.tab_list, this.current, tab_item); + this.$refs.uWaterfall[this.current].clear(); + } } }