Commit 7df7d7f3 authored by tangfh's avatar tangfh

+

parent c0d04b41
......@@ -74,6 +74,16 @@
onEmptyClick() {
this.onRefresh();
},
onBottomBtnClick() {
uni.navigateTo({
url: "/pages/repair-apply/repair-apply"
})
},
onItemClick(item) {
uni.navigateTo({
url: "/pages/repair-detail/repair-detail"
})
},
onRefresh(e) {
this.refresherTriggered = true;
this.refreshInit();
......@@ -84,21 +94,15 @@
return;
}
this.loadMoreStatus = constant.LOAD_STATUS.loading;
this.page++;
this.request();
},
onBottomBtnClick() {
uni.navigateTo({
url: "/pages/repair-apply/repair-apply"
})
},
onItemClick(item) {
uni.navigateTo({
url: "/pages/repair-detail/repair-detail"
})
},
request() {
this.page = this.page > this.total_page ? this.total_page : this.page;
let url = "";
if(!url) {
return;
}
let param = {
channel: this.channel,
page: this.page
......@@ -120,19 +124,19 @@
let data = res.data.data;
let list = data.list;
try {
this.page++;
this.total_page = data.total_list / 10 + (data.total_list % 10 > 0 ? 1 : 0);
this.total_page = util.calTotalPage(data.total_list);
} catch (e) {
this.total_page = 1;
console.log(e);
}
if (this.refresherTriggered || this.isOnFilter || this.items.length == 0) {
if (this.refresherTriggered || this.items.length == 0) {
this.items = list;
this.loadMoreStatus = this.total_page == 1 ? constant.LOAD_STATUS.noMore : constant.LOAD_STATUS.more;
} else if (this.loadMoreStatus == 'loading') {
} else if (this.loadMoreStatus == constant.LOAD_STATUS.loading) {
if (list.length > 0) {
this.items = this.items.concat(list);
}
this.loadMoreStatus = this.page == this.total_page ? constant.LOAD_STATUS.noMore : constant.LOAD_STATUS.more;
}
this.contentStatus = this.items.length == 0 ? constant.CONTENT_STATUS.EMPTY : {};
},
......
......@@ -162,13 +162,29 @@
},
onRefresh(e) {
var tab = this.tabList[this.tabIndex];
if (!tab.refreshFlag) {
return;
}
tab.page = 1;
tab.refreshing = true;
tab.loadStatus = tab.page == tab.total_pages ? constant.LOAD_STATUS.noMore : constant.LOAD_STATUS.more;
tab.refreshing = true;
this.getList(this.tabIndex)
},
onLoadMore(e) {
var tab = this.tabList[this.tabIndex];
if (!tab.loadMoreFlag || tab.loadStatus == constant.LOAD_STATUS.noMore) {
return;
}
tab.loadStatus = constant.LOAD_STATUS.loading;
tab.page += 1;
tab.loadStatus = tab.page > tab.total_pages ? constant.LOAD_STATUS.noMore : constant.LOAD_STATUS.more;
this.getList(this.tabIndex);
},
getList(index) {
let url = "";
if(!url) {
return;
}
let param = {
channel: this.tabList[index].channel,
keywords: "",
......@@ -191,25 +207,36 @@
tab.isRequestComplete = true;
return;
}
let data = res.data.data;
tab.firstRequest = false;
tab.refreshing = false;
tab.isRequestComplete = true;
let data = res.data.data;
let list = data.list;
// let tabBars = [{
// name: '待分配(' + data.channel_ct.alloc + ')',
// type: REPAIR_LIST_TYPE.wait_alloc.type
// }, {
// name: '已分配(' + data.channel_ct.alloced + ')',
// type: REPAIR_LIST_TYPE.alloced.type
// }];
// this.tabBars = tabBars;
// list.forEach((item, index) => {
// item.ui = {
//
// }
// })
if (tab.refreshing || tab.data.length == 0) {
tab.total_page = util.calTotalPage(data.total_list);
this.clearTabData(this.tabIndex);
let tabBars = [{
name: '待分配(' + data.channel_ct.alloc + ')',
type: REPAIR_LIST_TYPE.wait_alloc.type
}, {
name: '已分配(' + data.channel_ct.alloced + ')',
type: REPAIR_LIST_TYPE.alloced.type
}];
this.tabBars = tabBars;
const dayjs = require("dayjs");
data.list.forEach((item, index) => {
item.addtimeformat = dayjs.unix(item.addtime).format("YYYY-MM-DD HH:mm")
})
this.tabList[this.tabIndex].data = this.tabList[this.tabIndex].data.concat(data.list);
tab.contentStatus = this.tabList[this.tabIndex].data.length == 0 ? constant.CONTENT_STATUS.EMPTY : {}
tab.data = list;
tab.loadStatus = tab.total_page == 1 ? constant.LOAD_STATUS.noMore : constant.LOAD_STATUS.more;
} else if (tab.loadStatus == constant.LOAD_STATUS.loading) {
if (list.length > 0) {
tab.data = tab.data.concat(list);
}
tab.loadStatus = tab.page == tab.total_page ? constant.LOAD_STATUS.noMore : constant.LOAD_STATUS.more;
}
tab.contentStatus = tab.data.length == 0 ? constant.CONTENT_STATUS.EMPTY : {};
},
requestFail(res, status) {
if (this.tabList[this.tabIndex].data.length == 0) {
......@@ -223,13 +250,6 @@
tab.isRequestComplete = true;
uni.hideLoading()
},
onLoadMore(e) {
var _this = this;
_this.loadMoreViewShow = true;
setTimeout(() => {
_this.loadMoreViewShow = false;
}, 1000)
},
onTabItemClick(index) {
this.switchTab(index);
},
......@@ -254,7 +274,6 @@
let isExist = this.cacheTab.indexOf(this.tabIndex);
if (isExist < 0) {
this.cacheTab.push(this.tabIndex);
//console.log("cache index:: " + this.tabIndex);
}
}
......@@ -266,26 +285,12 @@
let cacheIndex = this.cacheTab[0];
this.clearTabData(cacheIndex);
this.cacheTab.splice(0, 1);
//console.log("remove cache index:: " + cacheIndex);
}
},
clearTabData(cacheIndex) {
this.tabList[cacheIndex].data.length = 0;
this.tabList[cacheIndex].loadingText = "加载更多...";
},
loadMore(e) {
var tab = this.tabList[this.tabIndex];
if (!tab.loadMoreFlag || tab.loadStatus == constant.LOAD_STATUS.noMore) {
return;
}
tab.loadStatus = constant.LOAD_STATUS.loading;
setTimeout(() => {
//this.getList(this.tabIndex);
tab.page += 1;
tab.loadStatus = tab.page > tab.total_pages ? constant.LOAD_STATUS.noMore : constant
.LOAD_STATUS.more;
}, 500)
},
onItemClick(item) {
uni.navigateTo({
url: '/pages/repair-detail/repair-detail'
......
......@@ -406,6 +406,13 @@ function moneyFormat(value, isNeedSubLastDot, isNeedAddZero) { // 金额 格式
return value_;
}
function calTotalPage(totalList) {
if(totalList <= 10) {
return 1;
}
return totalList / 10 + (totalList % 10 > 0 ? 1 : 0)
}
export default {
getSystemInfo,
combine3,
......@@ -425,4 +432,5 @@ export default {
logObj,
signOut,
moneyFormat,
calTotalPage,
}
\ No newline at end of file
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