dev
xiaowen 3 years ago
parent bf4d3eb79a
commit 9df968c2cd

@ -39,7 +39,10 @@ Component({
// 在组件实例进入页面节点树时执行
const query = this.createSelectorQuery()
query.select('#' + this.data.canvasId)
.fields({ node: true, size: true })
.fields({
node: true,
size: true
})
.exec((res) => {
this.setData({
canvas: res[0].node
@ -51,14 +54,14 @@ Component({
observers: {
list(newVal) {
if (!newVal || !Array.isArray(newVal) || newVal.length === 0) return
let { width, height, list, wordData, color } = this.data
let {
width,
height,
list,
wordData,
color
} = this.data
list = newVal;
if (!width || isNaN(Number(width))) {
width = 375
}
if (!height || isNaN(Number(height))) {
height = 450
}
const dpr = wx.getSystemInfoSync().pixelRatio
this.setData({
options: {
@ -72,7 +75,7 @@ Component({
"rotateRatio": 0.2, // probability for the word to rotate. 1 means always
"relativeScaling": 0.1,
"height": height * dpr,
"width": width * dpr
"width": 375 * dpr
}
})
setTimeout(() => {
@ -112,7 +115,9 @@ Component({
*/
methods: {
bindWord(event) {
const { detail } = event.currentTarget.dataset
const {
detail
} = event.currentTarget.dataset
this.triggerEvent('detail', detail);
},
doData(list = []) {
@ -120,10 +125,13 @@ Component({
return []
}
let arr = [];
let max = this.data.lvl;
let maxVal = list[0][1];
let l = list.length;
let x = l / (375 * this.data.height)
let max = x * maxVal;
let y = 23 / max;
list.forEach(ele => {
let a = [ele[0], ele[1] / maxVal * max];
let a = [ele[0], ele[1] * x * y];
arr.push(a)
})
return arr;

@ -6,7 +6,7 @@
.wc-canvas {
display: none;
position: absolute;
width: 100%;
width: 375px;
height: 100%;
z-index: -1;
}

Loading…
Cancel
Save