This commit is contained in:
haomingming
2023-03-22 09:01:58 +08:00
parent 589c2cf823
commit cfa69efd15
71 changed files with 1300 additions and 588 deletions
+37 -9
View File
@@ -11,7 +11,14 @@ Page({
height: app.globalData.height,
ctx: null,
canvas: null,
txt_show: true
txt_show: true,
template:{
width: '676rpx',
height: '414rpx',
views: [
{}
],
},
},
onReady() {
@@ -39,7 +46,6 @@ Page({
console.log("onReady onReady end")
})
},
ontouchmove(e){
console.log("ontouchmove ontouchmove ontouchmove");
console.log(e);
@@ -58,17 +64,19 @@ Page({
this.data.ctx.beginPath();
this.data.ctx.moveTo(e.touches[0].x,e.touches[0].y);
},
toClear() {
this.setData({
txt_show: true
});
this.data.ctx.clearRect(0,0,this.data.canvas.width,this.data.canvas.height)
},
rotate(){
let ctx = this.data.ctx;
ctx.rotate(90);
},
toSave(event) {
let _this = this;
let base64Img = _this.data.canvas.toDataURL()
let base64Img = _this.data.canvas.toDataURL();
console.log("sign: ", base64Img);
wx.canvasToTempFilePath({
canvasId: "sign_panels",
@@ -78,11 +86,32 @@ Page({
success(res) {
console.log(res.tempFilePath)
let filePath = res.tempFilePath;
_this.doUploadFile(event, 2, filePath);
console.log(_this.data.canvas)
console.log(_this.data.canvas.width)
console.log(_this.data.canvas.height)
let cs = (_this.data.canvas.height - _this.data.canvas.width)/2;
_this.setData({
"template.width": _this.data.canvas.height+"rpx",
"template.height": _this.data.canvas.width+"rpx",
"template.views[0].css.width": _this.data.canvas.width+"rpx",
"template.views[0].css.left": cs+"rpx",
"template.views[0].css.top": "-"+cs+"rpx",
"template.views[0].url": filePath,
"template.views[0].type": "image",
"template.views[0].css.rotate": "-90",
})
// _this.doUploadFile(event, 2, filePath);
}
})
},
onImgOK(e){
console.log("onImgOK onImgOK onImgOK onImgOK");
console.log(e.detail.path);
let txt_show = this.data.txt_show;
if(!txt_show){
this.doUploadFile(e, 2, e.detail.path);
}
},
doUploadFile(event, scene, filePath) {
console.log("index douploadFIle: ", event);
console.log("scene: ", scene);
@@ -128,5 +157,4 @@ Page({
console.error(errors);
})
}
})
})
+4 -2
View File
@@ -2,6 +2,8 @@
"component": true,
"usingComponents": {
"te-nav-bar": "/commpents/te_navbar",
"van-button": "@vant/weapp/button/index"
}
"van-button": "@vant/weapp/button/index",
"painter":"/commpents/painter/painter"
},
"disableScroll": true
}
+2 -1
View File
@@ -7,4 +7,5 @@
<van-button bindtap="toClear" custom-style="height: 70rpx;border-radius: 10rpx;color:#000;width: 230rpx;">清空</van-button>
<van-button bindtap="toSave" custom-style="height: 70rpx;border-radius: 10rpx;color:#fff;width: 230rpx;background: linear-gradient(315deg, #33BFB8 0%, #34BFB8 0%, #3CC7C0 100%);">确认</van-button>
</view>
</view>
</view>
<painter palette="{{template}}" style="position: absolute;top: 999999999999999999999999999999999900px;left: 999999999999999999999999999999999px;" bind:imgOK="onImgOK" />