index.8e2187c0.js 42 KB

1234567
  1. import{d as k,bt as O,bu as I,ac as W,ay as Y,bv as w,bw as A,bx as S,by as z,bz as B,c as d,e as D,o as N,bf as E,g as x,bq as $,bA as F,b4 as U,a5 as M}from"./index.332c7f08.js";import{g as R,o as j,U as P}from"./oss-file-upload.e630303f.js";import{I as T}from"./index.96a8db5e.js";const V="_uploader_jyku5_1",Q="_uploaderText_jyku5_52",q="_uploadImg_jyku5_57";var C={"uploader-section":"_uploader-section_jyku5_1","img-close":"_img-close_jyku5_9","col-uploader":"_col-uploader_jyku5_24",uploader:V,uploaderText:Q,uploadImg:q};const L={};L.getData=t=>new Promise((e,i)=>{let s={};G(t).then(o=>{s.arrayBuffer=o,s.orientation=_(o),e(s)}).catch(o=>{i(o)})});function G(t){let e=null;return new Promise((i,s)=>{if(t.src)if(/^data\:/i.test(t.src))e=Z(t.src),i(e);else if(/^blob\:/i.test(t.src)){var o=new FileReader;o.onload=function(a){e=a.target.result,i(e)},K(t.src,function(a){o.readAsArrayBuffer(a)})}else{var r=new XMLHttpRequest;r.onload=function(){if(this.status==200||this.status===0)e=r.response,i(e);else throw"Could not load image";r=null},r.open("GET",t.src,!0),r.responseType="arraybuffer",r.send(null)}else s("img error")})}function K(t,e){var i=new XMLHttpRequest;i.open("GET",t,!0),i.responseType="blob",i.onload=function(s){(this.status==200||this.status===0)&&e(this.response)},i.send()}function Z(t){t=t.replace(/^data\:([^\;]+)\;base64,/gmi,"");for(var e=atob(t),i=e.length,s=new ArrayBuffer(i),o=new Uint8Array(s),r=0;r<i;r++)o[r]=e.charCodeAt(r);return s}function J(t,e,i){var s="",o;for(o=e,i+=e;o<i;o++)s+=String.fromCharCode(t.getUint8(o));return s}function _(t){var e=new DataView(t),i=e.byteLength,s,o,r,a,h,l,c,n,p,u;if(e.getUint8(0)===255&&e.getUint8(1)===216)for(p=2;p<i;){if(e.getUint8(p)===255&&e.getUint8(p+1)===225){c=p;break}p++}if(c&&(o=c+4,r=c+10,J(e,o,4)==="Exif"&&(l=e.getUint16(r),h=l===18761,(h||l===19789)&&e.getUint16(r+2,h)===42&&(a=e.getUint32(r+4,h),a>=8&&(n=r+a)))),n){for(i=e.getUint16(n,h),u=0;u<i;u++)if(p=n+u*12+2,e.getUint16(p,h)===274){p+=8,s=e.getUint16(p,h);break}}return s}var tt=(t,e)=>{const i=t.__vccOpts||t;for(const[s,o]of e)i[s]=o;return i};const et=k({data:function(){return{w:0,h:0,scale:1,x:0,y:0,loading:!0,trueWidth:0,trueHeight:0,move:!0,moveX:0,moveY:0,crop:!1,cropping:!1,cropW:0,cropH:0,cropOldW:0,cropOldH:0,canChangeX:!1,canChangeY:!1,changeCropTypeX:1,changeCropTypeY:1,cropX:0,cropY:0,cropChangeX:0,cropChangeY:0,cropOffsertX:0,cropOffsertY:0,support:"",touches:[],touchNow:!1,rotate:0,isIos:!1,orientation:0,imgs:"",coe:.2,scaling:!1,scalingSet:"",coeStatus:"",isCanShow:!0}},props:{img:{type:[String,Blob,null,File],default:""},outputSize:{type:Number,default:1},outputType:{type:String,default:"jpeg"},info:{type:Boolean,default:!0},canScale:{type:Boolean,default:!0},autoCrop:{type:Boolean,default:!1},autoCropWidth:{type:[Number,String],default:0},autoCropHeight:{type:[Number,String],default:0},fixed:{type:Boolean,default:!1},fixedNumber:{type:Array,default:()=>[1,1]},fixedBox:{type:Boolean,default:!1},full:{type:Boolean,default:!1},canMove:{type:Boolean,default:!0},canMoveBox:{type:Boolean,default:!0},original:{type:Boolean,default:!1},centerBox:{type:Boolean,default:!1},high:{type:Boolean,default:!0},infoTrue:{type:Boolean,default:!1},maxImgSize:{type:[Number,String],default:2e3},enlarge:{type:[Number,String],default:1},preW:{type:[Number,String],default:0},mode:{type:String,default:"contain"},limitMinSize:{type:[Number,Array,String],default:()=>10}},computed:{cropInfo(){let t={};if(t.top=this.cropOffsertY>21?"-21px":"0px",t.width=this.cropW>0?this.cropW:0,t.height=this.cropH>0?this.cropH:0,this.infoTrue){let e=1;this.high&&!this.full&&(e=window.devicePixelRatio),this.enlarge!==1&!this.full&&(e=Math.abs(Number(this.enlarge))),t.width=t.width*e,t.height=t.height*e,this.full&&(t.width=t.width/this.scale,t.height=t.height/this.scale)}return t.width=t.width.toFixed(0),t.height=t.height.toFixed(0),t},isIE(){return!!window.ActiveXObject||"ActiveXObject"in window},passive(){return this.isIE?null:{passive:!1}}},watch:{img(){this.checkedImg()},imgs(t){t!==""&&this.reload()},cropW(){this.showPreview()},cropH(){this.showPreview()},cropOffsertX(){this.showPreview()},cropOffsertY(){this.showPreview()},scale(t,e){this.showPreview()},x(){this.showPreview()},y(){this.showPreview()},autoCrop(t){t&&this.goAutoCrop()},autoCropWidth(){this.autoCrop&&this.goAutoCrop()},autoCropHeight(){this.autoCrop&&this.goAutoCrop()},mode(){this.checkedImg()},rotate(){this.showPreview(),this.autoCrop?this.goAutoCrop(this.cropW,this.cropH):(this.cropW>0||this.cropH>0)&&this.goAutoCrop(this.cropW,this.cropH)}},methods:{getVersion(t){var e=navigator.userAgent.split(" "),i="";let s=0;const o=new RegExp(t,"i");for(var r=0;r<e.length;r++)o.test(e[r])&&(i=e[r]);return i?s=i.split("/")[1].split("."):s=["0","0","0"],s},checkOrientationImage(t,e,i,s){if(this.getVersion("chrome")[0]>=81)e=-1;else if(this.getVersion("safari")[0]>=605){const a=this.getVersion("version");a[0]>13&&a[1]>1&&(e=-1)}else{const a=navigator.userAgent.toLowerCase().match(/cpu iphone os (.*?) like mac os/);if(a){let h=a[1];h=h.split("_"),(h[0]>13||h[0]>=13&&h[1]>=4)&&(e=-1)}}let o=document.createElement("canvas"),r=o.getContext("2d");switch(r.save(),e){case 2:o.width=i,o.height=s,r.translate(i,0),r.scale(-1,1);break;case 3:o.width=i,o.height=s,r.translate(i/2,s/2),r.rotate(180*Math.PI/180),r.translate(-i/2,-s/2);break;case 4:o.width=i,o.height=s,r.translate(0,s),r.scale(1,-1);break;case 5:o.height=i,o.width=s,r.rotate(.5*Math.PI),r.scale(1,-1);break;case 6:o.width=s,o.height=i,r.translate(s/2,i/2),r.rotate(90*Math.PI/180),r.translate(-i/2,-s/2);break;case 7:o.height=i,o.width=s,r.rotate(.5*Math.PI),r.translate(i,-s),r.scale(-1,1);break;case 8:o.height=i,o.width=s,r.translate(s/2,i/2),r.rotate(-90*Math.PI/180),r.translate(-i/2,-s/2);break;default:o.width=i,o.height=s}r.drawImage(t,0,0,i,s),r.restore(),o.toBlob(a=>{let h=URL.createObjectURL(a);URL.revokeObjectURL(this.imgs),this.imgs=h},"image/"+this.outputType,1)},checkedImg(){if(this.img===null||this.img===""){this.imgs="",this.clearCrop();return}this.loading=!0,this.scale=1,this.rotate=0,this.clearCrop();let t=new Image;if(t.onload=()=>{if(this.img==="")return this.$emit("img-load","error"),!1;let i=t.width,s=t.height;L.getData(t).then(o=>{this.orientation=o.orientation||1;let r=Number(this.maxImgSize);if(!this.orientation&&i<r&s<r){this.imgs=this.img;return}i>r&&(s=s/i*r,i=r),s>r&&(i=i/s*r,s=r),this.checkOrientationImage(t,this.orientation,i,s)})},t.onerror=()=>{this.$emit("img-load","error")},this.img.substr(0,4)!=="data"&&(t.crossOrigin=""),this.isIE){var e=new XMLHttpRequest;e.onload=function(){var i=URL.createObjectURL(this.response);t.src=i},e.open("GET",this.img,!0),e.responseType="blob",e.send()}else t.src=this.img},startMove(t){if(t.preventDefault(),this.move&&!this.crop){if(!this.canMove)return!1;this.moveX=("clientX"in t?t.clientX:t.touches[0].clientX)-this.x,this.moveY=("clientY"in t?t.clientY:t.touches[0].clientY)-this.y,t.touches?(window.addEventListener("touchmove",this.moveImg),window.addEventListener("touchend",this.leaveImg),t.touches.length==2&&(this.touches=t.touches,window.addEventListener("touchmove",this.touchScale),window.addEventListener("touchend",this.cancelTouchScale))):(window.addEventListener("mousemove",this.moveImg),window.addEventListener("mouseup",this.leaveImg)),this.$emit("imgMoving",{moving:!0,axis:this.getImgAxis()}),this.$emit("img-moving",{moving:!0,axis:this.getImgAxis()})}else this.cropping=!0,window.addEventListener("mousemove",this.createCrop),window.addEventListener("mouseup",this.endCrop),window.addEventListener("touchmove",this.createCrop),window.addEventListener("touchend",this.endCrop),this.cropOffsertX=t.offsetX?t.offsetX:t.touches[0].pageX-this.$refs.cropper.offsetLeft,this.cropOffsertY=t.offsetY?t.offsetY:t.touches[0].pageY-this.$refs.cropper.offsetTop,this.cropX="clientX"in t?t.clientX:t.touches[0].clientX,this.cropY="clientY"in t?t.clientY:t.touches[0].clientY,this.cropChangeX=this.cropOffsertX,this.cropChangeY=this.cropOffsertY,this.cropW=0,this.cropH=0},touchScale(t){t.preventDefault();let e=this.scale;var i={x:this.touches[0].clientX,y:this.touches[0].clientY},s={x:t.touches[0].clientX,y:t.touches[0].clientY},o={x:this.touches[1].clientX,y:this.touches[1].clientY},r={x:t.touches[1].clientX,y:t.touches[1].clientY},a=Math.sqrt(Math.pow(i.x-o.x,2)+Math.pow(i.y-o.y,2)),h=Math.sqrt(Math.pow(s.x-r.x,2)+Math.pow(s.y-r.y,2)),l=h-a,c=1;c=c/this.trueWidth>c/this.trueHeight?c/this.trueHeight:c/this.trueWidth,c=c>.1?.1:c;var n=c*l;if(!this.touchNow){if(this.touchNow=!0,l>0?e+=Math.abs(n):l<0&&e>Math.abs(n)&&(e-=Math.abs(n)),this.touches=t.touches,setTimeout(()=>{this.touchNow=!1},8),!this.checkoutImgAxis(this.x,this.y,e))return!1;this.scale=e}},cancelTouchScale(t){window.removeEventListener("touchmove",this.touchScale)},moveImg(t){if(t.preventDefault(),t.touches&&t.touches.length===2)return this.touches=t.touches,window.addEventListener("touchmove",this.touchScale),window.addEventListener("touchend",this.cancelTouchScale),window.removeEventListener("touchmove",this.moveImg),!1;let e="clientX"in t?t.clientX:t.touches[0].clientX,i="clientY"in t?t.clientY:t.touches[0].clientY,s,o;s=e-this.moveX,o=i-this.moveY,this.$nextTick(()=>{if(this.centerBox){let r=this.getImgAxis(s,o,this.scale),a=this.getCropAxis(),h=this.trueHeight*this.scale,l=this.trueWidth*this.scale,c,n,p,u;switch(this.rotate){case 1:case-1:case 3:case-3:c=this.cropOffsertX-this.trueWidth*(1-this.scale)/2+(h-l)/2,n=this.cropOffsertY-this.trueHeight*(1-this.scale)/2+(l-h)/2,p=c-h+this.cropW,u=n-l+this.cropH;break;default:c=this.cropOffsertX-this.trueWidth*(1-this.scale)/2,n=this.cropOffsertY-this.trueHeight*(1-this.scale)/2,p=c-l+this.cropW,u=n-h+this.cropH;break}r.x1>=a.x1&&(s=c),r.y1>=a.y1&&(o=n),r.x2<=a.x2&&(s=p),r.y2<=a.y2&&(o=u)}this.x=s,this.y=o,this.$emit("imgMoving",{moving:!0,axis:this.getImgAxis()}),this.$emit("img-moving",{moving:!0,axis:this.getImgAxis()})})},leaveImg(t){window.removeEventListener("mousemove",this.moveImg),window.removeEventListener("touchmove",this.moveImg),window.removeEventListener("mouseup",this.leaveImg),window.removeEventListener("touchend",this.leaveImg),this.$emit("imgMoving",{moving:!1,axis:this.getImgAxis()}),this.$emit("img-moving",{moving:!1,axis:this.getImgAxis()})},scaleImg(){this.canScale&&window.addEventListener(this.support,this.changeSize,this.passive)},cancelScale(){this.canScale&&window.removeEventListener(this.support,this.changeSize)},changeSize(t){t.preventDefault();let e=this.scale;var i=t.deltaY||t.wheelDelta,s=navigator.userAgent.indexOf("Firefox");i=s>0?i*30:i,this.isIE&&(i=-i);var o=this.coe;o=o/this.trueWidth>o/this.trueHeight?o/this.trueHeight:o/this.trueWidth;var r=o*i;r<0?e+=Math.abs(r):e>Math.abs(r)&&(e-=Math.abs(r));let a=r<0?"add":"reduce";if(a!==this.coeStatus&&(this.coeStatus=a,this.coe=.2),this.scaling||(this.scalingSet=setTimeout(()=>{this.scaling=!1,this.coe=this.coe+=.01},50)),this.scaling=!0,!this.checkoutImgAxis(this.x,this.y,e))return!1;this.scale=e},changeScale(t){let e=this.scale;t=t||1;var i=20;if(i=i/this.trueWidth>i/this.trueHeight?i/this.trueHeight:i/this.trueWidth,t=t*i,t>0?e+=Math.abs(t):e>Math.abs(t)&&(e-=Math.abs(t)),!this.checkoutImgAxis(this.x,this.y,e))return!1;this.scale=e},createCrop(t){t.preventDefault();var e="clientX"in t?t.clientX:t.touches?t.touches[0].clientX:0,i="clientY"in t?t.clientY:t.touches?t.touches[0].clientY:0;this.$nextTick(()=>{var s=e-this.cropX,o=i-this.cropY;if(s>0?(this.cropW=s+this.cropChangeX>this.w?this.w-this.cropChangeX:s,this.cropOffsertX=this.cropChangeX):(this.cropW=this.w-this.cropChangeX+Math.abs(s)>this.w?this.cropChangeX:Math.abs(s),this.cropOffsertX=this.cropChangeX+s>0?this.cropChangeX+s:0),!this.fixed)o>0?(this.cropH=o+this.cropChangeY>this.h?this.h-this.cropChangeY:o,this.cropOffsertY=this.cropChangeY):(this.cropH=this.h-this.cropChangeY+Math.abs(o)>this.h?this.cropChangeY:Math.abs(o),this.cropOffsertY=this.cropChangeY+o>0?this.cropChangeY+o:0);else{var r=this.cropW/this.fixedNumber[0]*this.fixedNumber[1];r+this.cropOffsertY>this.h?(this.cropH=this.h-this.cropOffsertY,this.cropW=this.cropH/this.fixedNumber[1]*this.fixedNumber[0],s>0?this.cropOffsertX=this.cropChangeX:this.cropOffsertX=this.cropChangeX-this.cropW):this.cropH=r,this.cropOffsertY=this.cropOffsertY}})},changeCropSize(t,e,i,s,o){t.preventDefault(),window.addEventListener("mousemove",this.changeCropNow),window.addEventListener("mouseup",this.changeCropEnd),window.addEventListener("touchmove",this.changeCropNow),window.addEventListener("touchend",this.changeCropEnd),this.canChangeX=e,this.canChangeY=i,this.changeCropTypeX=s,this.changeCropTypeY=o,this.cropX="clientX"in t?t.clientX:t.touches[0].clientX,this.cropY="clientY"in t?t.clientY:t.touches[0].clientY,this.cropOldW=this.cropW,this.cropOldH=this.cropH,this.cropChangeX=this.cropOffsertX,this.cropChangeY=this.cropOffsertY,this.fixed&&this.canChangeX&&this.canChangeY&&(this.canChangeY=0),this.$emit("change-crop-size",{width:this.cropW,height:this.cropH})},changeCropNow(t){t.preventDefault();var e="clientX"in t?t.clientX:t.touches?t.touches[0].clientX:0,i="clientY"in t?t.clientY:t.touches?t.touches[0].clientY:0;let s=this.w,o=this.h,r=0,a=0;if(this.centerBox){let h=this.getImgAxis(),l=h.x2,c=h.y2;r=h.x1>0?h.x1:0,a=h.y1>0?h.y1:0,s>l&&(s=l),o>c&&(o=c)}this.$nextTick(()=>{var h=e-this.cropX,l=i-this.cropY;if(this.canChangeX&&(this.changeCropTypeX===1?this.cropOldW-h>0?(this.cropW=s-this.cropChangeX-h<=s-r?this.cropOldW-h:this.cropOldW+this.cropChangeX-r,this.cropOffsertX=s-this.cropChangeX-h<=s-r?this.cropChangeX+h:r):(this.cropW=Math.abs(h)+this.cropChangeX<=s?Math.abs(h)-this.cropOldW:s-this.cropOldW-this.cropChangeX,this.cropOffsertX=this.cropChangeX+this.cropOldW):this.changeCropTypeX===2&&(this.cropOldW+h>0?(this.cropW=this.cropOldW+h+this.cropOffsertX<=s?this.cropOldW+h:s-this.cropOffsertX,this.cropOffsertX=this.cropChangeX):(this.cropW=s-this.cropChangeX+Math.abs(h+this.cropOldW)<=s-r?Math.abs(h+this.cropOldW):this.cropChangeX-r,this.cropOffsertX=s-this.cropChangeX+Math.abs(h+this.cropOldW)<=s-r?this.cropChangeX-Math.abs(h+this.cropOldW):r))),this.canChangeY&&(this.changeCropTypeY===1?this.cropOldH-l>0?(this.cropH=o-this.cropChangeY-l<=o-a?this.cropOldH-l:this.cropOldH+this.cropChangeY-a,this.cropOffsertY=o-this.cropChangeY-l<=o-a?this.cropChangeY+l:a):(this.cropH=Math.abs(l)+this.cropChangeY<=o?Math.abs(l)-this.cropOldH:o-this.cropOldH-this.cropChangeY,this.cropOffsertY=this.cropChangeY+this.cropOldH):this.changeCropTypeY===2&&(this.cropOldH+l>0?(this.cropH=this.cropOldH+l+this.cropOffsertY<=o?this.cropOldH+l:o-this.cropOffsertY,this.cropOffsertY=this.cropChangeY):(this.cropH=o-this.cropChangeY+Math.abs(l+this.cropOldH)<=o-a?Math.abs(l+this.cropOldH):this.cropChangeY-a,this.cropOffsertY=o-this.cropChangeY+Math.abs(l+this.cropOldH)<=o-a?this.cropChangeY-Math.abs(l+this.cropOldH):a))),this.canChangeX&&this.fixed){var c=this.cropW/this.fixedNumber[0]*this.fixedNumber[1];c+this.cropOffsertY>o?(this.cropH=o-this.cropOffsertY,this.cropW=this.cropH/this.fixedNumber[1]*this.fixedNumber[0]):this.cropH=c}if(this.canChangeY&&this.fixed){var n=this.cropH/this.fixedNumber[1]*this.fixedNumber[0];n+this.cropOffsertX>s?(this.cropW=s-this.cropOffsertX,this.cropH=this.cropW/this.fixedNumber[0]*this.fixedNumber[1]):this.cropW=n}})},checkCropLimitSize(){let{cropW:t,cropH:e,limitMinSize:i}=this,s=new Array;return Array.isArray[i]?s=i:s=[i,i],t=parseFloat(s[0]),e=parseFloat(s[1]),[t,e]},changeCropEnd(t){window.removeEventListener("mousemove",this.changeCropNow),window.removeEventListener("mouseup",this.changeCropEnd),window.removeEventListener("touchmove",this.changeCropNow),window.removeEventListener("touchend",this.changeCropEnd)},endCrop(){this.cropW===0&&this.cropH===0&&(this.cropping=!1),window.removeEventListener("mousemove",this.createCrop),window.removeEventListener("mouseup",this.endCrop),window.removeEventListener("touchmove",this.createCrop),window.removeEventListener("touchend",this.endCrop)},startCrop(){this.crop=!0},stopCrop(){this.crop=!1},clearCrop(){this.cropping=!1,this.cropW=0,this.cropH=0},cropMove(t){if(t.preventDefault(),!this.canMoveBox)return this.crop=!1,this.startMove(t),!1;if(t.touches&&t.touches.length===2)return this.crop=!1,this.startMove(t),this.leaveCrop(),!1;window.addEventListener("mousemove",this.moveCrop),window.addEventListener("mouseup",this.leaveCrop),window.addEventListener("touchmove",this.moveCrop),window.addEventListener("touchend",this.leaveCrop);let e="clientX"in t?t.clientX:t.touches[0].clientX,i="clientY"in t?t.clientY:t.touches[0].clientY,s,o;s=e-this.cropOffsertX,o=i-this.cropOffsertY,this.cropX=s,this.cropY=o,this.$emit("cropMoving",{moving:!0,axis:this.getCropAxis()}),this.$emit("crop-moving",{moving:!0,axis:this.getCropAxis()})},moveCrop(t,e){let i=0,s=0;t&&(t.preventDefault(),i="clientX"in t?t.clientX:t.touches[0].clientX,s="clientY"in t?t.clientY:t.touches[0].clientY),this.$nextTick(()=>{let o,r,a=i-this.cropX,h=s-this.cropY;if(e&&(a=this.cropOffsertX,h=this.cropOffsertY),a<=0?o=0:a+this.cropW>this.w?o=this.w-this.cropW:o=a,h<=0?r=0:h+this.cropH>this.h?r=this.h-this.cropH:r=h,this.centerBox){let l=this.getImgAxis();o<=l.x1&&(o=l.x1),o+this.cropW>l.x2&&(o=l.x2-this.cropW),r<=l.y1&&(r=l.y1),r+this.cropH>l.y2&&(r=l.y2-this.cropH)}this.cropOffsertX=o,this.cropOffsertY=r,this.$emit("cropMoving",{moving:!0,axis:this.getCropAxis()}),this.$emit("crop-moving",{moving:!0,axis:this.getCropAxis()})})},getImgAxis(t,e,i){t=t||this.x,e=e||this.y,i=i||this.scale;let s={x1:0,x2:0,y1:0,y2:0},o=this.trueWidth*i,r=this.trueHeight*i;switch(this.rotate){case 0:s.x1=t+this.trueWidth*(1-i)/2,s.x2=s.x1+this.trueWidth*i,s.y1=e+this.trueHeight*(1-i)/2,s.y2=s.y1+this.trueHeight*i;break;case 1:case-1:case 3:case-3:s.x1=t+this.trueWidth*(1-i)/2+(o-r)/2,s.x2=s.x1+this.trueHeight*i,s.y1=e+this.trueHeight*(1-i)/2+(r-o)/2,s.y2=s.y1+this.trueWidth*i;break;default:s.x1=t+this.trueWidth*(1-i)/2,s.x2=s.x1+this.trueWidth*i,s.y1=e+this.trueHeight*(1-i)/2,s.y2=s.y1+this.trueHeight*i;break}return s},getCropAxis(){let t={x1:0,x2:0,y1:0,y2:0};return t.x1=this.cropOffsertX,t.x2=t.x1+this.cropW,t.y1=this.cropOffsertY,t.y2=t.y1+this.cropH,t},leaveCrop(t){window.removeEventListener("mousemove",this.moveCrop),window.removeEventListener("mouseup",this.leaveCrop),window.removeEventListener("touchmove",this.moveCrop),window.removeEventListener("touchend",this.leaveCrop),this.$emit("cropMoving",{moving:!1,axis:this.getCropAxis()}),this.$emit("crop-moving",{moving:!1,axis:this.getCropAxis()})},getCropChecked(t){let e=document.createElement("canvas"),i=new Image,s=this.rotate,o=this.trueWidth,r=this.trueHeight,a=this.cropOffsertX,h=this.cropOffsertY;i.onload=()=>{if(this.cropW!==0){let n=e.getContext("2d"),p=1;this.high&!this.full&&(p=window.devicePixelRatio),this.enlarge!==1&!this.full&&(p=Math.abs(Number(this.enlarge)));let u=this.cropW*p,b=this.cropH*p,f=o*this.scale*p,g=r*this.scale*p,m=(this.x-a+this.trueWidth*(1-this.scale)/2)*p,v=(this.y-h+this.trueHeight*(1-this.scale)/2)*p;switch(c(u,b),n.save(),s){case 0:this.full?(c(u/this.scale,b/this.scale),n.drawImage(i,m/this.scale,v/this.scale,f/this.scale,g/this.scale)):n.drawImage(i,m,v,f,g);break;case 1:case-3:this.full?(c(u/this.scale,b/this.scale),m=m/this.scale+(f/this.scale-g/this.scale)/2,v=v/this.scale+(g/this.scale-f/this.scale)/2,n.rotate(s*90*Math.PI/180),n.drawImage(i,v,-m-g/this.scale,f/this.scale,g/this.scale)):(m=m+(f-g)/2,v=v+(g-f)/2,n.rotate(s*90*Math.PI/180),n.drawImage(i,v,-m-g,f,g));break;case 2:case-2:this.full?(c(u/this.scale,b/this.scale),n.rotate(s*90*Math.PI/180),m=m/this.scale,v=v/this.scale,n.drawImage(i,-m-f/this.scale,-v-g/this.scale,f/this.scale,g/this.scale)):(n.rotate(s*90*Math.PI/180),n.drawImage(i,-m-f,-v-g,f,g));break;case 3:case-1:this.full?(c(u/this.scale,b/this.scale),m=m/this.scale+(f/this.scale-g/this.scale)/2,v=v/this.scale+(g/this.scale-f/this.scale)/2,n.rotate(s*90*Math.PI/180),n.drawImage(i,-v-f/this.scale,m,f/this.scale,g/this.scale)):(m=m+(f-g)/2,v=v+(g-f)/2,n.rotate(s*90*Math.PI/180),n.drawImage(i,-v-f,m,f,g));break;default:this.full?(c(u/this.scale,b/this.scale),n.drawImage(i,m/this.scale,v/this.scale,f/this.scale,g/this.scale)):n.drawImage(i,m,v,f,g)}n.restore()}else{let n=o*this.scale,p=r*this.scale,u=e.getContext("2d");switch(u.save(),s){case 0:c(n,p),u.drawImage(i,0,0,n,p);break;case 1:case-3:c(p,n),u.rotate(s*90*Math.PI/180),u.drawImage(i,0,-p,n,p);break;case 2:case-2:c(n,p),u.rotate(s*90*Math.PI/180),u.drawImage(i,-n,-p,n,p);break;case 3:case-1:c(p,n),u.rotate(s*90*Math.PI/180),u.drawImage(i,-n,0,n,p);break;default:c(n,p),u.drawImage(i,0,0,n,p)}u.restore()}t(e)};var l=this.img.substr(0,4);l!=="data"&&(i.crossOrigin="Anonymous"),i.src=this.imgs;function c(n,p){e.width=Math.round(n),e.height=Math.round(p)}},getCropData(t){this.getCropChecked(e=>{t(e.toDataURL("image/"+this.outputType,this.outputSize))})},getCropBlob(t){this.getCropChecked(e=>{e.toBlob(i=>t(i),"image/"+this.outputType,this.outputSize)})},showPreview(){if(this.isCanShow)this.isCanShow=!1,setTimeout(()=>{this.isCanShow=!0},16);else return!1;let t=this.cropW,e=this.cropH,i=this.scale;var s={};s.div={width:`${t}px`,height:`${e}px`};let o=(this.x-this.cropOffsertX)/i,r=(this.y-this.cropOffsertY)/i,a=0;s.w=t,s.h=e,s.url=this.imgs,s.img={width:`${this.trueWidth}px`,height:`${this.trueHeight}px`,transform:`scale(${i})translate3d(${o}px, ${r}px, ${a}px)rotateZ(${this.rotate*90}deg)`},s.html=`
  2. <div class="show-preview" style="width: ${s.w}px; height: ${s.h}px,; overflow: hidden">
  3. <div style="width: ${t}px; height: ${e}px">
  4. <img src=${s.url} style="width: ${this.trueWidth}px; height: ${this.trueHeight}px; transform:
  5. scale(${i})translate3d(${o}px, ${r}px, ${a}px)rotateZ(${this.rotate*90}deg)">
  6. </div>
  7. </div>`,this.$emit("realTime",s),this.$emit("real-time",s)},reload(){let t=new Image;t.onload=()=>{this.w=parseFloat(window.getComputedStyle(this.$refs.cropper).width),this.h=parseFloat(window.getComputedStyle(this.$refs.cropper).height),this.trueWidth=t.width,this.trueHeight=t.height,this.original?this.scale=1:this.scale=this.checkedMode(),this.$nextTick(()=>{this.x=-(this.trueWidth-this.trueWidth*this.scale)/2+(this.w-this.trueWidth*this.scale)/2,this.y=-(this.trueHeight-this.trueHeight*this.scale)/2+(this.h-this.trueHeight*this.scale)/2,this.loading=!1,this.autoCrop&&this.goAutoCrop(),this.$emit("img-load","success"),this.$emit("imgLoad","success"),setTimeout(()=>{this.showPreview()},20)})},t.onerror=()=>{this.$emit("imgLoad","error"),this.$emit("img-load","error")},t.src=this.imgs},checkedMode(){let t=1,e=this.trueWidth,i=this.trueHeight;const s=this.mode.split(" ");switch(s[0]){case"contain":this.trueWidth>this.w&&(t=this.w/this.trueWidth),this.trueHeight*t>this.h&&(t=this.h/this.trueHeight);break;case"cover":e=this.w,t=e/this.trueWidth,i=i*t,i<this.h&&(i=this.h,t=i/this.trueHeight);break;default:try{let o=s[0];if(o.search("px")!==-1){o=o.replace("px",""),e=parseFloat(o);const r=e/this.trueWidth;let a=1,h=s[1];h.search("px")!==-1&&(h=h.replace("px",""),i=parseFloat(h),a=i/this.trueHeight),t=Math.min(r,a)}if(o.search("%")!==-1&&(o=o.replace("%",""),e=parseFloat(o)/100*this.w,t=e/this.trueWidth),s.length===2&&o==="auto"){let r=s[1];r.search("px")!==-1&&(r=r.replace("px",""),i=parseFloat(r),t=i/this.trueHeight),r.search("%")!==-1&&(r=r.replace("%",""),i=parseFloat(r)/100*this.h,t=i/this.trueHeight)}}catch{t=1}}return t},goAutoCrop(t,e){if(this.imgs===""||this.imgs===null)return;this.clearCrop(),this.cropping=!0;let i=this.w,s=this.h;if(this.centerBox){const a=Math.abs(this.rotate)%2>0;let h=(a?this.trueHeight:this.trueWidth)*this.scale,l=(a?this.trueWidth:this.trueHeight)*this.scale;i=h<i?h:i,s=l<s?l:s}var o=t||parseFloat(this.autoCropWidth),r=e||parseFloat(this.autoCropHeight);(o===0||r===0)&&(o=i*.8,r=s*.8),o=o>i?i:o,r=r>s?s:r,this.fixed&&(r=o/this.fixedNumber[0]*this.fixedNumber[1]),r>this.h&&(r=this.h,o=r/this.fixedNumber[1]*this.fixedNumber[0]),this.changeCrop(o,r)},changeCrop(t,e){if(this.centerBox){let i=this.getImgAxis();t>i.x2-i.x1&&(t=i.x2-i.x1,e=t/this.fixedNumber[0]*this.fixedNumber[1]),e>i.y2-i.y1&&(e=i.y2-i.y1,t=e/this.fixedNumber[1]*this.fixedNumber[0])}this.cropW=t,this.cropH=e,this.checkCropLimitSize(),this.$nextTick(()=>{this.cropOffsertX=(this.w-this.cropW)/2,this.cropOffsertY=(this.h-this.cropH)/2,this.centerBox&&this.moveCrop(null,!0)})},refresh(){this.img,this.imgs="",this.scale=1,this.crop=!1,this.rotate=0,this.w=0,this.h=0,this.trueWidth=0,this.trueHeight=0,this.clearCrop(),this.$nextTick(()=>{this.checkedImg()})},rotateLeft(){this.rotate=this.rotate<=-3?0:this.rotate-1},rotateRight(){this.rotate=this.rotate>=3?0:this.rotate+1},rotateClear(){this.rotate=0},checkoutImgAxis(t,e,i){t=t||this.x,e=e||this.y,i=i||this.scale;let s=!0;if(this.centerBox){let o=this.getImgAxis(t,e,i),r=this.getCropAxis();o.x1>=r.x1&&(s=!1),o.x2<=r.x2&&(s=!1),o.y1>=r.y1&&(s=!1),o.y2<=r.y2&&(s=!1)}return s}},mounted(){this.support="onwheel"in document.createElement("div")?"wheel":document.onmousewheel!==void 0?"mousewheel":"DOMMouseScroll";let t=this;var e=navigator.userAgent;this.isIOS=!!e.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),HTMLCanvasElement.prototype.toBlob||Object.defineProperty(HTMLCanvasElement.prototype,"toBlob",{value:function(i,s,o){for(var r=atob(this.toDataURL(s,o).split(",")[1]),a=r.length,h=new Uint8Array(a),l=0;l<a;l++)h[l]=r.charCodeAt(l);i(new Blob([h],{type:t.type||"image/png"}))}}),this.showPreview(),this.checkedImg()},destroyed(){window.removeEventListener("mousemove",this.moveCrop),window.removeEventListener("mouseup",this.leaveCrop),window.removeEventListener("touchmove",this.moveCrop),window.removeEventListener("touchend",this.leaveCrop),this.cancelScale()}}),it={key:0,class:"cropper-box"},st=["src"],ot={class:"cropper-view-box"},rt=["src"],at={key:1};function ht(t,e,i,s,o,r){return O(),I("div",{class:"vue-cropper",ref:"cropper",onMouseover:e[28]||(e[28]=(...a)=>t.scaleImg&&t.scaleImg(...a)),onMouseout:e[29]||(e[29]=(...a)=>t.cancelScale&&t.cancelScale(...a))},[t.imgs?(O(),I("div",it,[W(w("div",{class:"cropper-box-canvas",style:A({width:t.trueWidth+"px",height:t.trueHeight+"px",transform:"scale("+t.scale+","+t.scale+") translate3d("+t.x/t.scale+"px,"+t.y/t.scale+"px,0)rotateZ("+t.rotate*90+"deg)"})},[w("img",{src:t.imgs,alt:"cropper-img",ref:"cropperImg"},null,8,st)],4),[[Y,!t.loading]])])):S("",!0),w("div",{class:z(["cropper-drag-box",{"cropper-move":t.move&&!t.crop,"cropper-crop":t.crop,"cropper-modal":t.cropping}]),onMousedown:e[0]||(e[0]=(...a)=>t.startMove&&t.startMove(...a)),onTouchstart:e[1]||(e[1]=(...a)=>t.startMove&&t.startMove(...a))},null,34),W(w("div",{class:"cropper-crop-box",style:A({width:t.cropW+"px",height:t.cropH+"px",transform:"translate3d("+t.cropOffsertX+"px,"+t.cropOffsertY+"px,0)"})},[w("span",ot,[w("img",{style:A({width:t.trueWidth+"px",height:t.trueHeight+"px",transform:"scale("+t.scale+","+t.scale+") translate3d("+(t.x-t.cropOffsertX)/t.scale+"px,"+(t.y-t.cropOffsertY)/t.scale+"px,0)rotateZ("+t.rotate*90+"deg)"}),src:t.imgs,alt:"cropper-img"},null,12,rt)]),w("span",{class:"cropper-face cropper-move",onMousedown:e[2]||(e[2]=(...a)=>t.cropMove&&t.cropMove(...a)),onTouchstart:e[3]||(e[3]=(...a)=>t.cropMove&&t.cropMove(...a))},null,32),t.info?(O(),I("span",{key:0,class:"crop-info",style:A({top:t.cropInfo.top})},B(t.cropInfo.width)+" \xD7 "+B(t.cropInfo.height),5)):S("",!0),t.fixedBox?S("",!0):(O(),I("span",at,[w("span",{class:"crop-line line-w",onMousedown:e[4]||(e[4]=a=>t.changeCropSize(a,!1,!0,0,1)),onTouchstart:e[5]||(e[5]=a=>t.changeCropSize(a,!1,!0,0,1))},null,32),w("span",{class:"crop-line line-a",onMousedown:e[6]||(e[6]=a=>t.changeCropSize(a,!0,!1,1,0)),onTouchstart:e[7]||(e[7]=a=>t.changeCropSize(a,!0,!1,1,0))},null,32),w("span",{class:"crop-line line-s",onMousedown:e[8]||(e[8]=a=>t.changeCropSize(a,!1,!0,0,2)),onTouchstart:e[9]||(e[9]=a=>t.changeCropSize(a,!1,!0,0,2))},null,32),w("span",{class:"crop-line line-d",onMousedown:e[10]||(e[10]=a=>t.changeCropSize(a,!0,!1,2,0)),onTouchstart:e[11]||(e[11]=a=>t.changeCropSize(a,!0,!1,2,0))},null,32),w("span",{class:"crop-point point1",onMousedown:e[12]||(e[12]=a=>t.changeCropSize(a,!0,!0,1,1)),onTouchstart:e[13]||(e[13]=a=>t.changeCropSize(a,!0,!0,1,1))},null,32),w("span",{class:"crop-point point2",onMousedown:e[14]||(e[14]=a=>t.changeCropSize(a,!1,!0,0,1)),onTouchstart:e[15]||(e[15]=a=>t.changeCropSize(a,!1,!0,0,1))},null,32),w("span",{class:"crop-point point3",onMousedown:e[16]||(e[16]=a=>t.changeCropSize(a,!0,!0,2,1)),onTouchstart:e[17]||(e[17]=a=>t.changeCropSize(a,!0,!0,2,1))},null,32),w("span",{class:"crop-point point4",onMousedown:e[18]||(e[18]=a=>t.changeCropSize(a,!0,!1,1,0)),onTouchstart:e[19]||(e[19]=a=>t.changeCropSize(a,!0,!1,1,0))},null,32),w("span",{class:"crop-point point5",onMousedown:e[20]||(e[20]=a=>t.changeCropSize(a,!0,!1,2,0)),onTouchstart:e[21]||(e[21]=a=>t.changeCropSize(a,!0,!1,2,0))},null,32),w("span",{class:"crop-point point6",onMousedown:e[22]||(e[22]=a=>t.changeCropSize(a,!0,!0,1,2)),onTouchstart:e[23]||(e[23]=a=>t.changeCropSize(a,!0,!0,1,2))},null,32),w("span",{class:"crop-point point7",onMousedown:e[24]||(e[24]=a=>t.changeCropSize(a,!1,!0,0,2)),onTouchstart:e[25]||(e[25]=a=>t.changeCropSize(a,!1,!0,0,2))},null,32),w("span",{class:"crop-point point8",onMousedown:e[26]||(e[26]=a=>t.changeCropSize(a,!0,!0,2,2)),onTouchstart:e[27]||(e[27]=a=>t.changeCropSize(a,!0,!0,2,2))},null,32)]))],4),[[Y,t.cropping]])],544)}var H=tt(et,[["render",ht],["__scopeId","data-v-be5e5ddc"]]);typeof window!="undefined"&&window.Vue&&window.Vue.createApp({}).component("VueCropper",H);const nt="_upbtn_15vje_1",lt="_uploadWarper_15vje_5",ct="_bg_15vje_12",pt="_btn_15vje_21",ut="_btn1_15vje_33",dt="_img_15vje_44",ft="_btndiv_15vje_53",gt="_wrapper_15vje_64";var y={upbtn:nt,uploadWarper:lt,bg:ct,btn:pt,btn1:ut,img:dt,btndiv:ft,wrapper:gt},mt=k({name:"o-cropper",components:{VueCropper:H},props:{hideInput:{type:Boolean,default:!1},option:{type:Object},onCancelTailor:{type:Function,default:()=>{}},getBase64Data:{type:Function,default:()=>{}},getBlob:{type:Function,default:()=>{}},getFile:{type:Function,default:()=>{}},imgOriginF:{type:Function,default:()=>{}}},emits:["chioseFile"],data(){return{img:"",config:{ceilbutton:!1,outputSize:1,outputType:"png",info:!1,canScale:!0,autoCrop:!1,autoCropWidth:0,autoCropHeight:0,fixed:!0,fixedNumber:[1,1],full:!1,fixedBox:!0,canMove:!0,canMoveBox:!1,original:!1,centerBox:!0,high:!0,infoTrue:!1,maxImgSize:2e3,enlarge:1,mode:"100%",cancelButtonText:"\u53D6\u6D88",confirmButtonText:"\u786E\u5B9A",cancelButtonBackgroundColor:"#606266",confirmButtonBackgroundColor:"#ed594c",cancelButtonTextColor:"#ffffff",confirmButtonTextColor:"#ffffff"}}},mounted(){this.config=Object.assign(this.config,this.option)},methods:{addSlide(){if(document.getElementById("vertical")==null){const t=document.getElementsByClassName("cropper-crop-box")[0],e=document.createElement("div");e.id="vertical",e.style.width="1px",e.style.height="100%",e.style.top="0px",e.style.left="33%",e.style.position="absolute",e.style.backgroundColor="#fff",e.style.zIndex="522",e.style.opacity="0.5";const i=document.createElement("div");i.style.width="1px",i.style.height="100%",i.style.top="0px",i.style.right="33%",i.style.position="absolute",i.style.backgroundColor="#fff",i.style.zIndex="522",i.style.opacity="0.5";const s=document.createElement("div");s.style.width="100%",s.style.height="1px",s.style.top="33%",s.style.left="0px",s.style.position="absolute",s.style.backgroundColor="#fff",s.style.zIndex="522",s.style.opacity="0.5";const o=document.createElement("div");o.style.width="100%",o.style.height="1px",o.style.bottom="33%",o.style.left="0px",o.style.position="absolute",o.style.backgroundColor="#fff",o.style.zIndex="522",o.style.opacity="0.5";const r=document.createElement("div");r.style.width="30px",r.style.height="4px",r.style.top="-4px",r.style.left="-4px",r.style.position="absolute",r.style.backgroundColor="#fff",r.style.zIndex="522",r.style.opacity="1";const a=document.createElement("div");a.style.width="4px",a.style.height="30px",a.style.top="-4px",a.style.left="-4px",a.style.position="absolute",a.style.backgroundColor="#fff",a.style.zIndex="522",a.style.opacity="1";const h=document.createElement("div");h.style.width="30px",h.style.height="4px",h.style.top="-4px",h.style.right="-4px",h.style.position="absolute",h.style.backgroundColor="#fff",h.style.zIndex="522",h.style.opacity="1";const l=document.createElement("div");l.style.width="4px",l.style.height="30px",l.style.top="-4px",l.style.right="-4px",l.style.position="absolute",l.style.backgroundColor="#fff",l.style.zIndex="522",l.style.opacity="1";const c=document.createElement("div");c.style.width="30px",c.style.height="4px",c.style.bottom="-4px",c.style.left="-4px",c.style.position="absolute",c.style.backgroundColor="#fff",c.style.zIndex="522",c.style.opacity="1";const n=document.createElement("div");n.style.width="4px",n.style.height="30px",n.style.bottom="-4px",n.style.left="-4px",n.style.position="absolute",n.style.backgroundColor="#fff",n.style.zIndex="522",n.style.opacity="1";const p=document.createElement("div");p.style.width="30px",p.style.height="4px",p.style.bottom="-4px",p.style.right="-4px",p.style.position="absolute",p.style.backgroundColor="#fff",p.style.zIndex="522",p.style.opacity="1";const u=document.createElement("div");u.style.width="4px",u.style.height="30px",u.style.bottom="-4px",u.style.right="-4px",u.style.position="absolute",u.style.backgroundColor="#fff",u.style.zIndex="522",u.style.opacity="1",t.appendChild(e),t.appendChild(i),t.appendChild(s),t.appendChild(o),t.appendChild(r),t.appendChild(a),t.appendChild(h),t.appendChild(l),t.appendChild(c),t.appendChild(n),t.appendChild(p),t.appendChild(u)}},onLoadImg(t){return new Promise(function(e,i){const s=new FileReader;s.readAsDataURL(t),s.onload=o=>{e(o.target.result)}})},loadFile(t){if(t instanceof File)this.onLoadImg(t).then(e=>{this.img=e,setTimeout(()=>{this.config.autoCrop=!0,this.addSlide()},10)});else throw new Error("Arguments file is not File")},loadBase64(t){if(typeof t!="string")throw new Error("Arguments base64 is not string");const e=t.split(",");if(!/^data:image\/(.*?);base64$/.test(e[0]))throw new Error("Arguments base64 MIME is not image/*");if(!/^[\/]?([\da-zA-Z]+[\/+]+)*[\da-zA-Z]+([+=]{1,2}|[\/])?$/.test(e[1]))throw new Error("Not standard base64");this.img=t,setTimeout(()=>{this.config.autoCrop=!0,this.addSlide()},10)},rotating(t){this.$refs.cropper.rotateRight()},canceltailor(){this.img="",this.onCancelTailor()},tailoring(){this.$refs.cropper.getCropData(t=>{this.getBase64Data(t),this.getBlob(t),this.img="",this.config.autoCrop=!1}),this.$refs.cropper.getCropBlob(t=>{this.getBase64Data(t),this.getBlob(t);const e={jpeg:"jpg",png:"png",webp:"webp"}[this.config.outputType],i=new Date().getTime(),s=new File([t],`${i}.${e}`,{type:`image/${this.config.outputType}`});this.getFile(s),this.img="",this.config.autoCrop=!1})},async upPhoto(t){let e=t.target.files[0];this.$refs.headInput.value=null,e!=null&&(this.imgOriginF(e),this.img=await this.onLoadImg(e),this.config.autoCrop=!0,setTimeout(()=>{this.addSlide()},20))},onCropMoving(t){},onImgMoving(t){},startChiose(){this.$refs.headInput.click()}},render(){return d("div",{class:[y.upbtn,y.uploadWarper]},[this.hideInput,this.hideInput?null:d("input",{style:"opacity: 0;",class:y.upbtn,type:"file",accept:"image/*",onChange:this.upPhoto,ref:"headInput"},null),this.img!=""?d("div",{class:y.bg},[this.config.ceilbutton?d("div",{class:y.btndiv},[d("div",{class:y.btn,onClick:this.canceltailor,style:{backgroundColor:this.config.cancelButtonBackgroundColor,color:this.config.cancelButtonTextColor}},[this.config.cancelButtonText]),d("div",{class:y.img,onClick:this.rotating},null),d("div",{class:y.btn,onClick:this.tailoring,style:{backgroundColor:this.config.confirmButtonBackgroundColor,color:this.config.confirmButtonTextColor}},[this.config.confirmButtonText])]):null,d("div",{class:y.wrapper},[d(H,{ref:"cropper",img:this.img,outputSize:this.config.outputSize,outputType:this.config.outputType,info:this.config.info,canScale:this.config.canScale,autoCrop:this.config.autoCrop,autoCropWidth:this.config.autoCropWidth,autoCropHeight:this.config.autoCropHeight,fixedBox:this.config.fixedBox,fixed:this.config.fixed,fixedNumber:this.config.fixedNumber,full:this.config.full,canMove:this.config.canMove,canMoveBox:this.config.canMoveBox,original:this.config.original,centerBox:this.config.centerBox,high:this.config.high,infoTrue:this.config.infoTrue,maxImgSize:this.config.maxImgSize,enlarge:this.config.enlarge,mode:this.config.mode,onCropMoving:this.onCropMoving,onImgMoving:this.onImgMoving},null)]),this.config.ceilbutton?null:d("div",{class:y.btndiv},[d("div",{class:y.btn,onClick:this.canceltailor,style:{backgroundColor:this.config.cancelButtonBackgroundColor,color:this.config.cancelButtonTextColor}},[this.config.cancelButtonText]),d("div",{class:y.img,onClick:this.rotating},null),d("div",{class:y.btn,onClick:this.tailoring,style:{backgroundColor:this.config.confirmButtonBackgroundColor,color:this.config.confirmButtonTextColor}},[this.config.confirmButtonText])])]):null])}}),X="data:image/png;base64,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",Ct=k({name:"col-upload",props:{modelValue:String,tips:{type:String,default:"\u70B9\u51FB\u4E0A\u4F20"},deletable:{type:Boolean,default:!0},native:{type:Boolean,default:!1},cropper:{type:Boolean,default:!1},options:{type:Object,default:{}},uploadSize:{type:Number,default:5},onUploadChange:{type:Function,default:t=>{}},bucket:{type:String,default:"gyt"},path:{type:String,default:""},disabled:{type:Boolean,default:!1}},methods:{nativeUpload(){this.disabled||D({api:"chooseFile",content:{type:"img",max:1,bucket:this.bucket,path:this.path}},t=>{console.log(t,"fileUrl"),this.$emit("update:modelValue",t.fileUrl)})},beforeRead(t){return console.log(t,"beforeRead"),t.size/1024/1024<this.uploadSize?!0:(N(`\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC7 ${this.uploadSize}MB`),!1)},beforeDelete(t,e){return!0},async afterRead(t,e){try{t.status="uploading",t.message="\u4E0A\u4F20\u4E2D...",await this.uploadFile(t.file)}catch(i){console.log(i,"2323"),E()}},onClose(t){this.$emit("update:modelValue",null),this.onUploadChange(),t.stopPropagation()},async getFile(t){try{await this.uploadFile(t)}catch{}},async uploadFile(t){try{x.platformType==="SCHOOL"?x.platformApi="/api-school":x.platformType==="TEACHER"?x.platformApi="/api-teacher":x.platformType==="STUDENT"&&(x.platformApi="/api-student");const e=t.name||"",i=this.path?this.path+"/"+(e&&e.replace(/ /gi,"_")):e&&e.replace(/ /gi,"_"),s=new Date().getTime()+i,{data:o}=await R({filename:s,bucketName:this.bucket,postData:{filename:s,acl:"public-read",key:s,unknowValueField:[]}});$({message:"\u52A0\u8F7D\u4E2D...",forbidClick:!0,loadingType:"spinner",duration:0});const r={policy:o.policy,signature:o.signature,key:s,KSSAccessKeyId:o.kssAccessKeyId,acl:"public-read",name:s,file:t},a=await j(F(this.bucket),r);E(),this.$emit("update:modelValue",a),this.onUploadChange(a)}catch(e){console.log(e,"uploadFile")}},startUpload(){var t;(t=this.$refs.uploaderRef)==null||t.startChiose()}},render(){return U(()=>this.modelValue),d("div",{class:[C["uploader-section"],"oUpload"]},[this.modelValue&&this.deletable?d(M,{name:"cross",onClick:this.onClose,class:C["img-close"]},null):null,this.cropper&&!this.native?d("div",{class:C["col-uploader"]},[this.modelValue?d(T,{fit:"cover",position:"center",class:C.uploadImg,src:this.modelValue},null):d("div",{class:C.uploader},[d(M,{name:X,size:"32"},null),d("p",{class:C.uploaderText},[this.tips])]),d(mt,{ref:"uploaderRef",option:this.options,getFile:this.getFile},null)]):this.native?d("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},onClick:this.nativeUpload},[this.modelValue?d(T,{fit:"cover",position:"center",class:C.uploadImg,src:this.modelValue},null):d("div",{class:C.uploader},[d(M,{name:X,size:"32"},null),d("p",{class:C.uploaderText},[this.tips])])]):d(P,{afterRead:this.afterRead,beforeRead:this.beforeRead,beforeDelete:this.beforeDelete,disabled:this.disabled},{default:()=>this.modelValue?d(T,{fit:"cover",position:"center",class:C.uploadImg,src:this.modelValue},null):d("div",{class:C.uploader},[d(M,{name:X,size:"32"},null),d("p",{class:C.uploaderText},[this.tips])])})])}});export{Ct as O};