|
@@ -19,27 +19,27 @@ Component({
|
|
|
this.updateDisabled(newVal);
|
|
|
}
|
|
|
},
|
|
|
- width: {
|
|
|
- type: Number,
|
|
|
- value: 100,
|
|
|
- observer(newVal) {
|
|
|
- this.updateWidth(newVal);
|
|
|
- }
|
|
|
- },
|
|
|
- r: {
|
|
|
- type: Number,
|
|
|
- value: 90,
|
|
|
- observer(newVal) {
|
|
|
- this.updateR(newVal);
|
|
|
- }
|
|
|
- },
|
|
|
- lw: {
|
|
|
- type: Number,
|
|
|
- value: 5,
|
|
|
- observer(newVal) {
|
|
|
- this.updateLw(newVal);
|
|
|
- }
|
|
|
- },
|
|
|
+ // width: {
|
|
|
+ // type: Number,
|
|
|
+ // value: 100,
|
|
|
+ // observer(newVal) {
|
|
|
+ // this.updateWidth(newVal);
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ // r: {
|
|
|
+ // type: Number,
|
|
|
+ // value: 90,
|
|
|
+ // observer(newVal) {
|
|
|
+ // this.updateR(newVal);
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ // lw: {
|
|
|
+ // type: Number,
|
|
|
+ // value: 5,
|
|
|
+ // observer(newVal) {
|
|
|
+ // this.updateLw(newVal);
|
|
|
+ // }
|
|
|
+ // },
|
|
|
},
|
|
|
|
|
|
|
|
@@ -54,9 +54,20 @@ Component({
|
|
|
r:110,
|
|
|
lw:7,
|
|
|
},
|
|
|
-
|
|
|
+
|
|
|
lifetimes: {
|
|
|
attached() {
|
|
|
+
|
|
|
+ const container = this.selectComponent('#container')
|
|
|
+ // const width = container.offsetWidth;
|
|
|
+ // const height = container.offsetHeight;
|
|
|
+ console.log("xxxxxxxxxxxxxxxxxxxxxxx")
|
|
|
+ console.log(container)
|
|
|
+ // console.log(width)
|
|
|
+ // console.log(height)
|
|
|
+ console.log("xxxxxxxxxxxxxxxxxxxxxxx")
|
|
|
+
|
|
|
+
|
|
|
// 组件加载后准备绘制
|
|
|
this.initCanvas();
|
|
|
},
|
|
@@ -70,11 +81,28 @@ Component({
|
|
|
* 初始化 Canvas 上下文
|
|
|
*/
|
|
|
initCanvas() {
|
|
|
+ let that = this
|
|
|
// 获取两个canvas元素的上下文
|
|
|
this.bgContext = wx.createCanvasContext('canvasProgressbg', this);
|
|
|
this.progressContext = wx.createCanvasContext('canvasProgress', this);
|
|
|
- this.drawProgressbg();
|
|
|
- this.drawCircle(this.data.progress);
|
|
|
+
|
|
|
+
|
|
|
+ const container = this.selectComponent('#container')
|
|
|
+ var query = wx.createSelectorQuery().in(this);
|
|
|
+ query.select('#container').boundingClientRect()
|
|
|
+ query.exec(function (res) {
|
|
|
+ //res就是 所有标签为publicImg的元素的信息 的数组
|
|
|
+ console.log(res);
|
|
|
+ that.data.width = res[0].width / 2
|
|
|
+ that.data.r = that.data.width - 1
|
|
|
+ that.data.lw = 1
|
|
|
+
|
|
|
+ that.drawProgressbg();
|
|
|
+ that.drawCircle(that.data.progress);
|
|
|
+ })
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -100,10 +128,6 @@ Component({
|
|
|
|
|
|
this.progressContext.setFillStyle('red');
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -133,33 +157,33 @@ Component({
|
|
|
/**
|
|
|
* 更新并画disabled
|
|
|
*/
|
|
|
- updateWidth(dis) {
|
|
|
- this.setData({
|
|
|
- width:dis
|
|
|
- })
|
|
|
- //const normalizedProgress = (progressPercentage / 100) * 2; // 转换成弧度,最大值为2(对应100%)
|
|
|
- if(this.progressContext){
|
|
|
- this.drawCircle(this.data.progressPercentage);
|
|
|
- }
|
|
|
- },
|
|
|
- updateR(dis) {
|
|
|
- this.setData({
|
|
|
- r:dis
|
|
|
- })
|
|
|
- //const normalizedProgress = (progressPercentage / 100) * 2; // 转换成弧度,最大值为2(对应100%)
|
|
|
- if(this.progressContext){
|
|
|
- this.drawCircle(this.data.progressPercentage);
|
|
|
- }
|
|
|
- },
|
|
|
- updateLw(dis) {
|
|
|
- this.setData({
|
|
|
- r:dis
|
|
|
- })
|
|
|
- //const normalizedProgress = (progressPercentage / 100) * 2; // 转换成弧度,最大值为2(对应100%)
|
|
|
- if(this.progressContext){
|
|
|
- this.drawCircle(this.data.progressPercentage);
|
|
|
- }
|
|
|
- },
|
|
|
+ // updateWidth(dis) {
|
|
|
+ // this.setData({
|
|
|
+ // width:dis
|
|
|
+ // })
|
|
|
+ // //const normalizedProgress = (progressPercentage / 100) * 2; // 转换成弧度,最大值为2(对应100%)
|
|
|
+ // if(this.progressContext){
|
|
|
+ // this.drawCircle(this.data.progressPercentage);
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ // updateR(dis) {
|
|
|
+ // this.setData({
|
|
|
+ // r:dis
|
|
|
+ // })
|
|
|
+ // //const normalizedProgress = (progressPercentage / 100) * 2; // 转换成弧度,最大值为2(对应100%)
|
|
|
+ // if(this.progressContext){
|
|
|
+ // this.drawCircle(this.data.progressPercentage);
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ // updateLw(dis) {
|
|
|
+ // this.setData({
|
|
|
+ // r:dis
|
|
|
+ // })
|
|
|
+ // //const normalizedProgress = (progressPercentage / 100) * 2; // 转换成弧度,最大值为2(对应100%)
|
|
|
+ // if(this.progressContext){
|
|
|
+ // this.drawCircle(this.data.progressPercentage);
|
|
|
+ // }
|
|
|
+ // },
|
|
|
/**
|
|
|
* 画progress进度
|
|
|
*/
|