"use strict";const e=require("../../common/vendor.js");require("../../common/libraries/request.js");const l=require("../../common/store/useWatermarkStore.js");require("../../common/store/useWeAppAuthStore.js"),require("../../common/store/useWorkStore.js");const o=require("../../common/libraries/day.js"),a=require("../../common/libraries/naviHelper.js"),s=require("../../common/libraries/upload.js"),i=require("./model.js"),t=l.useWatermarkStore(),n={handleWatermarkCameraSwitch(){i.useModel.devicePosition.value="back"===i.useModel.devicePosition.value?"front":"back"},takePhoto(){const l=e.index.createCameraContext(),n=e.index.getSystemInfoSync();let u=.82*(null==n?void 0:n.windowHeight);console.log(n,"systemInfo"),l.takePhoto({quality:"high",success:l=>{var n,r;e.index.showLoading({title:"save"===(null==(r=null==(n=i.useModel)?void 0:n.source)?void 0:r.value)?"正在保存...":"正在上传...",mask:!0});let d=e.index.createCanvasContext("watermark_camera");e.index.getImageInfo({src:null==l?void 0:l.tempImagePath,success:n=>{var r,v,c,m,f,h,g,x,k,p,M,I,w;const{width:y,height:S}=n;console.log(n,"img");const q=430*S/y;i.useModel.time.value=o.showCurrentTime(),d.drawImage((null==l?void 0:l.tempImagePath)||"",0,0,430,q),d.setFillStyle("rgba(0, 0, 0, 0.2)"),d.fillRect(0,u-100,430,100),d.setFillStyle("#ff7105"),d.fillRect(131,u-75,2,28),d.fillStyle="#fff",d.font="500 16px Arial",d.fillText((null==(c=null==(v=null==(r=i.useModel)?void 0:r.address)?void 0:v.value)?void 0:c.address)||(null==(h=null==(f=null==(m=i.useModel)?void 0:m.address)?void 0:f.value)?void 0:h.formatted_address)||"",15,u-17),d.fillText((null==(k=null==(x=null==(g=i.useModel)?void 0:g.userInfo)?void 0:x.value)?void 0:k.name)||"没有登录",141,u-64),d.font="500 12px Arial",d.fillText(`${(null==(p=i.useModel)?void 0:p.day.value)||""} ${(null==(M=i.useModel)?void 0:M.weekDay.value)||""}`,141,u-49),d.setLineWidth(3),d.setStrokeStyle("#fff"),d.font="900 45px Arial",d.fillText((null==(I=i.useModel)?void 0:I.time.value)||"",12,u-45),d.strokeText((null==(w=i.useModel)?void 0:w.time.value)||"",12,u-45),d.stroke(),d.draw(!1,()=>{e.index.canvasToTempFilePath({canvasId:"watermark_camera",success:l=>{var o,n,u,r,d,v,c,m;console.log(l,"nImg"),"current"===(null==(n=null==(o=i.useModel)?void 0:o.source)?void 0:n.value)&&s.uploadImgWatermark({path:null==l?void 0:l.tempFilePath,name:`${(null==(d=null==(r=null==(u=i.useModel)?void 0:u.userInfo)?void 0:r.value)?void 0:d.name)||"未登录"}-打卡-${(null==(v=i.useModel)?void 0:v.day.value)||""}`}).then(l=>{console.log(l,"uploadRes"),t.watermarkInfo.value=l?[l]:[],e.index.navigateBack({delta:1}),e.index.hideLoading()}).catch(l=>{console.log(l,"err"),e.index.hideLoading()}),"save"===(null==(m=null==(c=i.useModel)?void 0:c.source)?void 0:m.value)&&e.index.saveImageToPhotosAlbum({filePath:null==l?void 0:l.tempFilePath,success:function(){a.showToast("保存成功"),console.log("save success")}})}})})}}),console.log(l)}})}};exports.method=n;
