feat: 完成绘制汉字基础功能
This commit is contained in:
@@ -12,6 +12,7 @@ Page({
|
||||
|
||||
data: {
|
||||
cardList: [] as CardList,
|
||||
selectedWords: [] as string[],
|
||||
showColorPopup: false,
|
||||
currentKey: 0,
|
||||
currentColor: '',
|
||||
@@ -43,6 +44,7 @@ Page({
|
||||
{ color: '#FFFF00', word: '迎' },
|
||||
{ color: '#8A2BE2', word: '您' },
|
||||
],
|
||||
selectedWords: ['涂', '鸦', '丫', '欢', '迎', '您'],
|
||||
showIntroductionPopup: true,
|
||||
env: getApp().globalData.env || 'release',
|
||||
});
|
||||
@@ -69,8 +71,8 @@ Page({
|
||||
const boxWidth = rect.width;
|
||||
const boxHeight = boxWidth / (width / height);
|
||||
|
||||
this.boxHeight = boxHeight;
|
||||
this.boxWidth = boxWidth;
|
||||
console.log('boxWidth----:', boxWidth)
|
||||
console.log('boxHeight----:', boxHeight)
|
||||
|
||||
// 然后初始化canvas
|
||||
wx.createSelectorQuery()
|
||||
@@ -108,7 +110,10 @@ Page({
|
||||
callback: () => void = () => { },
|
||||
) {
|
||||
if (updatedCardList) {
|
||||
this.setData({ cardList: updatedCardList }, () => {
|
||||
this.setData({
|
||||
cardList: updatedCardList,
|
||||
selectedWords: updatedCardList.map((item) => item.word)
|
||||
}, () => {
|
||||
// 如果cardList有内容且canvas未初始化,先初始化canvas
|
||||
if (!this.canvas) {
|
||||
this.initCanvas();
|
||||
|
||||
@@ -84,7 +84,7 @@
|
||||
bind:onChange="onChangeColor" />
|
||||
<word-picker
|
||||
show="{{showSelectWordPopup}}"
|
||||
cardList="{{cardList}}"
|
||||
selectedWords="{{cardList}}"
|
||||
bind:onClose="closeSelectWordPopup"
|
||||
bind:onChange="onChangeWord" />
|
||||
</view>
|
||||
|
||||
Reference in New Issue
Block a user