Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
walk_daka_wx
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
穆启卓
walk_daka_wx
Commits
9f3be329
Commit
9f3be329
authored
May 15, 2019
by
穆启卓
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
f8f35299
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
91 additions
and
78 deletions
+91
-78
index.js
pages/index/index.js
+91
-78
No files found.
pages/index/index.js
View file @
9f3be329
...
...
@@ -36,56 +36,7 @@ Page({
},
onReady
()
{
const
rate
=
wx
.
getSystemInfoSync
().
screenWidth
/
750
,
context
=
wx
.
createCanvasContext
(
'progressCanvas'
);
context
.
translate
(
375
*
rate
,
255
*
rate
);
this
.
data
.
progressCanvasContext
=
context
;
this
.
data
.
progressCanvasRate
=
rate
;
// 画进度条总长
context
.
setStrokeStyle
(
'rgba(255, 255, 255, 0.4)'
);
context
.
setLineWidth
(
4
*
rate
);
context
.
setLineCap
(
'round'
);
context
.
beginPath
();
context
.
arc
(
0
,
0
,
245
*
rate
,
0.90625
*
Math
.
PI
,
2.09375
*
Math
.
PI
,
false
);
context
.
stroke
();
// 画刻度
context
.
setStrokeStyle
(
'#ffffff'
);
context
.
setLineWidth
(
4
*
rate
);
context
.
rotate
(
-
0.09375
*
Math
.
PI
);
context
.
beginPath
();
const
keduLeft
=
-
230
*
rate
,
keduRight
=
-
220
*
rate
,
oneKedu
=
0.03125
*
Math
.
PI
;
context
.
moveTo
(
keduLeft
,
0
);
context
.
lineTo
(
keduRight
,
0
);
context
.
stroke
();
for
(
let
i
=
0
;
i
<
38
;
i
++
)
{
context
.
rotate
(
oneKedu
);
context
.
beginPath
();
context
.
moveTo
(
keduLeft
,
0
);
context
.
lineTo
(
keduRight
,
0
);
context
.
stroke
();
}
// 画当前圆球
context
.
setFillStyle
(
'#ffffff'
);
context
.
rotate
(
2.544
);
context
.
arc
(
-
245
*
rate
,
0
,
7
*
rate
,
0
,
2
*
Math
.
PI
,
false
);
context
.
fill
();
// 画
context
.
draw
(
false
,
drawRes
=>
{
if
(
drawRes
.
errMsg
===
'drawCanvas:ok'
)
{
wx
.
canvasToTempFilePath
({
canvasId
:
'progressCanvas'
,
success
:(
ImageRes
)
=>
{
this
.
setData
({
progressCanvasImage
:
ImageRes
.
tempFilePath
});
}
});
}
else
{
// 重画
}
});
this
.
initCanvas
();
},
getPageData
()
{
...
...
@@ -266,40 +217,48 @@ Page({
},
method
:
'POST'
,
success
:(
res
)
=>
{
this
.
data
.
isFirstReq
=
false
;
const
resData
=
res
.
data
.
data
;
// 数据处理,结合!!两个数组!!判断是否显示打卡角标和状态
const
joinDate
=
[];
resData
.
records_info
.
forEach
(
item
=>
{
joinDate
.
push
(
item
.
period
);
});
resData
.
step_data
.
forEach
(
item
=>
{
if
(
joinDate
.
indexOf
(
item
.
period
)
>
-
1
)
{
if
(
resData
.
records_info
[
joinDate
.
indexOf
(
item
.
period
)].
daka_done
)
{
item
.
status
=
1
;
// 打卡成功
wx
.
hideLoading
();
if
(
res
.
data
.
code
===
0
)
{
this
.
data
.
isFirstReq
=
false
;
const
resData
=
res
.
data
.
data
;
// 数据处理,结合!!两个数组!!判断是否显示打卡角标和状态
const
joinDate
=
[];
resData
.
records_info
.
forEach
(
item
=>
{
joinDate
.
push
(
item
.
period
);
});
resData
.
step_data
.
forEach
(
item
=>
{
if
(
joinDate
.
indexOf
(
item
.
period
)
>
-
1
)
{
if
(
resData
.
records_info
[
joinDate
.
indexOf
(
item
.
period
)].
daka_done
)
{
item
.
status
=
1
;
// 打卡成功
}
else
{
item
.
status
=
2
;
// 打卡失败
}
}
else
{
item
.
status
=
2
;
// 打卡失败
item
.
status
=
0
;
// 未参与打卡
}
});
// wx.setStorageSync('getStepLoading', Date.now());
// 避免没有目标步数,不好比较是否达标
const
setData
=
{
targetSteps
:
resData
.
total_step
,
stepRecordList
:
resData
.
step_data
};
if
(
resData
.
total_step
>
0
)
{
// this.changeShowPopup();
const
realCurrentSteps
=
(
resData
.
step_data
&&
resData
.
step_data
[
0
])
?
resData
.
step_data
[
0
].
step
:
0
;
this
.
dynamicDrawCanvas
(
realCurrentSteps
,
(
realCurrentSteps
>
resData
.
total_step
?
resData
.
total_step
:
realCurrentSteps
)
/
100
);
}
else
{
item
.
status
=
0
;
// 未参与打卡
setData
.
currentSteps
=
(
resData
.
step_data
&&
resData
.
step_data
[
0
])
?
resData
.
step_data
[
0
].
step
:
0
;
}
});
// wx.setStorageSync('getStepLoading', Date.now());
// 避免没有目标步数,不好比较是否达标
const
setData
=
{
targetSteps
:
resData
.
total_step
,
stepRecordList
:
resData
.
step_data
};
if
(
resData
.
total_step
>
0
)
{
// this.changeShowPopup();
const
realCurrentSteps
=
(
resData
.
step_data
&&
resData
.
step_data
[
0
])
?
resData
.
step_data
[
0
].
step
:
0
;
this
.
dynamicDrawCanvas
(
realCurrentSteps
,
(
realCurrentSteps
>
resData
.
total_step
?
resData
.
total_step
:
realCurrentSteps
)
/
100
);
this
.
setData
(
setData
);
this
.
showToast
();
}
else
{
setData
.
currentSteps
=
(
resData
.
step_data
&&
resData
.
step_data
[
0
])
?
resData
.
step_data
[
0
].
step
:
0
;
wx
.
showToast
({
title
:
'同步步数失败,请联系客服处理'
,
icon
:
'none'
,
duration
:
2000
});
}
this
.
setData
(
setData
);
wx
.
hideLoading
();
this
.
showToast
();
},
fail
:
()
=>
{
wx
.
hideLoading
();
...
...
@@ -616,6 +575,60 @@ Page({
}
},
// 初始化仪表盘
initCanvas
()
{
const
rate
=
wx
.
getSystemInfoSync
().
screenWidth
/
750
,
context
=
wx
.
createCanvasContext
(
'progressCanvas'
);
context
.
translate
(
375
*
rate
,
255
*
rate
);
this
.
data
.
progressCanvasContext
=
context
;
this
.
data
.
progressCanvasRate
=
rate
;
// 画进度条总长
context
.
setStrokeStyle
(
'rgba(255, 255, 255, 0.4)'
);
context
.
setLineWidth
(
4
*
rate
);
context
.
setLineCap
(
'round'
);
context
.
beginPath
();
context
.
arc
(
0
,
0
,
245
*
rate
,
0.90625
*
Math
.
PI
,
2.09375
*
Math
.
PI
,
false
);
context
.
stroke
();
// 画刻度
context
.
setStrokeStyle
(
'#ffffff'
);
context
.
setLineWidth
(
4
*
rate
);
context
.
rotate
(
-
0.09375
*
Math
.
PI
);
context
.
beginPath
();
const
keduLeft
=
-
230
*
rate
,
keduRight
=
-
220
*
rate
,
oneKedu
=
0.03125
*
Math
.
PI
;
context
.
moveTo
(
keduLeft
,
0
);
context
.
lineTo
(
keduRight
,
0
);
context
.
stroke
();
for
(
let
i
=
0
;
i
<
38
;
i
++
)
{
context
.
rotate
(
oneKedu
);
context
.
beginPath
();
context
.
moveTo
(
keduLeft
,
0
);
context
.
lineTo
(
keduRight
,
0
);
context
.
stroke
();
}
// 画当前圆球
context
.
setFillStyle
(
'#ffffff'
);
context
.
rotate
(
2.544
);
context
.
arc
(
-
245
*
rate
,
0
,
7
*
rate
,
0
,
2
*
Math
.
PI
,
false
);
context
.
fill
();
// 画
context
.
draw
(
false
,
drawRes
=>
{
if
(
drawRes
.
errMsg
===
'drawCanvas:ok'
)
{
wx
.
canvasToTempFilePath
({
canvasId
:
'progressCanvas'
,
success
:(
ImageRes
)
=>
{
this
.
setData
({
progressCanvasImage
:
ImageRes
.
tempFilePath
});
}
});
}
else
{
// 重画
}
});
},
// 暂留==================================================================
// 通过code2session方式拿unionid
...
...
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