interview.js 11 KB

12
  1. (global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["pagesA/pages/interview/interview"],{371:function(t,e,n){"use strict";(function(t,e){var i=n(4);n(26);i(n(25));var a=i(n(372));t.__webpack_require_UNI_MP_PLUGIN__=n,e(a.default)}).call(this,n(1)["default"],n(2)["createPage"])},372:function(t,e,n){"use strict";n.r(e);var i=n(373),a=n(375);for(var s in a)["default"].indexOf(s)<0&&function(t){n.d(e,t,(function(){return a[t]}))}(s);n(377);var o,c=n(32),r=Object(c["default"])(a["default"],i["render"],i["staticRenderFns"],!1,null,"1a6954b8",null,!1,i["components"],o);r.options.__file="pagesA/pages/interview/interview.vue",e["default"]=r.exports},373:function(t,e,n){"use strict";n.r(e);var i=n(374);n.d(e,"render",(function(){return i["render"]})),n.d(e,"staticRenderFns",(function(){return i["staticRenderFns"]})),n.d(e,"recyclableRender",(function(){return i["recyclableRender"]})),n.d(e,"components",(function(){return i["components"]}))},374:function(t,e,n){"use strict";var i;n.r(e),n.d(e,"render",(function(){return a})),n.d(e,"staticRenderFns",(function(){return o})),n.d(e,"recyclableRender",(function(){return s})),n.d(e,"components",(function(){return i}));var a=function(){var t=this,e=t.$createElement,n=(t._self._c,t.ads.location?t._f("getWords")(t.ads.location):null);t.$mp.data=Object.assign({},{$root:{f0:n}})},s=!1,o=[];a._withStripped=!0},375:function(t,e,n){"use strict";n.r(e);var i=n(376),a=n.n(i);for(var s in i)["default"].indexOf(s)<0&&function(t){n.d(e,t,(function(){return i[t]}))}(s);e["default"]=a.a},376:function(t,e,n){"use strict";(function(t,i){Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var a=n(71),s={data:function(){return{canvasName:"handWriting",ctx:"",canvasWidth:0,canvasHeight:0,transparent:1,selectColor:"black",lineColor:"#1A1A1A",lineSize:1.5,lineMin:.5,lineMax:4,pressure:1,smoothness:60,currentPoint:{},currentLine:[],firstTouch:!0,radius:1,cutArea:{top:0,right:0,bottom:0,left:0},bethelPoint:[],lastPoint:0,chirography:[],currentChirography:{},linePrack:[],ads:{location:"",province:"",city:"",area:""},order_no:"",screenWidth:""}},filters:{getWords:function(t){return t.length>29?t.slice(0,29)+"...":t}},onLoad:function(e){var n=this;this.order_no=e.order_no,t.getSystemInfo({success:function(t){n.screenWidth=t.screenWidth}})},onShow:function(){this.getAddress()},mounted:function(){var e=this,n=this.canvasName,i=t.createCanvasContext(n);this.ctx=i;var a=t.createSelectorQuery();a.select(".handCenter").boundingClientRect((function(t){e.canvasWidth=t.width,e.canvasHeight=t.height,e.setCanvasBg("#fff")})).exec()},methods:{getAds:function(e){var n=this;(0,a.getLocation)({location:e}).then((function(e){if(200==e.code){var i=e.data.regeocode.addressComponent;n.ads.province=i.province,n.ads.city=i.district,n.ads.area=i.township,n.ads.location="".concat(i.province).concat(i.district).concat(i.township),console.log("地理位置:",n.ads.location)}else t.showToast({title:"获取位置失败",icon:"none"})}))},getAddress:function(){var e=this;t.getLocation({type:"gcj02",success:function(t){var n=t.latitude,i=t.longitude,a="".concat(i,",").concat(n);e.getAds(a)},fail:function(n){"getLocation:fail auth deny"==n.errMsg&&t.showModal({title:"是否授权当前位置",content:"取消位置授权,将影响您使用小程序,请重新开启授权",showCancel:!1,success:function(t){t.confirm&&e.openSetting()}})}})},openSetting:function(){var e=this;t.openSetting({success:function(t){t.authSetting["scope.userLocation"]&&e.getLocation()},fail:function(e){t.showModal({content:"开启位置权限失败,请手动开启",showCancel:!1})}})},uploadScaleStart:function(t){if("touchstart"!=t.type)return!1;var e=this.ctx;e.setFillStyle(this.lineColor),e.setGlobalAlpha(this.transparent);var n={x:t.touches[0].x,y:t.touches[0].y},i=this.currentLine;i.unshift({time:(new Date).getTime(),dis:0,x:n.x,y:n.y}),this.currentPoint=n,this.firstTouch&&(this.cutArea={top:n.y,right:n.x,bottom:n.y,left:n.x},this.firstTouch=!1),this.pointToLine(i)},uploadScaleMove:function(t){if("touchmove"!=t.type)return!1;t.cancelable&&(t.defaultPrevented||t.preventDefault());var e={x:t.touches[0].x,y:t.touches[0].y};e.y<this.cutArea.top&&(this.cutArea.top=e.y),e.y<0&&(this.cutArea.top=0),e.x>this.cutArea.right&&(this.cutArea.right=e.x),this.canvasWidth-e.x<=0&&(this.cutArea.right=this.canvasWidth),e.y>this.cutArea.bottom&&(this.cutArea.bottom=e.y),this.canvasHeight-e.y<=0&&(this.cutArea.bottom=this.canvasHeight),e.x<this.cutArea.left&&(this.cutArea.left=e.x),e.x<0&&(this.cutArea.left=0),this.lastPoint=this.currentPoint,this.currentPoint=e;var n=this.currentLine;n.unshift({time:(new Date).getTime(),dis:this.distance(this.currentPoint,this.lastPoint),x:e.x,y:e.y}),this.pointToLine(n)},uploadScaleEnd:function(t){if("touchend"!=t.type)return 0;var e={x:t.changedTouches[0].x,y:t.changedTouches[0].y};this.lastPoint=this.currentPoint,this.currentPoint=e;var n=this.currentLine;if(n.unshift({time:(new Date).getTime(),dis:this.distance(this.currentPoint,this.lastPoint),x:e.x,y:e.y}),n.length>2)n[0].time,n[n.length-1].time,n.length;this.pointToLine(n);var i={lineSize:this.lineSize,lineColor:this.lineColor},a=this.chirography;a.unshift(i),this.chirography=a;var s=this.linePrack;s.unshift(this.currentLine),this.linePrack=s,this.currentLine=[]},retDraw:function(){this.ctx.clearRect(0,0,700,730),this.ctx.draw(),this.setCanvasBg("#fff")},pointToLine:function(t){this.calcBethelLine(t)},calcBethelLine:function(t){if(t.length<=1)t[0].r=this.radius;else{var e,n,i,a,s,o,c,r,h,u,l=0,d=0,f=.5;t.length<=2?(e=t[1].x,a=t[1].y,i=t[1].x+(t[0].x-t[1].x)*f,o=t[1].y+(t[0].y-t[1].y)*f,n=e+(i-e)*f,s=a+(o-a)*f):(e=t[2].x+(t[1].x-t[2].x)*f,a=t[2].y+(t[1].y-t[2].y)*f,n=t[1].x,s=t[1].y,i=n+(t[0].x-n)*f,o=s+(t[0].y-s)*f),h=this.distance({x:i,y:o},{x:e,y:a}),u=this.radius;for(var y=0;y<t.length-1;y++)if(l+=t[y].dis,d+=t[y].time-t[y+1].time,l>this.smoothness)break;this.radius=Math.min(d/h*this.pressure+this.lineMin,this.lineMax)*this.lineSize,t[0].r=this.radius,t.length<=2?(c=(u+this.radius)/2,r=c,r):(c=(t[2].r+t[1].r)/2,r=t[1].r,(t[1].r+t[0].r)/2);for(var p=5,v=[],x=0;x<p;x++){var g=x/(p-1),m=(1-g)*(1-g)*e+2*g*(1-g)*n+g*g*i,w=(1-g)*(1-g)*a+2*g*(1-g)*s+g*g*o,F=u+(this.radius-u)/p*x;if(v.push({x:m,y:w,r:F}),3==v.length){var P=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);P[0].color=this.lineColor,this.bethelDraw(P,1),v=[{x:m,y:w,r:F}]}}this.currentLine=t}},distance:function(t,e){var n=e.x-t.x,i=e.y-t.y;return Math.sqrt(n*n+i*i)},ctaCalc:function(t,e,n,i,a,s,o,c,r){var h,u,l,d,f,y,p,v,x,g=[];h=i-t,u=a-e,l=2*Math.sqrt(h*h+u*u+1e-4),h=h/l*n,u=u/l*n,d=u,f=-h,y=i-o,p=a-c,l=2*Math.sqrt(y*y+p*p+1e-4),y=y/l*r,p=p/l*r,v=-p,x=y,g.push({mx:t+d,my:e+f,color:"#1A1A1A"}),g.push({c1x:i+d,c1y:a+f,c2x:i+v,c2y:a+x,ex:o+v,ey:c+x}),g.push({c1x:o+v-y,c1y:c+x-p,c2x:o-v-y,c2y:c-x-p,ex:o-v,ey:c-x}),g.push({c1x:i-v,c1y:a-x,c2x:i-d,c2y:a-f,ex:t-d,ey:e-f}),g.push({c1x:t-d-h,c1y:e-f-u,c2x:t+d-h,c2y:e+f-u,ex:t+d,ey:e+f}),g[0].mx=g[0].mx.toFixed(1),g[0].mx=parseFloat(g[0].mx),g[0].my=g[0].my.toFixed(1),g[0].my=parseFloat(g[0].my);for(var m=1;m<g.length;m++)g[m].c1x=g[m].c1x.toFixed(1),g[m].c1x=parseFloat(g[m].c1x),g[m].c1y=g[m].c1y.toFixed(1),g[m].c1y=parseFloat(g[m].c1y),g[m].c2x=g[m].c2x.toFixed(1),g[m].c2x=parseFloat(g[m].c2x),g[m].c2y=g[m].c2y.toFixed(1),g[m].c2y=parseFloat(g[m].c2y),g[m].ex=g[m].ex.toFixed(1),g[m].ex=parseFloat(g[m].ex),g[m].ey=g[m].ey.toFixed(1),g[m].ey=parseFloat(g[m].ey);return g},bethelDraw:function(t,e,n){var i=this.ctx;i.beginPath(),i.moveTo(t[0].mx,t[0].my),void 0!=n?(i.setFillStyle(n),i.setStrokeStyle(n)):(i.setFillStyle(t[0].color),i.setStrokeStyle(t[0].color));for(var a=1;a<t.length;a++)i.bezierCurveTo(t[a].c1x,t[a].c1y,t[a].c2x,t[a].c2y,t[a].ex,t[a].ey);i.stroke(),void 0!=e&&i.fill(),i.draw(!0)},selectColorEvent:function(t,e){this.selectColor=t,this.lineColor=e},canvasToImg:function(t){this.ctx.draw(!0,(function(){i.canvasToTempFilePath({canvasId:"handWriting",fileType:"png",quality:1,success:function(e){i.showToast({title:"执行了吗?"}),t(e.tempFilePath)}})}))},dataURLtoBlob:function(t){var e=t.split(","),n=e[0].match(/:(.*?);/)[1],i=atob(e[1]),a=i.length,s=new Uint8Array(a);while(a--)s[a]=i.charCodeAt(a);return new Blob([s],{type:n})},isCanvasBlank:function(t){var e=document.createElement("canvas");return e.width=t.width,e.height=t.height,t.toDataURL()==e.toDataURL()},subCanvas:function(){var e=this;if(5!=this.ctx.subpath.length)return t.showModal({content:"请先签名",showCancel:!1}),!1;t.showLoading({title:"绘制中...",mask:!0}),this.ctx.draw(!0,function(){t.canvasToTempFilePath({canvasId:"handWriting",fileType:"png",quality:1,success:function(n){t.getFileSystemManager().readFile({filePath:n.tempFilePath,encoding:"base64",success:function(n){var i="data:image/jpeg;base64,"+n.data;t.showLoading({title:"上传中...",mask:!0}),(0,a.uploadSign)({img:i}).then((function(n){if(200==n.code){var i=n.data;t.showLoading({title:"提交中...",mask:!0}),(0,a.confirmReceipt)({order_no:e.order_no,signature:i,province:e.ads.province||"",city:e.ads.city||"",area:e.ads.area||""}).then((function(e){t.hideLoading(),200==e.code?t.showModal({content:"确认收货成功",showCancel:!1,success:function(e){e.confirm&&t.reLaunch({url:"../../../pages/order-manage/order-manage?status=4"})}}):t.showModal({content:e.data||"确认收货失败",showCancel:!1})}))}else t.showModal({content:n.data||"上传失败",showCancel:!1})}))},fail:function(e){t.showModal({content:"请重试",showCancel:!1})}})},fail:function(e){t.showModal({content:"获取失败",showCancel:!1})}})}())},saveCanvasAsImg:function(){i.canvasToTempFilePath({canvasId:"handWriting",fileType:"png",quality:1,success:function(t){i.saveImageToPhotosAlbum({filePath:t.tempFilePath,success:function(t){i.showToast({title:"已保存到相册",duration:2e3})}})}})},previewCanvasImg:function(){i.canvasToTempFilePath({canvasId:"handWriting",fileType:"jpg",quality:1,success:function(t){i.previewImage({urls:[t.tempFilePath]})}})},uploadCanvasImg:function(){i.canvasToTempFilePath({canvasId:"handWriting",fileType:"png",quality:1,success:function(t){i.uploadFile({url:"https://example.weixin.qq.com/upload",filePath:t.tempFilePath,name:"file_signature",formData:{user:"test"},success:function(t){t.data}})}})},setCanvasBg:function(t){this.ctx.rect(0,0,this.canvasWidth,this.canvasHeight-4),this.ctx.setFillStyle(t),this.ctx.fill(),this.ctx.draw()}}};e.default=s}).call(this,n(2)["default"],n(1)["default"])},377:function(t,e,n){"use strict";n.r(e);var i=n(378),a=n.n(i);for(var s in i)["default"].indexOf(s)<0&&function(t){n.d(e,t,(function(){return i[t]}))}(s);e["default"]=a.a},378:function(t,e,n){}},[[371,"common/runtime","common/vendor"]]]);
  2. //# sourceMappingURL=../../../../.sourcemap/mp-weixin/pagesA/pages/interview/interview.js.map