Commit cf6d3f04 authored by tangfh's avatar tangfh

+

parent 40ca9b14
...@@ -58,15 +58,18 @@ ...@@ -58,15 +58,18 @@
}, },
methods: { methods: {
init(option) { init(option) {
this.onRefresh() let _this = this;
setTimeout(() => {
_this.refresherTriggered = true;
}, 35)
}, },
onNavBarLeftClick() { onNavBarLeftClick() {
uni.navigateBack(); uni.navigateBack();
}, },
refreshInit() { refreshInit() {
this.page = 1; this.page = 1;
this.total_pagetotal_page = 1; this.total_page = 1;
this.status = 'noMore'; this.loadMoreStatus = constant.LOAD_STATUS.noMore;
}, },
onEmptyClick() { onEmptyClick() {
this.onRefresh(); this.onRefresh();
...@@ -77,10 +80,10 @@ ...@@ -77,10 +80,10 @@
this.request(); this.request();
}, },
onLoadMore(e) { onLoadMore(e) {
if ('noMore' == this.status) { if (constant.LOAD_STATUS.noMore == this.loadMoreStatus) {
return; return;
} }
this.status = 'loading'; this.loadMoreStatus = constant.LOAD_STATUS.loading;
this.request(); this.request();
}, },
onBottomBtnClick() { onBottomBtnClick() {
...@@ -125,8 +128,8 @@ ...@@ -125,8 +128,8 @@
} }
if (this.refresherTriggered || this.isOnFilter || this.items.length == 0) { if (this.refresherTriggered || this.isOnFilter || this.items.length == 0) {
this.items = list; this.items = list;
this.status = this.total_page == 1 ? constant.LOAD_STATUS.noMore : constant.LOAD_STATUS.more; this.loadMoreStatus = this.total_page == 1 ? constant.LOAD_STATUS.noMore : constant.LOAD_STATUS.more;
} else if (this.status == 'loading') { } else if (this.loadMoreStatus == 'loading') {
if (list.length > 0) { if (list.length > 0) {
this.items = this.items.concat(list); this.items = this.items.concat(list);
} }
...@@ -140,14 +143,14 @@ ...@@ -140,14 +143,14 @@
if (this.refresherTriggered) { if (this.refresherTriggered) {
this.refresherTriggered = false; this.refresherTriggered = false;
if (this.total_page > 1) { if (this.total_page > 1) {
this.status = constant.LOAD_STATUS.more; this.loadMoreStatus = constant.LOAD_STATUS.more;
} }
} else if (this.status == constant.LOAD_STATUS.loading) { } else if (this.loadMoreStatus == constant.LOAD_STATUS.loading) {
if (this.page > this.total_page) { if (this.page > this.total_page) {
this.status = constant.LOAD_STATUS.noMore; this.loadMoreStatus = constant.LOAD_STATUS.noMore;
this.page = this.total_page this.page = this.total_page
} else { } else {
this.status = constant.LOAD_STATUS.more; this.loadMoreStatus = constant.LOAD_STATUS.more;
} }
} }
this.firstRequest = false this.firstRequest = false
......
...@@ -16,7 +16,8 @@ ...@@ -16,7 +16,8 @@
<view class="view-tmp1 active" v-for="(item2, index2) in tab.data" :index="index2" :key="index2" <view class="view-tmp1 active" v-for="(item2, index2) in tab.data" :index="index2" :key="index2"
:item="item2" @onItemClick="onItemClick"></view> :item="item2" @onItemClick="onItemClick"></view>
</view> </view>
<c-empty v-if="tab.data.length == 0" @onEmptyClick="onEmptyClick"></c-empty> <c-status-view v-if="tab.data.length == 0 && !tab.firstRequest" :status="tab.contentStatus"
@onStatusClick="onStatusClick"></c-status-view>
<uni-load-more :status="tab.loadStatus" :icon-size="16" v-if="tab.isLoading || tab.data.length > 0" <uni-load-more :status="tab.loadStatus" :icon-size="16" v-if="tab.isLoading || tab.data.length > 0"
:content-text="loadMoreViewContentText" /> :content-text="loadMoreViewContentText" />
</scroll-view> </scroll-view>
...@@ -86,7 +87,6 @@ ...@@ -86,7 +87,6 @@
date: "2023-05-06-08 13:16", date: "2023-05-06-08 13:16",
item: "公共照明", item: "公共照明",
}, },
firstRequest: true,
} }
}, },
onLoad(option) { onLoad(option) {
...@@ -146,24 +146,24 @@ ...@@ -146,24 +146,24 @@
} }
_this.tabList.push(tab); _this.tabList.push(tab);
}); });
_this.onRefresh(); var tab = _this.tabList[_this.tabIndex];
setTimeout(() => {
tab.refreshing = true;
}, 35)
}, 350) }, 350)
}, },
onNavBarLeftClick() { onNavBarLeftClick() {
uni.navigateBack(); uni.navigateBack();
}, },
onEmptyClick() { onStatusClick() {
var tab = this.tabList[this.tabIndex];
tab.refreshing = true;
this.onRefresh(); this.onRefresh();
}, },
onRefresh(e) { onRefresh(e) {
var tab = this.tabList[this.tabIndex]; var tab = this.tabList[this.tabIndex];
if (!tab.refreshFlag) {
return;
}
tab.page = 1; tab.page = 1;
setTimeout(function() {
tab.refreshing = true; tab.refreshing = true;
}, 30);
tab.loadStatus = tab.page == tab.total_pages ? constant.LOAD_STATUS.noMore : constant.LOAD_STATUS.more; tab.loadStatus = tab.page == tab.total_pages ? constant.LOAD_STATUS.noMore : constant.LOAD_STATUS.more;
this.getList(this.tabIndex) this.getList(this.tabIndex)
}, },
...@@ -210,13 +210,15 @@ ...@@ -210,13 +210,15 @@
this.tabList[this.tabIndex].data = this.tabList[this.tabIndex].data.concat(data.list); this.tabList[this.tabIndex].data = this.tabList[this.tabIndex].data.concat(data.list);
}, },
requestFail(res, status) { requestFail(res, status) {
this.contentStatus = status; if (this.tabList[this.tabIndex].data.length == 0) {
this.tabList[this.tabIndex].contentStatus = status;
}
}, },
requestComplete() { requestComplete() {
if (this.refresherTriggered) { this.tabList[this.tabIndex].firstRequest = false;
this.refresherTriggered = false; var tab = this.tabList[this.tabIndex];
} tab.refreshing = false;
this.firstRequest = false; tab.isRequestComplete = true;
uni.hideLoading() uni.hideLoading()
}, },
onLoadMore(e) { onLoadMore(e) {
...@@ -235,7 +237,10 @@ ...@@ -235,7 +237,10 @@
if (this.tabList[index].data.length > 0) { if (this.tabList[index].data.length > 0) {
return; return;
} }
this.getList(index); var tab = this.tabList[this.tabIndex];
setTimeout(() => {
tab.refreshing = true;
}, 35)
}, },
switchTab(index) { switchTab(index) {
if (this.tabIndex === index) { if (this.tabIndex === index) {
...@@ -285,7 +290,6 @@ ...@@ -285,7 +290,6 @@
}) })
}, },
ensure() { ensure() {
uni.$emit("onRepairItemSelected", this.seletedItem)
uni.navigateBack(); uni.navigateBack();
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment