(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-530c1a68"],{3618:function(t,e,a){var n=a("24fb");e=n(!1),e.push([t.i,"canvas[data-v-a1968bcc]{max-width:100%;display:block}",""]),t.exports=e},"55e2":function(t,e,a){var n=a("3618");n.__esModule&&(n=n.default),"string"===typeof n&&(n=[[t.i,n,""]]),n.locals&&(t.exports=n.locals);var i=a("499e").default;i("e0e1a22e",n,!0,{sourceMap:!1,shadowMode:!1})},6410:function(t,e,a){"use strict";a.r(e);var n=function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",{attrs:{id:"handwrittenEsign-esign"}},[a("c-title",{attrs:{hide:!1,text:"协议详情"}}),a("div",{staticClass:"content",domProps:{innerHTML:t._s(t.content)}}),t.loading&&0==Object.keys(t.field).length?t._e():[a("diyform",{ref:"diyform",attrs:{status:t.fieldStatus,field:t.field,thumb:t.thumb,description:t.description},on:{submit:t.submit}},[a("div")])],a("div",{staticClass:"esign-title"},[t._v("以下方框处为签名处:")]),0==t.status?[a("div",{staticClass:"sign-box"},[a("vue-esign",{ref:"esign",attrs:{height:250,isCrop:!1,lineWidth:"2",lineColor:"#000000",bgColor:"#efefef"}})],1),a("div",{staticClass:"button-box"},[a("button",{on:{click:t.handleReset}},[t._v("重写")]),a("button",{staticClass:"button-bg",on:{click:t.submitSign}},[t._v("提交")])])]:t._e(),t.status?a("img",{staticStyle:{width:"100%",padding:"0 0.875rem"},attrs:{src:t.resultImg,alt:""}}):t._e(),a("van-popup",{style:{},attrs:{round:"",position:"bottom",closeable:""},model:{value:t.showPay,callback:function(e){t.showPay=e},expression:"showPay"}},[a("div",{staticClass:"recharge_way"},[a("div",{staticClass:"pay-warn"},[a("div",{staticStyle:{"font-size":"14px",color:"#666"}},[t._v("支付金额")]),a("div",{staticClass:"money-text"},[a("em",{staticStyle:{"font-size":"16px"}},[t._v("¥")]),t._v(t._s(t.money))])]),a("ul",{staticClass:"choose_box"},t._l(t.buttons,(function(e,n){return a("li",{key:n,on:{click:function(a){return t.confirm(e.value)}}},[a("i",{staticClass:"iconfont",class:[t.btnclass(e.value)]}),t._v(" "+t._s(e.name)+"支付 ")])})),0)])])],2)},i=[],s=(a("e7e5"),a("d399")),o=(a("a4d3"),a("e01a"),a("a9e3"),a("b64b"),a("81b2"),a("0eb6"),a("b7ef"),a("8bd4"),a("c19f"),a("ace4"),a("d3b7"),a("5cc6"),a("907a"),a("9a8c"),a("a975"),a("735e"),a("c1ac"),a("d139"),a("3a7b"),a("986a"),a("1d02"),a("d5d6"),a("82f8"),a("e91f"),a("60bd"),a("5f96"),a("3280"),a("3fcc"),a("ca91"),a("25a1"),a("cd26"),a("3c5d"),a("2954"),a("649e"),a("219c"),a("170b"),a("b39a"),a("6ce5"),a("2834"),a("72f7"),a("4ea1"),function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("canvas",{ref:"canvas",on:{mousedown:t.mouseDown,mousemove:t.mouseMove,mouseup:t.mouseUp,touchstart:t.touchStart,touchmove:t.touchMove,touchend:t.touchEnd}})}),r=[],c=a("2909"),d=(a("14d9"),{props:{width:{type:Number,default:800},height:{type:Number,default:300},lineWidth:{type:Number,default:4},lineColor:{type:String,default:"#000000"},bgColor:{type:String,default:""},isCrop:{type:Boolean,default:!1},isClearBgColor:{type:Boolean,default:!0},format:{type:String,default:"image/png"},quality:{type:Number,default:1}},data:function(){return{hasDrew:!1,resultImg:"",points:[],canvasTxt:null,startX:0,startY:0,isDrawing:!1,sratio:1}},computed:{ratio:function(){return this.height/this.width},stageInfo:function(){return this.$refs.canvas.getBoundingClientRect()},myBg:function(){return this.bgColor?this.bgColor:"rgba(255, 255, 255, 0)"}},watch:{myBg:function(t){this.$refs.canvas.style.background=t}},beforeMount:function(){window.addEventListener("resize",this.$_resizeHandler)},beforeDestroy:function(){window.removeEventListener("resize",this.$_resizeHandler)},mounted:function(){var t=this,e=this.$refs.canvas;e.height=this.height,e.width=this.width,e.style.background=this.myBg,this.$_resizeHandler(),document.onmouseup=function(){t.isDrawing=!1}},methods:{$_resizeHandler:function(){var t=this.$refs.canvas;t.style.width=this.width+"px";var e=parseFloat(window.getComputedStyle(t).width);t.style.height=this.ratio*e+"px",this.canvasTxt=t.getContext("2d"),this.canvasTxt.scale(1*this.sratio,1*this.sratio),this.sratio=e/this.width,this.canvasTxt.scale(1/this.sratio,1/this.sratio)},mouseDown:function(t){t=t||event,t.preventDefault(),this.isDrawing=!0,this.hasDrew=!0;var e={x:t.offsetX,y:t.offsetY};this.drawStart(e)},mouseMove:function(t){if(t=t||event,t.preventDefault(),this.isDrawing){var e={x:t.offsetX,y:t.offsetY};this.drawMove(e)}},mouseUp:function(t){t=t||event,t.preventDefault();var e={x:t.offsetX,y:t.offsetY};this.drawEnd(e),this.isDrawing=!1},touchStart:function(t){if(t=t||event,t.preventDefault(),this.hasDrew=!0,1===t.touches.length){var e={x:t.targetTouches[0].clientX-this.$refs.canvas.getBoundingClientRect().left,y:t.targetTouches[0].clientY-this.$refs.canvas.getBoundingClientRect().top};this.drawStart(e)}},touchMove:function(t){if(t=t||event,t.preventDefault(),1===t.touches.length){var e={x:t.targetTouches[0].clientX-this.$refs.canvas.getBoundingClientRect().left,y:t.targetTouches[0].clientY-this.$refs.canvas.getBoundingClientRect().top};this.drawMove(e)}},touchEnd:function(t){if(t=t||event,t.preventDefault(),1===t.touches.length){var e={x:t.targetTouches[0].clientX-this.$refs.canvas.getBoundingClientRect().left,y:t.targetTouches[0].clientY-this.$refs.canvas.getBoundingClientRect().top};this.drawEnd(e)}},drawStart:function(t){this.startX=t.x,this.startY=t.y,this.canvasTxt.beginPath(),this.canvasTxt.moveTo(this.startX,this.startY),this.canvasTxt.lineTo(t.x,t.y),this.canvasTxt.lineCap="round",this.canvasTxt.lineJoin="round",this.canvasTxt.lineWidth=this.lineWidth*this.sratio,this.canvasTxt.stroke(),this.canvasTxt.closePath(),this.points.push(t)},drawMove:function(t){this.canvasTxt.beginPath(),this.canvasTxt.moveTo(this.startX,this.startY),this.canvasTxt.lineTo(t.x,t.y),this.canvasTxt.strokeStyle=this.lineColor,this.canvasTxt.lineWidth=this.lineWidth*this.sratio,this.canvasTxt.lineCap="round",this.canvasTxt.lineJoin="round",this.canvasTxt.stroke(),this.canvasTxt.closePath(),this.startY=t.y,this.startX=t.x,this.points.push(t)},drawEnd:function(t){this.canvasTxt.beginPath(),this.canvasTxt.moveTo(this.startX,this.startY),this.canvasTxt.lineTo(t.x,t.y),this.canvasTxt.lineCap="round",this.canvasTxt.lineJoin="round",this.canvasTxt.stroke(),this.canvasTxt.closePath(),this.points.push(t),this.points.push({x:-1,y:-1})},generate:function(t){var e=this,a=t&&t.format?t.format:this.format,n=t&&t.quality?t.quality:this.quality,i=new Promise((function(t,i){if(e.hasDrew){var s=e.canvasTxt.getImageData(0,0,e.$refs.canvas.width,e.$refs.canvas.height);e.canvasTxt.globalCompositeOperation="destination-over",e.canvasTxt.fillStyle=e.myBg,e.canvasTxt.fillRect(0,0,e.$refs.canvas.width,e.$refs.canvas.height),e.resultImg=e.$refs.canvas.toDataURL(a,n);var o=e.resultImg;if(e.canvasTxt.clearRect(0,0,e.$refs.canvas.width,e.$refs.canvas.height),e.canvasTxt.putImageData(s,0,0),e.canvasTxt.globalCompositeOperation="source-over",e.isCrop){var r,d=e.getCropArea(s.data),l=document.createElement("canvas"),h=l.getContext("2d");l.width=d[2]-d[0],l.height=d[3]-d[1];var u=(r=e.canvasTxt).getImageData.apply(r,Object(c["a"])(d));h.globalCompositeOperation="destination-over",h.putImageData(u,0,0),h.fillStyle=e.myBg,h.fillRect(0,0,l.width,l.height),o=l.toDataURL(a,n),l=null}t(o)}else i("Warning: Not Signned!")}));return i},reset:function(){this.canvasTxt.clearRect(0,0,this.$refs.canvas.width,this.$refs.canvas.height),this.isClearBgColor&&(this.$emit("update:bgColor",""),this.$refs.canvas.style.background="rgba(255, 255, 255, 0)"),this.points=[],this.hasDrew=!1,this.resultImg=""},getCropArea:function(t){for(var e=this.$refs.canvas.width,a=0,n=this.$refs.canvas.height,i=0,s=0;s0||t[r+1]>0||t[r+2]||t[r+3]>0)&&(i=Math.max(o,i),a=Math.max(s,a),n=Math.min(o,n),e=Math.min(s,e))}e++,a++,n++,i++;var c=[e,n,a,i];return c}}}),l=d,h=(a("91fa"),a("2877")),u=Object(h["a"])(l,o,r,!1,null,"a1968bcc",null),f=u.exports;f.install=function(t){this.installed||(this.installed=!0,t.component("vueEsign",f))};var g=f,v=a("dca4"),m=a("ace1"),p={mixins:[v["a"]],data:function(){return{status:1,resultImg:"",content:null,buttons:[],pay_type:null,showPay:!1,money:"",ordersn:"",loading:!0,fieldStatus:0,field:[],form_data:null,thumb:"",description:""}},created:function(){this.getData()},components:{diyform:m["a"],vueEsign:g},computed:{},mounted:function(){},methods:{getData:function(){var t=this;this.resultImg=null,$http.get("plugin.hand-sign-protocol.frontend.controllers.protocol.getDetail",{id:this.$route.params.id},".").then((function(e){1==e.result?(t.content=e.data.protocol.content,t.money=e.data.protocol.amount,t.status=e.data.protocol.sign_status,e.data.protocol.sign_status&&(t.resultImg=e.data.protocol.img_url),t.loading=!1,t.fieldStatus=e.data.form.status,t.field=e.data.form.fields,t.thumb=e.data.form.thumb||null,t.description=e.data.form.description||null):t.$toast(e.msg)})).catch((function(t){}))},getPayButton:function(){var t=this;$http.get("plugin.hand-sign-protocol.frontend.controllers.protocol.getButtons",{id:this.$route.params.id}).then((function(e){if(1==e.result){if(0==Number(t.money))return void t.confirm(54);t.buttons=e.data.buttons,t.showPay=!0}else t.$toast(e.msg)})).catch((function(t){}))},btnclass:function(t){return 1==t||6==t||9==t||12==t||20==t||22==t||48==t?"icon-balance_i":2==t||10==t||49==t||52==t?"icon-balance_j":18==t?"icon-balance_d":19==t?"icon-balance_g":"icon-balance_h"},confirm:function(t){var e=this;this.pay_type=t;var a="plugin.hand-sign-protocol.frontend.controllers.protocol.pay";window.isMiniprogram&&(a+="&client_type=2&app_type=wechat"),this.showPay=!1,this.resultImg?$http.post(a,{pay_type:this.pay_type,img_url:this.resultImg,id:this.$route.params.id,form_data:this.form_data},"正在充值").then((function(a){if(1==a.result){if(3==t)return e.$toast("支付成功"),void e.getData();if(a.data&&e.fun.isTextEmpty(a.data.order_sn))return e.$dialog.alert({message:"参数错误"}),!1;if(e.ordersn=a.data.order_sn,54==e.pay_type)return void(a.data.line?window.location.href=a.data.line:e.getData());e.rechargePay(e.pay_type,a,e.ordersn,"handSign")}else e.$dialog.alert({message:a.msg})})):this.$toast("您还没签名,请签名后再进行提交")},handleReset:function(){this.$refs.esign.reset()},submitSign:function(){0==Object.keys(this.field).length?this.handleGenerate():this.$refs.diyform.submit()},submit:function(t){t&&(this.form_data=t),this.handleGenerate()},handleGenerate:function(){var t=this;this.$refs.esign.generate().then((function(e){t.buttons.length>0&&t.resultImg?t.showPay=!0:t.onRead_1(e)})).catch((function(e){t.$dialog.alert({message:"您还没签名,请签名后再进行提交"})}))},onRead_1:function(t){var e=this;s["a"].loading({message:"上传中",forbidClick:!0});var a=new FormData;a.append("file",a.append("file",this.dataURItoBlob(t))),axios.post(this.fun.getRealUrl("upload.uploadPic"),a,{headers:{"Content-Type":"multipart/form-data"}}).then((function(t){var a=t.data;1===a.result?(s["a"].clear(),e.resultImg=a.data.img,e.getPayButton()):(s["a"].clear(),Object(s["a"])(a.msg))})).catch((function(t){s["a"].clear()}))},dataURItoBlob:function(t){for(var e=atob(t.split(",")[1]),a=t.split(",")[0].split(":")[1].split(";")[0],n=new ArrayBuffer(e.length),i=new Uint8Array(n),s=0;s