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
7df7d7f3
Commit
7df7d7f3
authored
Jun 08, 2023
by
tangfh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
+
parent
c0d04b41
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
72 additions
and
55 deletions
+72
-55
base-page.vue
pages/template/base-page.vue
+18
-14
base-tab.vue
pages/template/base-tab.vue
+46
-41
util.js
utils/util.js
+8
-0
No files found.
pages/template/base-page.vue
View file @
7df7d7f3
...
...
@@ -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
.
i
sOnFilter
||
this
.
i
tems
.
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
:
{};
},
...
...
pages/template/base-tab.vue
View file @
7df7d7f3
...
...
@@ -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
;
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
:
{}
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
);
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'
...
...
utils/util.js
View file @
7df7d7f3
...
...
@@ -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
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