Commit 9037169d by 穆启卓

仪表盘进度条超出情况处理

parent 3ad20622
......@@ -288,7 +288,7 @@ Page({
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, resData.total_step / 100);
this.dynamicDrawCanvas(realCurrentSteps, (resData.currentSteps > resData.total_step ? resData.total_step : resData.currentSteps) / 100);
} else {
setData.currentSteps = (resData.step_data && resData.step_data[0]) ? resData.step_data[0].step : 0;
}
......@@ -311,17 +311,20 @@ Page({
// 让canvas动起来
dynamicDrawCanvas(realCurrentSteps, increment) {
setTimeout(() => {
this.drawProgressCanvas();
if (this.data.currentSteps < realCurrentSteps - increment) {
// 让数字动
this.setData({
currentSteps: this.data.currentSteps + increment
currentSteps: Math.floor(this.data.currentSteps + increment)
});
// 画进度条
if (this.data.currentSteps <= this.data.targetSteps) {
this.drawProgressCanvas();
}
this.dynamicDrawCanvas(realCurrentSteps, increment);
} else {
this.setData({
currentSteps: realCurrentSteps
});
return;
}
}, 10);
},
......@@ -330,7 +333,7 @@ Page({
drawProgressCanvas() {
const rate = this.data.progressCanvasRate,
context = this.data.progressCanvasContext,
currentSteps = this.data.currentSteps || 0,
currentSteps = (this.data.currentSteps > this.data.targetSteps ? this.data.targetSteps : this.data.currentSteps) || 0,
targetSteps = this.data.targetSteps || 1,
progressValue = currentSteps / targetSteps;
context.translate(375 * rate, 255 * rate);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment