1 |
- (window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["pages-my-signature-signature"],{"0485":function(t,e,i){"use strict";i("7a82");var n=i("4ea4").default;Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var a=n(i("0a3a")),s={data:function(){return{lineColor:"black",slideValue:25,handwriting:"",selectColor:"black",color:"",showimg:"",share_popup:!1}},onLoad:function(){this.handwriting=new a.default({lineColor:this.lineColor,slideValue:this.slideValue,canvasName:"handWriting"})},methods:{selectColorEvent:function(t){this.selectColor=t,"black"==t?this.color="#1A1A1A":"red"==t&&(this.color="#ca262a"),this.handwriting.selectColorEvent(this.color)},retDraw:function(){this.handwriting.retDraw()},updateValue:function(t){console.log(t.detail),this.slideValue=t.detail.value,this.handwriting.selectSlideValue(this.slideValue)},uploadScaleStart:function(t){this.handwriting.uploadScaleStart(t)},uploadScaleMove:function(t){this.handwriting.uploadScaleMove(t)},uploadScaleEnd:function(t){this.handwriting.uploadScaleEnd(t)},subCanvas:function(){var t=this;this.handwriting.saveCanvas().then((function(e){t.showimg=e,console.log(e),t.$api.worksheet_baseimg({staff_num:uni.getStorageSync("user").staff_num,base_img:e}).then((function(t){uni.showToast({icon:"none",title:"保存成功"}),setTimeout((function(){uni.navigateBack()}),1500),console.log(t)}))})).catch((function(t){console.log(t)}))}}};e.default=s},"0a3a":function(t,e,i){"use strict";i("7a82");var n=i("4ea4").default;Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,i("ac1f"),i("3c65"),i("14d9"),i("acd8"),i("cb29"),i("d3b7");var a=n(i("d4ec")),s=n(i("bee2")),c=n(i("ade3")),o=function(){function t(e){(0,a.default)(this,t),(0,c.default)(this,"ctx",""),(0,c.default)(this,"canvasWidth",300),(0,c.default)(this,"canvasHeight",900),(0,c.default)(this,"linePrack",[]),(0,c.default)(this,"currentLine",[]),(0,c.default)(this,"transparent",1),(0,c.default)(this,"pressure",.5),(0,c.default)(this,"smoothness",100),(0,c.default)(this,"lineSize",1.5),(0,c.default)(this,"lineMin",.5),(0,c.default)(this,"lineMax",2),(0,c.default)(this,"currentPoint",{}),(0,c.default)(this,"firstTouch",!0),(0,c.default)(this,"radius",1),(0,c.default)(this,"cutArea",{top:0,right:0,bottom:0,left:0}),(0,c.default)(this,"lastPoint",0),(0,c.default)(this,"chirography",[]),(0,c.default)(this,"startY",0),(0,c.default)(this,"deltaY",0),(0,c.default)(this,"startValue",0),console.log(e),this.lineColor=e.lineColor||"#1A1A1A",this.slideValue=e.slideValue||50,this.canvasName=e.canvasName||"handWriting",this.init()}return(0,s.default)(t,[{key:"init",value:function(){var t=this;this.ctx=uni.createCanvasContext(this.canvasName);var e=uni.createSelectorQuery();e.select(".handCenter").boundingClientRect((function(e){console.log(e),t.canvasWidth=e.width,t.canvasHeight=e.height})).exec(),this.selectSlideValue(this.slideValue)}},{key:"uploadScaleStart",value:function(t){console.log("start");var e=t.mp;if(console.log(e.touches[0]),"touchstart"!=e.type)return!1;this.ctx.setFillStyle(this.lineColor),this.ctx.setGlobalAlpha(this.transparent),this.currentPoint={x:e.touches[0].x,y:e.touches[0].y},this.currentLine.unshift({time:(new Date).getTime(),dis:0,x:this.currentPoint.x,y:this.currentPoint.y}),this.firstTouch&&(this.cutArea={top:this.currentPoint.y,right:this.currentPoint.x,bottom:this.currentPoint.y,left:this.currentPoint.x},this.firstTouch=!1),this.pointToLine(this.currentLine)}},{key:"uploadScaleMove",value:function(t){console.log("move");var e=t.mp;if("touchmove"!=e.type)return!1;e.cancelable&&(e.defaultPrevented||e.preventDefault());var i={x:e.touches[0].x,y:e.touches[0].y};i.y<this.cutArea.top&&(this.cutArea.top=i.y),i.y<0&&(this.cutArea.top=0),i.x>this.cutArea.right&&(this.cutArea.right=i.x),this.canvasWidth-i.x<=0&&(this.cutArea.right=this.canvasWidth),i.y>this.cutArea.bottom&&(this.cutArea.bottom=i.y),this.canvasHeight-i.y<=0&&(this.cutArea.bottom=this.canvasHeight),i.x<this.cutArea.left&&(this.cutArea.left=i.x),i.x<0&&(this.cutArea.left=0),this.lastPoint=this.currentPoint,this.currentPoint=i,this.currentLine.unshift({time:(new Date).getTime(),dis:this.distance(this.currentPoint,this.lastPoint,"move"),x:i.x,y:i.y}),this.pointToLine(this.currentLine)}},{key:"uploadScaleEnd",value:function(t){var e=t.mp;if("touchend"!=e.type)return 0;console.log(e);var i={x:e.changedTouches[0].x,y:e.changedTouches[0].y};if(this.lastPoint=this.currentPoint,this.currentPoint=i,this.currentLine.unshift({time:(new Date).getTime(),dis:this.distance(this.currentPoint,this.lastPoint,"end"),x:i.x,y:i.y}),this.currentLine.length>2)this.currentLine[0].time,this.currentLine[this.currentLine.length-1].time,this.currentLine.length;this.pointToLine(this.currentLine);var n={lineSize:this.lineSize,lineColor:this.lineColor};this.chirography.unshift(n),this.linePrack.unshift(this.currentLine),this.currentLine=[]}},{key:"retDraw",value:function(){this.ctx.clearRect(0,0,700,730),this.ctx.draw()}},{key:"pointToLine",value:function(t){this.calcBethelLine(t)}},{key:"calcBethelLine",value:function(t){if(t.length<=1)t[0].r=this.radius;else{var e,i,n,a,s,c,o,r,l,h,u=0,d=0;t.length<=2?(e=t[1].x,a=t[1].y,n=t[1].x+.5*(t[0].x-t[1].x),c=t[1].y+.5*(t[0].y-t[1].y),i=e+.5*(n-e),s=a+.5*(c-a)):(e=t[2].x+.5*(t[1].x-t[2].x),a=t[2].y+.5*(t[1].y-t[2].y),i=t[1].x,s=t[1].y,n=i+.5*(t[0].x-i),c=s+.5*(t[0].y-s)),l=this.distance({x:n,y:c},{x:e,y:a},"calc"),h=this.radius;for(var f=0;f<t.length-1;f++)if(u+=t[f].dis,d+=t[f].time-t[f+1].time,u>this.smoothness)break;this.radius=Math.min(d/l*this.pressure+this.lineMin,this.lineMax)*this.lineSize,t[0].r=this.radius,t.length<=2?(o=(h+this.radius)/2,r=o,r):(o=(t[2].r+t[1].r)/2,r=t[1].r,(t[1].r+t[0].r)/2);for(var v=[],x=0;x<5;x++){var y=x/4,g=(1-y)*(1-y)*e+2*y*(1-y)*i+y*y*n,p=(1-y)*(1-y)*a+2*y*(1-y)*s+y*y*c,b=h+(this.radius-h)/5*x;if(v.push({x:g,y:p,r:b}),3==v.length){var m=this.ctaCalc(v[0].x,v[0].y,v[0].r,v[1].x,v[1].y,v[1].r,v[2].x,v[2].y,v[2].r);m[0].color=this.lineColor,this.bethelDraw(m,1),v=[{x:g,y:p,r:b}]}}}}},{key:"distance",value:function(t,e,i){var n=e.x-t.x,a=e.y-t.y;return 5*Math.sqrt(n*n+a*a)}},{key:"ctaCalc",value:function(t,e,i,n,a,s,c,o,r){var l,h,u,d,f,v,x,y,g,p=[];l=n-t,h=a-e,u=2*Math.sqrt(l*l+h*h+1e-4),l=l/u*i,h=h/u*i,d=h,f=-l,v=n-c,x=a-o,u=2*Math.sqrt(v*v+x*x+1e-4),v=v/u*r,x=x/u*r,y=-x,g=v,p.push({mx:t+d,my:e+f,color:"#1A1A1A"}),p.push({c1x:n+d,c1y:a+f,c2x:n+y,c2y:a+g,ex:c+y,ey:o+g}),p.push({c1x:c+y-v,c1y:o+g-x,c2x:c-y-v,c2y:o-g-x,ex:c-y,ey:o-g}),p.push({c1x:n-y,c1y:a-g,c2x:n-d,c2y:a-f,ex:t-d,ey:e-f}),p.push({c1x:t-d-l,c1y:e-f-h,c2x:t+d-l,c2y:e+f-h,ex:t+d,ey:e+f}),p[0].mx=p[0].mx.toFixed(1),p[0].mx=parseFloat(p[0].mx),p[0].my=p[0].my.toFixed(1),p[0].my=parseFloat(p[0].my);for(var b=1;b<p.length;b++)p[b].c1x=p[b].c1x.toFixed(1),p[b].c1x=parseFloat(p[b].c1x),p[b].c1y=p[b].c1y.toFixed(1),p[b].c1y=parseFloat(p[b].c1y),p[b].c2x=p[b].c2x.toFixed(1),p[b].c2x=parseFloat(p[b].c2x),p[b].c2y=p[b].c2y.toFixed(1),p[b].c2y=parseFloat(p[b].c2y),p[b].ex=p[b].ex.toFixed(1),p[b].ex=parseFloat(p[b].ex),p[b].ey=p[b].ey.toFixed(1),p[b].ey=parseFloat(p[b].ey);return p}},{key:"bethelDraw",value:function(t,e,i){this.ctx.beginPath(),this.ctx.moveTo(t[0].mx,t[0].my),void 0!=i?(this.ctx.setFillStyle(i),this.ctx.setStrokeStyle(i)):(this.ctx.setFillStyle(t[0].color),this.ctx.setStrokeStyle(t[0].color));for(var n=1;n<t.length;n++)this.ctx.bezierCurveTo(t[n].c1x,t[n].c1y,t[n].c2x,t[n].c2y,t[n].ex,t[n].ey);this.ctx.stroke(),void 0!=e&&this.ctx.fill(),this.ctx.draw(!0)}},{key:"selectColorEvent",value:function(t){this.lineColor=t}},{key:"selectSlideValue",value:function(t){switch(t){case 0:this.lineSize=.1,this.lineMin=.1,this.lineMax=.1;break;case 25:this.lineSize=1,this.lineMin=.5,this.lineMax=2;break;case 50:this.lineSize=1.5,this.lineMin=1,this.lineMax=3;break;case 75:this.lineSize=1.5,this.lineMin=2,this.lineMax=3.5;break;case 100:this.lineSize=3,this.lineMin=2,this.lineMax=3.5;break}}},{key:"saveCanvas",value:function(){var t=this;return new Promise((function(e,i){uni.canvasToTempFilePath({canvasId:t.canvasName,success:function(t){e(t.tempFilePath)},fail:function(t){console.log("图片生成失败:"+t),i(t)}})}))}}]),t}(),r=o;e.default=r},"11b7":function(t,e,i){var n=i("e7c8");n.__esModule&&(n=n.default),"string"===typeof n&&(n=[[t.i,n,""]]),n.locals&&(t.exports=n.locals);var a=i("4f06").default;a("40f00e8a",n,!0,{sourceMap:!1,shadowMode:!1})},"1d5f":function(t,e,i){"use strict";var n=i("11b7"),a=i.n(n);a.a},3256:function(t,e,i){"use strict";i.r(e);var n=i("cfc0"),a=i("9cef");for(var s in a)["default"].indexOf(s)<0&&function(t){i.d(e,t,(function(){return a[t]}))}(s);i("1d5f");var c=i("f0c5"),o=Object(c["a"])(a["default"],n["b"],n["c"],!1,null,"2dbf474c",null,!1,n["a"],void 0);e["default"]=o.exports},"9cef":function(t,e,i){"use strict";i.r(e);var n=i("0485"),a=i.n(n);for(var s in n)["default"].indexOf(s)<0&&function(t){i.d(e,t,(function(){return n[t]}))}(s);e["default"]=a.a},cb29:function(t,e,i){var n=i("23e7"),a=i("81d5"),s=i("44d2");n({target:"Array",proto:!0},{fill:a}),s("fill")},cfc0:function(t,e,i){"use strict";i.d(e,"b",(function(){return n})),i.d(e,"c",(function(){return a})),i.d(e,"a",(function(){}));var n=function(){var t=this,e=t.$createElement,i=t._self._c||e;return i("v-uni-view",{staticClass:"wrapper"},[i("v-uni-view",{staticClass:"handRight"}),i("v-uni-view",{staticClass:"handBtn"},[i("v-uni-view",{staticClass:"slide-wrapper"},[i("v-uni-text",[t._v("选择粗细")]),i("v-uni-slider",{staticClass:"slider",attrs:{value:"25","show-value":!0,step:"25"},on:{change:function(e){arguments[0]=e=t.$handleEvent(e),t.updateValue.apply(void 0,arguments)}}})],1)],1),i("v-uni-view",{staticClass:"handCenter"},[i("v-uni-canvas",{staticClass:"handWriting",attrs:{"disable-scroll":"true","canvas-id":"handWriting"},on:{touchstart:function(e){arguments[0]=e=t.$handleEvent(e),t.uploadScaleStart.apply(void 0,arguments)},touchmove:function(e){arguments[0]=e=t.$handleEvent(e),t.uploadScaleMove.apply(void 0,arguments)},touchend:function(e){arguments[0]=e=t.$handleEvent(e),t.uploadScaleEnd.apply(void 0,arguments)},click:function(e){arguments[0]=e=t.$handleEvent(e),t.mouseDown.apply(void 0,arguments)}}})],1),i("v-uni-view",{staticClass:"showimg"},[t.showimg?i("v-uni-image",{attrs:{src:t.showimg,mode:""}}):i("v-uni-text",[t._v("图片展示")])],1),i("v-uni-view",{staticClass:"buttons"},[i("v-uni-button",{staticClass:"delBtn",on:{click:function(e){arguments[0]=e=t.$handleEvent(e),t.retDraw.apply(void 0,arguments)}}},[t._v("重写")]),i("v-uni-button",{staticClass:"subBtn",on:{click:function(e){arguments[0]=e=t.$handleEvent(e),t.subCanvas.apply(void 0,arguments)}}},[t._v("保存")])],1)],1)},a=[]},e7c8:function(t,e,i){var n=i("24fb");e=n(!1),e.push([t.i,"uni-view[data-v-2dbf474c]{display:flex}.wrapper[data-v-2dbf474c]{width:100%;height:100%;margin:%?30?% 0;overflow:hidden;display:flex;align-content:center;flex-direction:column;justify-content:center;font-size:%?28?%}.handWriting[data-v-2dbf474c]{background:#fff;width:100%;height:%?350?%}.handRight[data-v-2dbf474c]{align-items:center}.handCenter[data-v-2dbf474c]{border:%?4?% dashed #e9e9e9;flex:5;overflow:hidden;box-sizing:border-box;width:90%;margin:0 auto}.handTitle[data-v-2dbf474c]{flex:1;color:#666;justify-content:center;font-size:%?30?%}.handBtn[data-v-2dbf474c]{flex-direction:column;padding:%?40?% 0;width:90%;margin:0 auto}.buttons[data-v-2dbf474c]{width:100%;margin-top:%?100?%;justify-content:space-between}.buttons>uni-button[data-v-2dbf474c]{font-size:%?30?%;height:%?80?%;width:%?120?%}.delBtn[data-v-2dbf474c]{color:#666}.color[data-v-2dbf474c]{align-items:center}.color>uni-text[data-v-2dbf474c]{margin-right:%?20?%}.subBtn[data-v-2dbf474c]{background:#008ef6;color:#fff;text-align:center;justify-content:center}.black-select[data-v-2dbf474c]{width:%?60?%;height:%?60?%}.black-select.color_select[data-v-2dbf474c]{width:%?90?%;height:%?90?%}.red-select[data-v-2dbf474c]{width:%?60?%;height:%?60?%}.red-select.color_select[data-v-2dbf474c]{width:%?90?%;height:%?90?%}.slide-wrapper[data-v-2dbf474c]{align-items:center;margin-bottom:%?20?%}.slider[data-v-2dbf474c]{width:%?400?%;padding-left:%?20?%}.drop[data-v-2dbf474c]{width:%?50?%;height:%?50?%;border-radius:50%;background:#fff;position:absolute;left:%?0?%;top:%?-10?%;box-shadow:0 1px 5px #888}.slide[data-v-2dbf474c]{width:%?250?%;height:%?30?%}.showimg[data-v-2dbf474c]{border:%?4?% solid #e9e9e9;overflow:hidden;width:90%;margin:0 auto;background:#eee;height:%?350?%;margin-top:%?40?%;align-items:center;justify-content:center}.showimg>uni-image[data-v-2dbf474c]{width:100%;height:100%}.showimg>uni-text[data-v-2dbf474c]{font-size:%?40?%;color:#888}",""]),t.exports=e}}]);
|