pages-my-avatar-avatar.514d7d52.js 14 KB

1
  1. (window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["pages-my-avatar-avatar"],{2643:function(t,i,e){"use strict";e.r(i);var a=e("e665"),n=e.n(a);for(var o in a)["default"].indexOf(o)<0&&function(t){e.d(i,t,(function(){return a[t]}))}(o);i["default"]=n.a},"61b5":function(t,i,e){"use strict";var a=e("d04e"),n=e.n(a);n.a},"6d12":function(t,i,e){"use strict";e.d(i,"b",(function(){return a})),e.d(i,"c",(function(){return n})),e.d(i,"a",(function(){}));var a=function(){var t=this,i=t.$createElement,e=t._self._c||i;return e("v-uni-view",{staticClass:"body"},[e("v-uni-image",{style:{width:t.imgWidth+"px",height:t.imgHeight+"px",transform:"translate("+t.imgX+"px,"+t.imgY+"px) rotate("+t.imgRotate+"deg) scale("+t.imgScale+")","transition-duration":t.imgTransition,"transform-origin":t.imgOrigin},attrs:{id:"img",src:t.url},on:{load:function(i){arguments[0]=i=t.$handleEvent(i),t.imgLoad.apply(void 0,arguments)}}}),e("v-uni-canvas",{attrs:{id:"touch","canvas-id":"myCanvas"},on:{touchstart:function(i){arguments[0]=i=t.$handleEvent(i),t.touchstart.apply(void 0,arguments)},touchmove:function(i){arguments[0]=i=t.$handleEvent(i),t.touchmove.apply(void 0,arguments)},touchend:function(i){arguments[0]=i=t.$handleEvent(i),t.touchend.apply(void 0,arguments)}}}),e("v-uni-view",{attrs:{id:"clipArea"}},[e("v-uni-view",{staticClass:"top"}),e("v-uni-view",{staticClass:"bottom"}),e("v-uni-view",{staticClass:"left"}),e("v-uni-view",{staticClass:"right"})],1),e("v-uni-view",{attrs:{id:"bottom"}},[e("v-uni-view",{on:{click:function(i){arguments[0]=i=t.$handleEvent(i),t.jiazaiImg.apply(void 0,arguments)}}},[t._v(t._s(""===t.url?"选择图片":"重新选择"))]),e("v-uni-view",{on:{click:function(i){arguments[0]=i=t.$handleEvent(i),t.xvanzhuan.apply(void 0,arguments)}}},[t._v(t._s(t.bottomText_2))]),e("v-uni-view",{on:{click:function(i){arguments[0]=i=t.$handleEvent(i),t.yulan.apply(void 0,arguments)}}},[t._v(t._s(t.bottomText_3))]),e("v-uni-view",{on:{click:function(i){arguments[0]=i=t.$handleEvent(i),t.jieqv.apply(void 0,arguments)}}},[t._v(t._s(t.bottomText_4))])],1),e("v-uni-view",{directives:[{name:"show",rawName:"v-show",value:""!==t.yulanPicSrc,expression:"yulanPicSrc !== ''"}],staticClass:"tanchuang"},[e("v-uni-view",{staticClass:"alert notitle"},[e("v-uni-view",{staticClass:"title"}),e("v-uni-view",{staticClass:"content",staticStyle:{"padding-top":"70rpx","padding-bottom":"70rpx"}},[e("v-uni-view",{staticClass:"img zheng",style:{backgroundImage:"url('"+t.yulanPicSrc+"')"}}),e("v-uni-view",{staticClass:"img yuan",style:{backgroundImage:"url('"+t.yulanPicSrc+"')"}})],1),e("v-uni-view",{staticClass:"bottom line"},[e("v-uni-view",{staticClass:"vertical_line",on:{click:function(i){arguments[0]=i=t.$handleEvent(i),t.yulanPicSrc=""}}},[t._v("确定")])],1)],1)],1)],1)},n=[]},"7c92":function(t,i,e){var a=e("24fb");i=a(!1),i.push([t.i,'.body[data-v-4e86ab32] #headNavHeight{display:none}.body[data-v-4e86ab32]{Position:relative;width:%?750?%;height:100vh}#touch[data-v-4e86ab32]{Position:absolute;top:0;left:0;z-index:2;min-width:%?750?%;min-height:100vh;opacity:0}#img.show[data-v-4e86ab32]:before{content:"旋转中";background:#fff;color:#333;font-size:%?34?%;text-align:center;display:block;height:100%;opacity:.8}#clipArea[data-v-4e86ab32]{width:%?458?%;height:%?458?%;Position:absolute;top:50%;left:50%;z-index:1;margin:%?-231?% 0 0 %?-231?%;background:#fff;border:1px solid #fff;background:transparent}#clipArea uni-view[data-v-4e86ab32]{Position:absolute;background:rgba(0,0,0,.25)}#clipArea .top[data-v-4e86ab32],\n#clipArea .bottom[data-v-4e86ab32]{width:200vw;height:%?2083?%;left:-100vw}#clipArea .top[data-v-4e86ab32]{top:%?-2083?%;margin-top:-1px}#clipArea .bottom[data-v-4e86ab32]{bottom:%?-2083?%;margin-bottom:-1px}#clipArea .left[data-v-4e86ab32],\n#clipArea .right[data-v-4e86ab32]{width:%?2083?%;height:%?458?%;top:-1px}#clipArea .left[data-v-4e86ab32]{left:%?-2083?%;margin-left:-1px}#clipArea .right[data-v-4e86ab32]{right:%?-2083?%;margin-right:-1px}#bottom[data-v-4e86ab32]{Position:absolute;bottom:0;z-index:3;width:%?750?%;height:%?100?%;padding:0 0 0 %?30?%;background:#fff}#bottom>uni-view[data-v-4e86ab32]{display:inline-block;color:#444;background:#fff;width:%?150?%;line-height:%?66?%;text-align:center;font-size:%?26?%;border:%?1?% solid rgba(0,0,0,.1);margin:%?17?% %?30?% 0 0}.tanchuang .content .img[data-v-4e86ab32]{width:%?200?%;height:%?200?%;margin:0 auto;background-size:100%;box-shadow:0 0 %?24?% hsla(0,0%,78.4%,.4)}.tanchuang .content .img.yuan[data-v-4e86ab32]{border-radius:500%;margin:%?75?% auto 0 auto}\n\n/* 一些全局的 */.body[data-v-4e86ab32]{overflow:hidden;color:#333}[data-v-4e86ab32]::-webkit-scrollbar{display:none}*[data-v-4e86ab32]{vertical-align:top;box-sizing:border-box}\n\n/* 绘制一条很细的线 */.line[data-v-4e86ab32],\n.vertical_line[data-v-4e86ab32]{Position:relative}.line[data-v-4e86ab32]:before{Position:absolute;left:0;bottom:0;z-index:1;content:"";width:100%;height:%?2?%;background-image:linear-gradient(180deg,transparent 0,#f1f1f1 0)}.vertical_line[data-v-4e86ab32]:after{Position:absolute;top:0;left:0;z-index:1;content:"";width:%?2?%;height:100%;background-image:linear-gradient(90deg,#f1f1f1 100%,transparent 0)}@media screen and (-webkit-min-device-pixel-ratio:2){.line[data-v-4e86ab32]:before{background-image:linear-gradient(180deg,transparent 50%,#f1f1f1 0)}.vertical_line[data-v-4e86ab32]:after{background-image:linear-gradient(90deg,#f1f1f1 50%,transparent 0)}}@media screen and (-webkit-min-device-pixel-ratio:2.5){.line[data-v-4e86ab32]:before{background-image:linear-gradient(180deg,transparent %,#f1f1f1 0)}.vertical_line[data-v-4e86ab32]:after{background-image:linear-gradient(90deg,#f1f1f1 55%,transparent 0)}}@media screen and (-webkit-min-device-pixel-ratio:3){.line[data-v-4e86ab32]:before{background-image:linear-gradient(180deg,transparent 60%,#f1f1f1 0)}.vertical_line[data-v-4e86ab32]:after{background-image:linear-gradient(90deg,#f1f1f1 60%,transparent 0)}}\n\n/* 弹窗的样式开始 */.tanchuang[data-v-4e86ab32]{width:100%;height:100vh;background:rgba(0,0,0,.3);position:fixed;top:0;left:0;z-index:900}.tanchuang>.alert[data-v-4e86ab32]{Position:absolute;top:50%;left:50%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);background:#fff;border-radius:%?14?%;text-align:center;overflow:hidden;width:%?600?%}.tanchuang>.alert .title[data-v-4e86ab32]{color:#000;padding:%?42?% %?11?% 0 %?11?%;font-weight:700;font-size:%?31?%}.tanchuang>.alert .content[data-v-4e86ab32]{display:block;color:#656565;padding:%?24?% %?54?% %?41?% %?54?%;line-height:%?38?%;font-size:%?30?%;max-height:72vh;overflow:scroll}.tanchuang>.alert .content[data-v-4e86ab32]::-webkit-scrollbar{\n\t/* 隐藏滚动条,css3属性 */display:none}\n\n/* 无标题时,改变一下 “标题” 和 “内容” 区域的内边距 */.tanchuang>.alert.notitle .title[data-v-4e86ab32]{padding:0}.tanchuang>.alert.notitle .content[data-v-4e86ab32]{padding:%?54?%}.tanchuang>.alert .bottom[data-v-4e86ab32]{display:-webkit-box;line-height:%?94?%}.tanchuang>.alert .bottom uni-view[data-v-4e86ab32]{-webkit-box-flex:1;width:100%;display:block;background:#fff;font-size:%?30?%}.tanchuang>.alert .bottom uni-view[data-v-4e86ab32]:nth-of-type(1){color:#1e90ff}.tanchuang>.alert .bottom uni-view[data-v-4e86ab32]:nth-of-type(2){color:#333}.tanchuang>.alert .bottom uni-view[data-v-4e86ab32]:active{background:#e0e0e0}.tanchuang>.alert .bottom.line[data-v-4e86ab32]:before{top:%?-2?%}',""]),t.exports=i},a722:function(t,i,e){"use strict";e.r(i);var a=e("6d12"),n=e("2643");for(var o in n)["default"].indexOf(o)<0&&function(t){e.d(i,t,(function(){return n[t]}))}(o);e("61b5");var s=e("f0c5"),r=Object(s["a"])(n["default"],a["b"],a["c"],!1,null,"4e86ab32",null,!1,a["a"],void 0);i["default"]=r.exports},d04e:function(t,i,e){var a=e("7c92");a.__esModule&&(a=a.default),"string"===typeof a&&(a=[[t.i,a,""]]),a.locals&&(t.exports=a.locals);var n=e("4f06").default;n("7e01473a",a,!0,{sourceMap:!1,shadowMode:!1})},e665:function(t,i,e){"use strict";e("7a82");var a=e("4ea4").default;Object.defineProperty(i,"__esModule",{value:!0}),i.default=void 0;var n=a(e("3835"));e("c975"),e("e25e"),e("ac1f");var o,s,r,h,c,d,u,l,g,m,f,v,b,p,x=0,w=-1===navigator.userAgent.indexOf("Mobile"),y={data:function(){return{imgX:0,imgY:0,imgWidth:0,imgHeight:0,imgTransition:"0ms",imgScale:1,imgOrigin:"",imgRotate:0,bottomText_2:"旋转",bottomText_3:"预览",bottomText_4:"上传",url:"../../static/i/touxiang/212.jpg",yulanPicSrc:"",pixelRatio:1,bodyLeftWidth:0}},methods:{X_AND_Y:function(){return[o,r]},widht_AND_height:function(){var t,i;return b<p?(t=c,i=p/(b/c)):(t=b/(p/d),i=d),[t,i]},imgLoad:function(t){b=t.detail.width,p=t.detail.height;var i=this.widht_AND_height(),e=(0,n.default)(i,2);this.imgWidth=e[0],this.imgHeight=e[1];var a=this.X_AND_Y(),o=(0,n.default)(a,2);this.imgX=o[0],this.imgY=o[1];var s=Math.min(this.imgWidth,this.imgHeight)/2;this.imgOrigin=s+"px "+s+"px"},upData:function(t){!0===w||1===t.touches.length?(!0===w?(u=t.y,l=t.x):(u=t.touches[0].y,l=t.touches[0].x),f=this.imgY,v=this.imgX,m=this.imgScale):2===t.touches.length&&(g=t.touches)},touchstart:function(t){"旋转"===this.bottomText_2&&(this.imgTransition="50ms",this.upData(t))},touchmove:function(t){if(void 0!==u)if(!0===w||1===t.touches.length){var i=this.imgWidht_AND_imgHeight(),e=(0,n.default)(i,2),a=e[0],o=e[1],s=a<=c?.5:1,r=o<=d?.5:1;this.imgY=((w?t.y:t.touches[0].y)-u)*r+f,this.imgX=((w?t.x:t.touches[0].x)-l)*s+v}else if(2===t.touches.length){var h=m*(this.getDistance(t.touches[0],t.touches[1])/this.getDistance(g[0],g[1]));h>.4&&h<5&&(this.imgScale=h)}},touchend:function(t){!0!==w&&0!==t.touches.length||(u=void 0,this.imgScale<1&&(this.imgScale=1),this.huitan()),this.upData(t)},imgWidht_AND_imgHeight:function(){return[([0,180].indexOf(x)>-1?this.imgWidth:this.imgHeight)*this.imgScale,([0,180].indexOf(x)>-1?this.imgHeight:this.imgWidth)*this.imgScale]},imgLeft_AND_imgTop:function(t,i){var e=this.imgX,a=this.imgY;return this.imgWidth<this.imgHeight?90===x?e=e+i-t:180===x&&(a=a+t-i):this.imgHeight<this.imgWidth&&(180===x?e=e-t+i:270===x&&(a=a-i+t)),e-=Math.min(this.imgWidth,this.imgHeight)/2*(this.imgScale-1),a-=Math.min(this.imgWidth,this.imgHeight)/2*(this.imgScale-1),[e,a]},huitan:function(){this.imgTransition="400ms";var t=this.imgWidht_AND_imgHeight(),i=(0,n.default)(t,2),e=i[0],a=i[1],c=this.imgLeft_AND_imgTop(e,a),d=(0,n.default)(c,2),u=d[0],l=d[1],g=u+e,m=l+a;if(o<u){var f=o;this.imgWidth>this.imgHeight?180===x&&(f+=e-a):90===x&&(f-=a-e)}else if(g<s){f=s;this.imgWidth>this.imgHeight?f-=180===x?a:e:f-=90===x?a:e}if(r<l){var v=r;this.imgWidth>this.imgHeight?v+=270===x?a-e:0:v+=180===x?a-e:0}else if(m<h){v=h;this.imgWidth>this.imgHeight?v-=270===x?e:a:v-=180===x?e:a}"number"===typeof f&&(this.imgX=f+Math.min(this.imgWidth,this.imgHeight)*(this.imgScale-1)/2),"number"===typeof v&&(this.imgY=v+Math.min(this.imgWidth,this.imgHeight)*(this.imgScale-1)/2)},getDistance:function(t,i){var e=t.x-i.x,a=t.y-i.y;return Math.sqrt(e*e+a*a)},jiazaiImg:function(){var t=this;uni.chooseImage({count:1,sizeType:["compressed"],sourceType:["album","camera"],success:function(i){t.url=i.tempFilePaths[0],x=t.imgRotate=0}})},jieqv:function(){""===this.url?this.jiazaiImg():"截取中..."===this.bottomText_4?uni.showToast({title:"截取中,请稍等",icon:"none",duration:1500}):"上传中..."===this.bottomText_4?uni.showToast({title:"上传中,请稍等",icon:"none",duration:1500}):"旋转中..."===this.bottomText_2?uni.showToast({title:"旋转中,请稍等",icon:"none",duration:1e3}):(this.bottomText_4="截取中...",this.jieqvTobase64("base64UP"))},base64UP:function(t){var i=this;this.bottomText_4="上传中...",uni.request({method:"POST",dataType:"json",timeout:1e4,url:"/ajax/mine/touxiang.php",data:{img:t},header:{"content-type":"application/x-www-form-urlencoded"},success:function(t){},complete:function(t){setTimeout((function(){uni.showToast({title:"上传成功",icon:"none",duration:2e3}),i.bottomText_4="上传"}),300)}})},getImageInClipAreaInfo:function(){var t=this.imgWidht_AND_imgHeight(),i=(0,n.default)(t,2),e=i[0],a=i[1],s=this.imgLeft_AND_imgTop(e,a),h=(0,n.default)(s,2),c=h[0],d=h[1],u=Math.min(b,p)/this.imgScale,l=o-c,g=l/e,m=([0,180].indexOf(x)>-1?b:p)*g;90===x?m=p-u-m:180===x&&(m=b-u-m);var f=r-d,v=f/a,w=([0,180].indexOf(x)>-1?p:b)*v;return 180===x?w=p-u-w:270===x&&(w=b-u-w),[0,180].indexOf(x)>-1?[m,w,u]:[w,m,u]},jieqvTobase64:function(t){var i=this,e=this.getImageInClipAreaInfo(),a=(0,n.default)(e,3),o=a[0],s=a[1],r=a[2];console.log(o),console.log(s),console.log(r);var h=uni.createCanvasContext("myCanvas");h.rotate(this.imgRotate*Math.PI/180),90===x?h.transform(1,0,0,1,0,-250*this.pixelRatio):180===x?h.transform(1,0,0,1,-250*this.pixelRatio,-250*this.pixelRatio):270===x&&h.transform(1,0,0,1,-250*this.pixelRatio,0),h.drawImage(this.url,o,s,r,r,0,0,250,250),h.draw(!1,(function(e){i.bottomText_3="预览",uni.canvasToTempFilePath({destWidth:250,destHeight:250,width:250,height:250,canvasId:"myCanvas",fileType:"jpg",quality:.7,success:function(e){i[t](e.tempFilePath)}})}))},xvanzhuan:function(){var t=this;if(""===this.url)this.jiazaiImg();else if("旋转"===this.bottomText_2){this.bottomText_2="旋转中...",this.imgTransition="400ms";var i=this.X_AND_Y(),e=(0,n.default)(i,2);this.imgX=e[0],this.imgY=e[1],this.imgScale=1,this.imgRotate+=90,x=this.imgRotate-360*parseInt(this.imgRotate/360),setTimeout((function(){t.bottomText_2="旋转"}),400)}},yulan:function(){""===this.url?this.jiazaiImg():"截取中..."===this.bottomText_3?uni.showToast({title:"截取中,请稍等",icon:"none",duration:1500}):"旋转中..."===this.bottomText_2?uni.showToast({title:"旋转中,请稍等",icon:"none",duration:1e3}):(this.bottomText_3="截取中...",this.jieqvTobase64("yulanAlert"))},yulanAlert:function(t){this.bottomText_3="预览",this.yulanPicSrc=t}},onReady:function(){var t=this;uni.getSystemInfo({success:function(i){t.bodyLeftWidth=(i.windowWidth-uni.upx2px(750))/2,t.pixelRatio=i.pixelRatio,uni.createSelectorQuery().select("#clipArea").boundingClientRect((function(i){c=i.width-2,d=i.height-2,o=i.left+1-t.bodyLeftWidth,s=i.right-1-t.bodyLeftWidth,r=i.top+1,h=i.bottom-1})).exec()}}),!0===w&&(document.querySelector("#touch").addEventListener("mousedown",(function(i){document.querySelector("body").addEventListener("mousemove",t.touchmove),t.touchstart(i)})),document.querySelector("body").addEventListener("mouseup",(function(i){document.querySelector("body").removeEventListener("mousemove",t.touchmove),t.touchend(i)})))},onBackPress:function(t){if(""!==this.yulanPicSrc)return this.yulanPicSrc="",!0}};i.default=y}}]);