|
|
@@ -33,7 +33,14 @@ Page({
|
|
|
node: true,
|
|
|
size: true
|
|
|
})
|
|
|
- .exec(this.init.bind(this))
|
|
|
+ .exec(res => {
|
|
|
+ if (!res || !res.length || !res[0]) return
|
|
|
+ const width = res[0].width
|
|
|
+ const height = res[0].height
|
|
|
+ const canvas = res[0].node
|
|
|
+ this.drawCanvas._init({ width, height, canvas, dicTypePath: this.data.dicTypePath[0] })
|
|
|
+ this.onChange({ target: { dataset: { item: this.data.list[0] } } })
|
|
|
+ })
|
|
|
},
|
|
|
|
|
|
init(res) {
|
|
|
@@ -64,13 +71,19 @@ Page({
|
|
|
this.drawCanvas.clear()
|
|
|
},
|
|
|
|
|
|
- changeTool(e) {
|
|
|
+ onChange(e) {
|
|
|
const { url, w, h } = e.target.dataset.item
|
|
|
if (!url) return
|
|
|
- this.drawCanvas.changeBrush(url, w, h, this.data.angle)
|
|
|
+ this.drawCanvas.changeBrush({ url, w, h, angle: this.data.angle })
|
|
|
},
|
|
|
|
|
|
save() {
|
|
|
- this.drawCanvas.save()
|
|
|
+ this.drawCanvas.save(res => {
|
|
|
+ console.log('保存', res);
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ onUnload() {
|
|
|
+ this.drawCanvas.destory()
|
|
|
}
|
|
|
})
|