Commit 9037169d by 穆启卓

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

parent 3ad20622
...@@ -288,7 +288,7 @@ Page({ ...@@ -288,7 +288,7 @@ Page({
if (resData.total_step > 0) { if (resData.total_step > 0) {
// this.changeShowPopup(); // this.changeShowPopup();
const realCurrentSteps = (resData.step_data && resData.step_data[0]) ? resData.step_data[0].step : 0; 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 { } else {
setData.currentSteps = (resData.step_data && resData.step_data[0]) ? resData.step_data[0].step : 0; setData.currentSteps = (resData.step_data && resData.step_data[0]) ? resData.step_data[0].step : 0;
} }
...@@ -311,17 +311,20 @@ Page({ ...@@ -311,17 +311,20 @@ Page({
// 让canvas动起来 // 让canvas动起来
dynamicDrawCanvas(realCurrentSteps, increment) { dynamicDrawCanvas(realCurrentSteps, increment) {
setTimeout(() => { setTimeout(() => {
this.drawProgressCanvas();
if (this.data.currentSteps < realCurrentSteps - increment) { if (this.data.currentSteps < realCurrentSteps - increment) {
// 让数字动
this.setData({ 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); this.dynamicDrawCanvas(realCurrentSteps, increment);
} else { } else {
this.setData({ this.setData({
currentSteps: realCurrentSteps currentSteps: realCurrentSteps
}); });
return;
} }
}, 10); }, 10);
}, },
...@@ -330,7 +333,7 @@ Page({ ...@@ -330,7 +333,7 @@ Page({
drawProgressCanvas() { drawProgressCanvas() {
const rate = this.data.progressCanvasRate, const rate = this.data.progressCanvasRate,
context = this.data.progressCanvasContext, 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, targetSteps = this.data.targetSteps || 1,
progressValue = currentSteps / targetSteps; progressValue = currentSteps / targetSteps;
context.translate(375 * rate, 255 * rate); 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