Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
U
uni-app-base
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tangfh
uni-app-base
Commits
9e2f1536
Commit
9e2f1536
authored
Jul 14, 2023
by
tangfh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
+
parent
a8f86323
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
84 additions
and
144 deletions
+84
-144
base-tab.vue
pages/template/base-tab.vue
+84
-144
No files found.
pages/template/base-tab.vue
View file @
9e2f1536
...
...
@@ -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 tab
List
"
:key=
"index"
>
<scroll-view
class=
"scroll-v"
scroll-y
:refresher-enabled=
"t
ru
e"
@
refresherrefresh=
"onRefresh()"
:enable-back-to-top=
"true"
:lower-threshold=
"75"
:refresher-triggered=
"tab.refreshing"
<swiper-item
class=
"swiper-item"
v-for=
"(tab,index) in tab
Bars
"
:key=
"index"
>
<scroll-view
class=
"scroll-v"
scroll-y
:refresher-enabled=
"t
ab.content.refresherEnabl
e"
@
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>
</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"
<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,224 +33,160 @@
<
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
))
},
alloc
ed
:
{
pass
ed
:
{
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
}],
tabIndex
:
0
,
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
.
tab
List
[
this
.
tabIndex
];
tab
.
refreshing
=
true
;
var
tab
=
this
.
tab
Bars
[
this
.
tabIndex
];
tab
.
content
.
refreshing
=
true
;
this
.
onRefresh
();
},
onRefresh
(
e
)
{
var
tab
=
this
.
tab
List
[
this
.
tabIndex
];
if
(
!
tab
.
refreshFlag
)
{
var
tab
=
this
.
tab
Bars
[
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
.
tab
List
[
this
.
tabIndex
];
if
(
tab
.
loadStatus
==
constant
.
LOAD_STATUS
.
noMore
)
{
var
tab
=
this
.
tab
Bars
[
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
};
util
.
request
(
url
,
param
,
option
,
{
success
:
this
.
requestSuccess
,
success
:
this
.
requestSuccess
,
fail
:
this
.
requestFail
,
complete
:
this
.
requestComplete
});
},
requestSuccess
(
res
)
{
var
tab
=
this
.
tab
List
[
this
.
tabIndex
];
var
tab
=
this
.
tab
Bars
[
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
.
content
Status
=
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
.
tab
List
[
this
.
tabIndex
].
data
.
length
==
0
)
{
this
.
tab
List
[
this
.
tabIndex
]
.
contentStatus
=
status
;
if
(
this
.
tab
Bars
[
this
.
tabIndex
].
content
.
list
.
length
==
0
)
{
this
.
tab
Bars
[
this
.
tabIndex
].
content
.
contentStatus
=
status
;
}
},
requestComplete
()
{
var
tab
=
this
.
tab
List
[
this
.
tabIndex
];
tab
.
firstRequest
=
false
;
tab
.
refreshing
=
false
;
tab
.
isRequestComplete
=
true
;
var
tab
=
this
.
tab
Bars
[
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
.
tab
List
[
index
].
data
.
length
>
0
)
{
if
(
this
.
tab
Bars
[
index
].
content
.
list
.
length
>
0
)
{
return
;
}
var
tab
=
this
.
tab
List
[
this
.
tabIndex
];
var
tab
=
this
.
tab
Bars
[
this
.
tabIndex
];
setTimeout
(()
=>
{
tab
.
refreshing
=
true
;
tab
.
content
.
refreshing
=
true
;
},
35
)
},
switchTab
(
index
)
{
...
...
@@ -269,7 +209,7 @@
}
// 缓存 tabId
if
(
this
.
tab
List
[
this
.
tabIndex
].
data
.
length
>
MAX_CACHE_DATA
)
{
if
(
this
.
tab
Bars
[
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
.
tab
List
[
cacheIndex
].
data
.
length
=
0
;
this
.
tab
List
[
cacheIndex
]
.
loadingText
=
"加载更多..."
;
this
.
tab
Bars
[
cacheIndex
].
content
.
list
.
length
=
0
;
this
.
tab
Bars
[
cacheIndex
].
content
.
loadingText
=
"加载更多..."
;
},
onItemClick
(
i
ndex2
)
{
onItemClick
(
i
tem
)
{
uni
.
navigateTo
({
url
:
'/pages/repair-detail/repair-detail'
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment