Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wx-program
Overview
Overview
Details
Activity
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
陈玉桐
wx-program
Commits
6d0f319f
Commit
6d0f319f
authored
Oct 12, 2019
by
陈玉桐
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix 首页定时器清除
parent
9a724568
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
10 deletions
+26
-10
index.js
pages/index/index.js
+26
-10
No files found.
pages/index/index.js
View file @
6d0f319f
...
@@ -379,12 +379,14 @@ Page({
...
@@ -379,12 +379,14 @@ Page({
trainSortList
:[],
trainSortList
:[],
userRanking
:
''
,
userRanking
:
''
,
resultSortList
:[],
resultSortList
:[],
timerId
:
''
,
// 定时器id
checkImg
:
'../../assets/indexDefault.png'
,
checkImg
:
'../../assets/indexDefault.png'
,
trainingStatus
:
2
,
//训练状态 1正在训练 0:未训练
trainingStatus
:
2
,
//训练状态 1正在训练 0:未训练
trainingTime
:
0
,
//当前训练时间
trainingTime
:
0
,
//当前训练时间
watchImgText
:
'加载中'
,
//当前训练时间
watchImgText
:
'加载中'
,
//当前训练时间
indexTimer
:
''
,
refreshTimer
:
''
,
mustUpdate
:
true
,
mustUpdate
:
true
,
status
:
1
,
status
:
1
,
...
@@ -415,7 +417,15 @@ Page({
...
@@ -415,7 +417,15 @@ Page({
},
},
onShow
()
{
onShow
()
{
let
me
=
this
;
let
me
=
this
;
if
(
me
.
data
.
indexTimer
){
clearInterval
(
me
.
data
.
indexTimer
)
}
if
(
me
.
data
.
refreshTimer
){
clearInterval
(
me
.
data
.
refreshTimer
)
}
me
.
setData
({
watchImgText
:
'加载中'
,
})
app
.
getToken
().
then
(
function
(
res
)
{
app
.
getToken
().
then
(
function
(
res
)
{
if
(
res
.
status
==
200
){
if
(
res
.
status
==
200
){
// 请求前加Loading
// 请求前加Loading
...
@@ -506,7 +516,7 @@ Page({
...
@@ -506,7 +516,7 @@ Page({
checkImg
:
'../../assets/indexDefault.png'
checkImg
:
'../../assets/indexDefault.png'
})
})
let
times
=
1
let
times
=
1
let
t
imer
=
setInterval
(
function
(){
let
indexT
imer
=
setInterval
(
function
(){
// console.log(timestamp)
// console.log(timestamp)
times
++
times
++
console
.
log
(
times
)
console
.
log
(
times
)
...
@@ -520,7 +530,7 @@ Page({
...
@@ -520,7 +530,7 @@ Page({
})
})
}
}
if
(
times
>
16
){
if
(
times
>
16
){
clearInterval
(
t
imer
)
clearInterval
(
indexT
imer
)
// 获取失败
// 获取失败
me
.
setData
({
me
.
setData
({
trainingStatus
:
4
,
//1正在训练 0:未训练 2加载中 3未在线 4获取失败
trainingStatus
:
4
,
//1正在训练 0:未训练 2加载中 3未在线 4获取失败
...
@@ -547,7 +557,7 @@ Page({
...
@@ -547,7 +557,7 @@ Page({
checkImg
:
res
.
data
.
data
.
thumb
,
checkImg
:
res
.
data
.
data
.
thumb
,
trainingTime
:
res
.
data
.
data
.
nowTrainingDuration
trainingTime
:
res
.
data
.
data
.
nowTrainingDuration
})
})
clearInterval
(
t
imer
)
clearInterval
(
indexT
imer
)
}
}
}
else
{
}
else
{
// wx.showModal({
// wx.showModal({
...
@@ -560,11 +570,14 @@ Page({
...
@@ -560,11 +570,14 @@ Page({
trainingStatus
:
3
,
//训练状态 1正在训练 0:未训练
trainingStatus
:
3
,
//训练状态 1正在训练 0:未训练
checkImg
:
'../../assets/indexDefault.png'
checkImg
:
'../../assets/indexDefault.png'
})
})
clearInterval
(
t
imer
)
clearInterval
(
indexT
imer
)
}
}
}
}
})
})
},
1000
)
},
1000
)
me
.
setData
({
indexTimer
:
indexTimer
})
}
}
}
else
{
}
else
{
// wx.showModal({
// wx.showModal({
...
@@ -817,7 +830,7 @@ Page({
...
@@ -817,7 +830,7 @@ Page({
})
})
}
else
{
}
else
{
let
times
=
1
let
times
=
1
let
t
imer
=
setInterval
(
function
(){
var
refreshT
imer
=
setInterval
(
function
(){
// console.log(timestamp)
// console.log(timestamp)
times
++
times
++
console
.
log
(
times
)
console
.
log
(
times
)
...
@@ -831,7 +844,7 @@ Page({
...
@@ -831,7 +844,7 @@ Page({
})
})
}
}
if
(
times
>
16
){
if
(
times
>
16
){
clearInterval
(
t
imer
)
clearInterval
(
refreshT
imer
)
// 获取失败
// 获取失败
me
.
setData
({
me
.
setData
({
trainingStatus
:
4
,
//1正在训练 0:未训练 2加载中 3未在线 4获取失败
trainingStatus
:
4
,
//1正在训练 0:未训练 2加载中 3未在线 4获取失败
...
@@ -858,7 +871,7 @@ Page({
...
@@ -858,7 +871,7 @@ Page({
checkImg
:
res
.
data
.
data
.
thumb
,
checkImg
:
res
.
data
.
data
.
thumb
,
trainingTime
:
res
.
data
.
data
.
nowTrainingDuration
trainingTime
:
res
.
data
.
data
.
nowTrainingDuration
})
})
clearInterval
(
t
imer
)
clearInterval
(
refreshT
imer
)
}
}
}
else
{
}
else
{
// wx.showModal({
// wx.showModal({
...
@@ -871,11 +884,14 @@ Page({
...
@@ -871,11 +884,14 @@ Page({
trainingStatus
:
3
,
//训练状态 1正在训练 0:未训练
trainingStatus
:
3
,
//训练状态 1正在训练 0:未训练
checkImg
:
'../../assets/indexDefault.png'
checkImg
:
'../../assets/indexDefault.png'
})
})
clearInterval
(
t
imer
)
clearInterval
(
refreshT
imer
)
}
}
}
}
})
})
},
1000
)
},
1000
)
me
.
setData
({
refreshTimer
:
refreshTimer
})
}
}
}
else
{
}
else
{
// wx.showModal({
// wx.showModal({
...
...
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