取消我的页面圆形进度条的动画效果,原因:App动画时会抖动

master
chen 2022-04-02 09:42:53 +08:00
parent 476de6e246
commit fe4b5e8c85
2 changed files with 146 additions and 160 deletions

View File

@ -10,14 +10,14 @@
onLaunch: function() {
//
// #ifdef APP-PLUS
getApp().globalData.hostapi = 'https://7and5.cn';
this.globalData.hostapi = 'https://7and5.cn';
// #endif
// #ifdef MP-WEIXIN
this.globalData.hostapi = 'https://7and5.cn';
// #endif
// #ifdef H5
// uni.setStorageSync('hostapi','/web');
getApp().globalData.hostapi = '/web';
this.globalData.hostapi = 'https://7and5.cn';
// this.globalData.hostapi = '/web';
// #endif
},
onShow: function() {

View File

@ -1,37 +1,17 @@
<template>
<view
class="circle-progress"
:style="{
width: widthPx + 'px',
height: widthPx + 'px',
backgroundColor: bgColor
}"
>
<view class="circle-progress"
:style="{width: widthPx + 'px',height: widthPx + 'px',backgroundColor: bgColor}">
<!-- 有的不支持canvas-id属性必须用id属性 -->
<canvas v-if="canvasId"
class="canvas-bg"
:canvas-id="canvasId"
:id="canvasId"
:style="{
width: widthPx + 'px',
height: widthPx + 'px'
}"
></canvas>
<canvas v-if="elId"
class="canvas"
:canvas-id="elId"
:id="elId"
:style="{
width: widthPx + 'px',
height: widthPx + 'px'
}"
></canvas>
<canvas v-if="canvasId" class="canvas-bg" :canvas-id="canvasId" :id="canvasId"
:style="{width: widthPx + 'px',height: widthPx + 'px'}"></canvas>
<canvas v-if="elId" class="canvas" :canvas-id="elId" :id="elId"
:style="{width: widthPx + 'px',height: widthPx + 'px'}"></canvas>
<slot></slot>
</view>
</template>
<script>
export default {
export default {
name: 'circle-progress',
props: {
//
@ -109,8 +89,8 @@ export default {
},
methods: {
//progressID
randomId(){
return 'progressId'+parseInt(Math.random()*1000000)
randomId() {
return 'progressId' + parseInt(Math.random() * 1000000)
},
drawProgressBg() {
let ctx = uni.createCanvasContext(this.canvasId, this);
@ -142,22 +122,26 @@ export default {
ctx.arc(radius, radius, radius - this.borderWidthPx, this.startAngle, endAngle, false);
ctx.stroke();
ctx.draw();
//
//
if (this.newPercent > this.oldPercent) {
progress++;
if (progress > this.newPercent) return;
} else {
//
progress--;
if (progress < this.newPercent) return;
}
// if (this.newPercent > this.oldPercent) {
// progress++;
// if (progress > this.newPercent) return;
// } else {
// //
// progress--;
// if (progress < this.newPercent) return;
// }
//
progress = this.newPercent;
setTimeout(() => {
//
this.drawCircleByProgress(progress);
}, time);
// }, time);
}, 0);
}
}
};
};
</script>
<style scoped>
@ -167,9 +151,11 @@ export default {
align-items: center;
justify-content: center;
}
.canvas-bg {
position: absolute;
}
.canvas {
position: absolute;
}