207版本:canvas电流流向功能,海外自定义电价功能
This commit is contained in:
@ -64,14 +64,10 @@
|
||||
methods: {
|
||||
getSystemInfo() {
|
||||
const self = this
|
||||
// 获取屏幕尺寸
|
||||
uni.getSystemInfo({
|
||||
success: (res) => {
|
||||
this.windowWidth = res.windowWidth
|
||||
},
|
||||
})
|
||||
uni.getSystemInfo({
|
||||
success: function(res) {
|
||||
// 获取屏幕尺寸
|
||||
self.windowWidth = res.windowWidth
|
||||
// const platform = res.hostName.toLowerCase()
|
||||
if (res.uniPlatform || res.uniPlatform === 'app') {
|
||||
self.type = 'app'
|
||||
@ -87,20 +83,25 @@
|
||||
})
|
||||
},
|
||||
clear() {
|
||||
// if (this.type === 'wx') {
|
||||
// this.ctx.globalCompositeOperation = 'destination-out';
|
||||
// this.ctx.beginPath();
|
||||
// this.ctx.fillStyle = 'red';
|
||||
// this.ctx.fillRect(0, 0, 8000, 80000);
|
||||
// this.ctx.fill();
|
||||
// this.ctx.globalCompositeOperation = 'source-over';
|
||||
// // this.ctx.draw();
|
||||
// } else {
|
||||
// // this.ctx.clearRect(2000, 2000, 2000, 2000);
|
||||
// // this.ctx.fillStyle = '#ffffff'
|
||||
// // this.ctx.draw(true);
|
||||
// }
|
||||
if (this.type === 'wx') {
|
||||
this.ctx.globalCompositeOperation = 'destination-out';
|
||||
this.ctx.beginPath();
|
||||
this.ctx.fillStyle = 'red';
|
||||
this.ctx.fillRect(0, 0, 8000, 80000);
|
||||
this.ctx.fill();
|
||||
this.ctx.globalCompositeOperation = 'source-over';
|
||||
// this.ctx.draw();
|
||||
this.ctx.clearRect(0, 0, this.canvasWidth, this.canvasHeight);
|
||||
} else {
|
||||
// this.ctx.clearRect(2000, 2000, 2000, 2000);
|
||||
// this.ctx.fillStyle = '#ffffff'
|
||||
// this.ctx.draw(true);
|
||||
// App 平台
|
||||
this.ctx.clearRect(0, 0, 8000, 8000);
|
||||
}
|
||||
|
||||
},
|
||||
//获取app的canvas DOM
|
||||
getAppDom() {
|
||||
@ -216,22 +217,22 @@
|
||||
|
||||
},
|
||||
countChineseAndEnglishCharacters(str, x) {
|
||||
var chineseCount = str.match(/[\u4e00-\u9fa5]/g)
|
||||
? str.match(/[\u4e00-\u9fa5]/g).length
|
||||
: 0;
|
||||
var englishCount = str.match(/[a-zA-Z]/g)
|
||||
? str.match(/[a-zA-Z]/g).length
|
||||
: 0;
|
||||
var otherCount = str.length - chineseCount - englishCount;
|
||||
const obj = {
|
||||
otherCount: otherCount,
|
||||
chineseCount: chineseCount,
|
||||
englishCount: englishCount,
|
||||
};
|
||||
return (
|
||||
obj.englishCount * 6 + obj.chineseCount * 12 + obj.otherCount * 7.5 + x
|
||||
);
|
||||
},
|
||||
var chineseCount = str.match(/[\u4e00-\u9fa5]/g) ?
|
||||
str.match(/[\u4e00-\u9fa5]/g).length :
|
||||
0;
|
||||
var englishCount = str.match(/[a-zA-Z]/g) ?
|
||||
str.match(/[a-zA-Z]/g).length :
|
||||
0;
|
||||
var otherCount = str.length - chineseCount - englishCount;
|
||||
const obj = {
|
||||
otherCount: otherCount,
|
||||
chineseCount: chineseCount,
|
||||
englishCount: englishCount,
|
||||
};
|
||||
return (
|
||||
obj.englishCount * 6 + obj.chineseCount * 12 + obj.otherCount * 7.5 + x
|
||||
);
|
||||
},
|
||||
|
||||
drawText(draw) {
|
||||
draw.forEach((item, index) => {
|
||||
@ -244,8 +245,10 @@
|
||||
this.ctx.fontSize = item2.size
|
||||
}
|
||||
this.ctx.fillStyle = item2.color
|
||||
const x = this.countChineseAndEnglishCharacters(item.font[0].text,item.coord[0][0])
|
||||
this.ctx.fillText(item2.text, this.fitSize( index2 === 1 ? x : item.coord[0][0]), this.fitSize(item.coord[0][1]))
|
||||
const x = this.countChineseAndEnglishCharacters(item.font[0].text, item
|
||||
.coord[0][0])
|
||||
this.ctx.fillText(item2.text, this.fitSize(index2 === 1 ? x : item.coord[0]
|
||||
[0]), this.fitSize(item.coord[0][1]))
|
||||
this.ctx.closePath()
|
||||
})
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user