Commit 9e2f1536 authored by tangfh's avatar tangfh

+

parent a8f86323
......@@ -8,17 +8,21 @@
:marginL="tabItemMargin" :marginR="tabItemMargin" @onTabItemClick="onTabItemClick"></c-tab-bar>
<swiper :current="tabIndex" class="swiper-box" :duration="300" @change="onTabChange"
:style="{height: swiperHeight + 'px'}">
<swiper-item class="swiper-item" v-for="(tab,index) in tabList" :key="index">
<scroll-view class="scroll-v" scroll-y :refresher-enabled="true" @refresherrefresh="onRefresh()"
:enable-back-to-top="true" :lower-threshold="75" :refresher-triggered="tab.refreshing"
<swiper-item class="swiper-item" v-for="(tab,index) in tabBars" :key="index">
<scroll-view class="scroll-v" scroll-y :refresher-enabled="tab.content.refresherEnable" @refresherrefresh="onRefresh()"
:enable-back-to-top="true" :lower-threshold="75" :refresher-triggered="tab.content.refreshing"
@scrolltolower="onLoadMore(index)" :style="{height: (swiperHeight) + 'px'}">
<view class="flex-column" v-if="tab.data.length > 0" :style="{'min-height': (svHeight + 'rpx')}">
<view class="view-tmp1 active" v-for="(item2, index2) in tab.data" :index="index2" :key="index2"
:item="item2" @onItemClick="onItemClick"></view>
<view class="flex-column" v-if="tab.content.list.length > 0"
:style="{'min-height': (swiperHeight + 'px')}">
<view class="view-tmp1 active" v-for="(item2, index2) in tab.content.list" :index="index2"
:key="index2" :item="item2" @onItemClick="onItemClick(item2, index2)">
<text>hello</text>
</view>
<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"
</view>
<c-status-view v-if="tab.content.list.length == 0 && !tab.content.firstRequest"
:status="tab.content.contentStatus" @onStatusClick="onStatusClick"></c-status-view>
<uni-load-more :status="tab.content.loadStatus" :icon-size="16"
v-if="tab.content.isLoading || tab.content.list.length > 0"
:content-text="loadMoreViewContentText" />
</scroll-view>
</swiper-item>
......@@ -29,166 +33,114 @@
<script>
import constant from './../../utils/constant.js'
import util from './../../utils/util.js'
import MSC from './../../utils/mishang_constant.js'
// 缓存每页最多
const MAX_CACHE_DATA = 100;
// 缓存页签数量
const MAX_CACHE_PAGE = 3;
const REPAIR_LIST_TYPE = {
wait_alloc: {
const TABBARS = {
apply: {
type: 1,
text: 'alloc',
name: '店员申请',
content: JSON.parse(JSON.stringify(constant.LIST_CONTENT))
},
alloced: {
passed: {
type: 2,
text: 'alloced',
name: '我的店员',
content: JSON.parse(JSON.stringify(constant.LIST_CONTENT))
}
};
export default {
data() {
return {
title: '报修单分配',
title: '通行证管理',
navBarHeight: 0,
scrollViewHeight: 1000,
refresherTriggered: false,
loadMoreViewShow: false,
loadMoreViewContentText: {
contentnomore: "到底啦~"
},
loadMoreViewStatus: 'noMore',
tabList: [],
cacheTab: [],
tabIndex: 0,
tabBars: [{
name: '待分配(0)',
type: REPAIR_LIST_TYPE.wait_alloc.type
}, {
name: '已分配(0)',
type: REPAIR_LIST_TYPE.alloced.type
}],
tabBars: [TABBARS.apply, TABBARS.passed],
screen: "",
tabItemMargin: 30, //tabItem第一个margin-left和最后一个margin-right的margin
tabWidth: 0,
scrollInto: "",
swiperHeight: 1000,
svHeight: 1000,
loadTexts: {
contentdown: '上拉加载更多',
contentrefresh: '加载中',
contentnomore: '没有更多~'
},
loadTexts: constant.LOAD_TEXTS,
seletedItem: {
range_name: ""
},
itemTmp: {
title: "内部报修",
statusAlias: "抢单中",
order_sn: "SN2023050813",
date: "2023-05-06-08 13:16",
item: "公共照明",
},
}
},
onLoad(option) {
var systemInfo = uni.getSystemInfoSync();
//scroll-view的高度 = 屏幕高度 -(顶部状态栏高度 + 导航栏高度) -(底部tabBar高度 + 底部安全区域高度)
this.scrollViewHeight = systemInfo.screenHeight - (uni.getSystemInfoSync()
.statusBarHeight + this.$refs.navBar.height) - (systemInfo.safeAreaInsets.bottom);
this.swiperHeight = this.scrollViewHeight - (80) / getApp().globalData.pxToRpxScale;
this.svHeight = this.swiperHeight;
this.tabWidth = (getApp().globalData.screenWidth - this.tabItemMargin * 2) / this.tabBars.length;
let contentHeight = systemInfo.screenHeight - (uni.getSystemInfoSync()
.statusBarHeight + this.$refs.navBar.height) - (systemInfo.safeAreaInsets.bottom);
//80 tabBar的高度
this.swiperHeight = contentHeight - 80 / getApp().globalData.pxToRpxScale;
this.init(option);
},
onShow() {
if(!this.firstRequest) {
//this.getList()
var tab = this.tabBars[this.tabIndex];
if (!tab.content.firstRequest && tab.content.page == 1) {
this.getList();
}
},
methods: {
init(option) {
this.initTabBar();
this.refresh();
},
initTabBar() {
var _this = this;
refresh() {
var tab = this.tabBars[this.tabIndex];
setTimeout(() => {
_this.tabBars.forEach((tabBar) => {
var tab = {
data: [],
isLoading: false,
refreshing: false,
refreshFlag: true,
loadMoreFlag: true,
loadStatus: constant.LOAD_STATUS.loading,
page: 1,
total_pages: 1,
loadingText: '加载更多...',
isRequestComplete: false,
channel: ""
};
if (tabBar.type == REPAIR_LIST_TYPE.wait_alloc.type) {
tab.limit = 10;
tab.loadStatus = constant.LOAD_STATUS.more;
tab.total_pages = 1;
// tab.data.push([{},{},{}]);
tab.channel = REPAIR_LIST_TYPE.wait_alloc.text
} else if (tabBar.type == REPAIR_LIST_TYPE.alloced.type) {
tab.limit = 5;
tab.loadStatus = constant.LOAD_STATUS.more;
tab.total_pages = 1;
// tab.data.push([{},{},{},{},{},{}]);
tab.channel = REPAIR_LIST_TYPE.alloced.text
}
if (tab.total_pages == 1) {
tab.loadStatus = constant.LOAD_STATUS.noMore;
tab.loadingText = _this.loadTexts.contentnomore;
}
_this.tabList.push(tab);
});
var tab = _this.tabList[_this.tabIndex];
setTimeout(() => {
tab.refreshing = true;
}, 35)
}, 350)
tab.content.refreshing = true;
}, 1000)
},
onNavBarLeftClick() {
uni.navigateBack();
},
onStatusClick() {
var tab = this.tabList[this.tabIndex];
tab.refreshing = true;
var tab = this.tabBars[this.tabIndex];
tab.content.refreshing = true;
this.onRefresh();
},
onRefresh(e) {
var tab = this.tabList[this.tabIndex];
if (!tab.refreshFlag) {
var tab = this.tabBars[this.tabIndex];
if (!tab.content.refreshFlag) {
return;
}
tab.page = 1;
tab.loadStatus = tab.page == tab.total_pages ? constant.LOAD_STATUS.noMore : constant.LOAD_STATUS.more;
tab.refreshing = true;
tab.content.page = 1;
tab.content.loadStatus = tab.content.page == tab.content.total_pages ? constant.LOAD_STATUS.noMore :
constant.LOAD_STATUS.more;
tab.content.refreshing = true;
this.getList(this.tabIndex)
},
onLoadMore(e) {
var tab = this.tabList[this.tabIndex];
if (tab.loadStatus == constant.LOAD_STATUS.noMore) {
var tab = this.tabBars[this.tabIndex];
if (tab.content.loadStatus == constant.LOAD_STATUS.noMore) {
return;
}
tab.loadStatus = constant.LOAD_STATUS.loading;
tab.page++;
tab.content.loadStatus = constant.LOAD_STATUS.loading;
tab.content.page++;
this.getList(this.tabIndex);
},
getList(index) {
let url = "";
if(!url) {
let url = MSC.URLS.audit_clerk_list;
if (!url) {
return;
}
let param = {
channel: this.tabList[index].channel,
keywords: "",
search_status: "",
page: this.tabList[index].page
status: this.tabBars[index].type,
screen: this.screen,
};
let option = {
isNeedShowLoading: false
......@@ -200,53 +152,41 @@
});
},
requestSuccess(res) {
var tab = this.tabList[this.tabIndex];
var tab = this.tabBars[this.tabIndex];
if (res.statusCode != 200) {
tab.refreshing = false;
tab.isRequestComplete = true;
tab.content.refreshing = false;
tab.content.isRequestComplete = true;
return;
}
tab.firstRequest = false;
tab.content.firstRequest = false;
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_pages = util.calTotalPage(data.total_list);
if (tab.content.refreshing || tab.content.list.length == 0) {
tab.content.total_pages = util.calTotalPage(data.total_list);
this.clearTabData(this.tabIndex);
tab.data = list;
tab.loadStatus = tab.total_pages == 1 ? constant.LOAD_STATUS.noMore : constant.LOAD_STATUS.more;
} else if (tab.loadStatus == constant.LOAD_STATUS.loading) {
tab.content.list = list;
tab.content.loadStatus = tab.content.total_pages == 1 ? constant.LOAD_STATUS.noMore : constant
.LOAD_STATUS.more;
} else if (tab.content.loadStatus == constant.LOAD_STATUS.loading) {
if (list.length > 0) {
tab.data = tab.data.concat(list);
tab.content.list = tab.content.list.concat(list);
}
tab.loadStatus = tab.page == tab.total_pages ? constant.LOAD_STATUS.noMore : constant.LOAD_STATUS.more;
tab.content.loadStatus = tab.content.page == tab.content.total_pages ? constant.LOAD_STATUS.noMore :
constant.LOAD_STATUS.more;
}
tab.contentStatus = tab.data.length == 0 ? constant.CONTENT_STATUS.EMPTY : {};
tab.content.contentStatus = tab.content.list.length == 0 ? constant.CONTENT_STATUS.EMPTY : {};
},
requestFail(res, status) {
if (this.tabList[this.tabIndex].data.length == 0) {
this.tabList[this.tabIndex].contentStatus = status;
if (this.tabBars[this.tabIndex].content.list.length == 0) {
this.tabBars[this.tabIndex].content.contentStatus = status;
}
},
requestComplete() {
var tab = this.tabList[this.tabIndex];
tab.firstRequest = false;
tab.refreshing = false;
tab.isRequestComplete = true;
var tab = this.tabBars[this.tabIndex];
tab.content.firstRequest = false;
tab.content.refreshing = false;
tab.content.isRequestComplete = true;
uni.hideLoading()
},
onTabItemClick(index) {
......@@ -255,12 +195,12 @@
onTabChange(e) {
let index = e.target.current || e.detail.current;
this.switchTab(index);
if (this.tabList[index].data.length > 0) {
if (this.tabBars[index].content.list.length > 0) {
return;
}
var tab = this.tabList[this.tabIndex];
var tab = this.tabBars[this.tabIndex];
setTimeout(() => {
tab.refreshing = true;
tab.content.refreshing = true;
}, 35)
},
switchTab(index) {
......@@ -269,7 +209,7 @@
}
// 缓存 tabId
if (this.tabList[this.tabIndex].data.length > MAX_CACHE_DATA) {
if (this.tabBars[this.tabIndex].content.list.length > MAX_CACHE_DATA) {
let isExist = this.cacheTab.indexOf(this.tabIndex);
if (isExist < 0) {
this.cacheTab.push(this.tabIndex);
......@@ -287,10 +227,10 @@
}
},
clearTabData(cacheIndex) {
this.tabList[cacheIndex].data.length = 0;
this.tabList[cacheIndex].loadingText = "加载更多...";
this.tabBars[cacheIndex].content.list.length = 0;
this.tabBars[cacheIndex].content.loadingText = "加载更多...";
},
onItemClick(index2) {
onItemClick(item) {
uni.navigateTo({
url: '/pages/repair-detail/repair-detail'
})
......
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