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