import{_ as t,aw as r,H as e,m as a,p as n,ax as i,W as o,o as s,c as h,w as c,v as l,a3 as u,b as g,f,ay as d,h as w,s as v,ah as p,d as y,t as m,e as A,x,z as b,B as C,y as I}from"./index-01d5b8eb.js";import{r as B}from"./uni-app.es.37c693bd.js";var k=function(t,r){var e=t,a=_[r],n=null,i=0,o=null,s=new Array,h={},c=function(t,r){n=function(t){for(var r=new Array(t),e=0;e=7&&f(t),null==o&&(o=v(e,a,s)),w(o,r)},l=function(t,r){for(var e=-1;e<=7;e+=1)if(!(t+e<=-1||i<=t+e))for(var a=-1;a<=7;a+=1)r+a<=-1||i<=r+a||(n[t+e][r+a]=0<=e&&e<=6&&(0==a||6==a)||0<=a&&a<=6&&(0==e||6==e)||2<=e&&e<=4&&2<=a&&a<=4)},u=function(){for(var t=8;t>a&1);n[Math.floor(a/3)][a%3+i-8-3]=o}for(a=0;a<18;a+=1){o=!t&&1==(r>>a&1);n[a%3+i-8-3][Math.floor(a/3)]=o}},d=function(t,r){for(var e=a<<3|r,o=$.getBCHTypeInfo(e),s=0;s<15;s+=1){var h=!t&&1==(o>>s&1);s<6?n[s][8]=h:s<8?n[s+1][8]=h:n[i-15+s][8]=h}for(s=0;s<15;s+=1){h=!t&&1==(o>>s&1);s<8?n[8][i-s-1]=h:s<9?n[8][15-s-1+1]=h:n[8][15-s-1]=h}n[i-8][8]=!t},w=function(t,r){for(var e=-1,a=i-1,o=7,s=0,h=$.getMaskFunction(r),c=i-1;c>0;c-=2)for(6==c&&(c-=1);;){for(var l=0;l<2;l+=1)if(null==n[a][c-l]){var u=!1;s>>o&1)),h(a,c-l)&&(u=!u),n[a][c-l]=u,-1==(o-=1)&&(s+=1,o=7)}if((a+=e)<0||i<=a){a-=e,e=-e;break}}},v=function(t,r,e){for(var a=X.getRSBlocks(t,r),n=Y(),i=0;i8*s)throw new Error("code length overflow. ("+n.getLengthInBits()+">"+8*s+")");for(n.getLengthInBits()+4<=8*s&&n.put(0,4);n.getLengthInBits()%8!=0;)n.putBit(!1);for(;!(n.getLengthInBits()>=8*s||(n.put(236,8),n.getLengthInBits()>=8*s));)n.put(17,8);return function(t,r){for(var e=0,a=0,n=0,i=new Array(r.length),o=new Array(r.length),s=0;s=0?g.getAt(f):0}}var d=0;for(l=0;la)&&(t=a,r=e)}return r}())},h.createTableTag=function(t,r){t=t||2;var e="";e+='',e+="";for(var a=0;a";for(var n=0;n';e+=""}return e+="",e+="
"},h.createImgTag=function(t,r,e){t=t||2;var a=r=void 0===r?4*t:r,n=h.getModuleCount()*t+r;return tt(e,e,(function(r,e){if(a<=r&&r>>8),r.push(255&o)):r.push(a)}}return r}};var D,P,L,O,S,M=1,T=2,E=4,R=8,_={L:1,M:0,Q:3,H:2},z=0,H=1,F=2,W=3,N=4,U=5,q=6,Q=7,$=(D=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],P=1335,L=7973,S=function(t){for(var r=0;0!=t;)r+=1,t>>>=1;return r},(O={}).getBCHTypeInfo=function(t){for(var r=t<<10;S(r)-S(P)>=0;)r^=P<=0;)r^=L<5&&(e+=3+i-5)}for(a=0;a=256;)r-=255;return t[r]}};return a}();function G(t,r){if(void 0===t.length)throw new Error(t.length+"/"+r);var e=function(){for(var e=0;e>>7-r%8&1)},put:function(t,r){for(var a=0;a>>r-a-1&1))},getLengthInBits:function(){return r},putBit:function(e){var a=Math.floor(r/8);t.length<=a&&t.push(0),e&&(t[a]|=128>>>r%8),r+=1}};return e},J=function(t){for(var r=E,e=t,a=[],n={},i=0,o=e.length;i65536?(s[0]=240|(1835008&h)>>>18,s[1]=128|(258048&h)>>>12,s[2]=128|(4032&h)>>>6,s[3]=128|63&h):h>2048?(s[0]=224|(61440&h)>>>12,s[1]=128|(4032&h)>>>6,s[2]=128|63&h):h>128?(s[0]=192|(1984&h)>>>6,s[1]=128|63&h):s[0]=h,a.push(s)}(a=Array.prototype.concat.apply([],a)).length!=e.length&&(a.unshift(191),a.unshift(187),a.unshift(239));var c=a;return n.getMode=function(){return r},n.getLength=function(t){return c.length},n.write=function(t){for(var r=0;r>>8)},writeBytes:function(t,e,a){e=e||0,a=a||t.length;for(var n=0;n0&&(r+=","),r+=t[e];return r+="]"}};return r},V=function(t){var r=t,e=0,a=0,n=0,i={read:function(){for(;n<8;){if(e>=r.length){if(0==n)return-1;throw new Error("unexpected end of file./"+n)}var t=r.charAt(e);if(e+=1,"="==t)return n=0,-1;t.match(/^\s$/)||(a=a<<6|o(t.charCodeAt(0)),n+=6)}var i=a>>>n-8&255;return n-=8,i}},o=function(t){if(65<=t&&t<=90)return t-65;if(97<=t&&t<=122)return t-97+26;if(48<=t&&t<=57)return t-48+52;if(43==t)return 62;if(47==t)return 63;throw new Error("c:"+t)};return i},Z=function(t,r){var e=t,a=r,n=new Array(t*r),i={setPixel:function(t,r,a){n[r*e+t]=a},write:function(t){t.writeString("GIF87a"),t.writeShort(e),t.writeShort(a),t.writeByte(128),t.writeByte(0),t.writeByte(0),t.writeByte(0),t.writeByte(0),t.writeByte(0),t.writeByte(255),t.writeByte(255),t.writeByte(255),t.writeString(","),t.writeShort(0),t.writeShort(0),t.writeShort(e),t.writeShort(a),t.writeByte(0);var r=o(2);t.writeByte(2);for(var n=0;r.length-n>255;)t.writeByte(255),t.writeBytes(r,n,255),n+=255;t.writeByte(r.length-n),t.writeBytes(r,n,r.length-n),t.writeByte(0),t.writeString(";")}},o=function(t){for(var r=1<>>r!=0)throw new Error("length over");for(;c+r>=8;)h.writeByte(255&(t<>>=8-c,l=0,c=0;l|=t<0&&h.writeByte(l)}});g.write(r,a);var f=0,d=String.fromCharCode(n[f]);for(f+=1;f=6;)i(t>>>r-6),r-=6},n.flush=function(){if(r>0&&(i(t<<6-r),t=0,r=0),e%3!=0)for(var n=3-e%3,o=0;o=40)throw new Error("Text too long to encode");return gen(t,{size:i,errorCorrectLevel:n,typeNumber:a+1})}var o=parseInt(i/e.getModuleCount()),s=parseInt((i-e.getModuleCount()*o)/2);return e.createImgTag(o,s,i)};const et=t({name:"mosowe-canvas-image",components:{},props:{imgType:{type:String,default:"jpg",validator:()=>["jpg","png"]},compress:{type:Boolean,default:!1},compressSize:{type:[Number,String],default:2097152},showPreview:{type:Boolean,default:!1},height:{type:[String,Number],default:200},width:{type:[String,Number],default:200},lists:{type:Array,default:()=>[]}},data:()=>({canvas:null,listsIndex:0,listsLength:0,canvasArc:null,canvasArcWidth:100,canvasArcHeight:100,compressQuality:20,compressQualityH5:5}),watch:{},beforeCreate(){},created(){this.canvas=r("canvas",this),this.canvasArc=r("canvas-arc",this)},beforeMount(){},mounted(){},beforeUpdate(){},updated(){},beforeDestroy(){},destroyed(){},methods:{createCanvas(){this.clearCanvas(),0!==this.lists.length?(this.listsIndex=0,this.listsLength=this.lists.length-1,a({title:"正在生成图片...",mask:!0}),setTimeout((()=>{n()}),1e4),this.dataDrawCanvas()):e({title:"lists不能为空",icon:"none"})},dataDrawCanvas(){let t=this.lists[this.listsIndex];"image"===t.type?t.content.indexOf("https://")>-1?this.downloadImageH5(t):this.compress&&t.hasOwnProperty("file")&&t.file.size>this.compressSize?this.compressImage(t):t.arc?this.drawImageArc(t):this.drawImage(t):"text"===t.type?this.drawText(t):"rect"===t.type?this.drawRect(t):"arc"===t.type?this.drawArc(t):"qr"===t.type&&this.drawQR(t)},downloadImageH5(t){let r=null;r=new Image,r.setAttribute("crossOrigin","anonymous"),r.crossOrigin="Anonymous",r.src=t.content,r.onload=()=>{let e=document.createElement("canvas");e.width=t.width,e.height=t.height,e.getContext("2d").drawImage(r,0,0,t.width,t.height);let a=e.toDataURL("image/png");t.arc?(t.content=a,this.drawImageArc(t)):(this.canvas.globalAlpha=t.hasOwnProperty("globalAlpha")?t.globalAlpha:1,this.canvas.drawImage(a,t.x,t.y,t.hasOwnProperty("width")?t.width:this.width,t.hasOwnProperty("height")?t.height:this.height),this.checkDrawOver())}},compressImage(t){a({title:"压缩中...",mask:!0});let r=new Image;r.setAttribute("crossOrigin","anonymous"),r.crossOrigin="Anonymous",r.src=t.content,r.onload=()=>{let e=document.createElement("canvas");e.width=t.width,e.height=t.height,e.getContext("2d").drawImage(r,0,0,t.width,t.height);let a=e.toDataURL("image/png");t.content=a,t.arc?this.drawImageArc(t):this.drawImage(t)}},drawImageArc(t){this.canvasArc.clearRect(0,0,this.canvasArcWidth,this.canvasArcHeight),this.canvasArcWidth=2*t.arcR,this.canvasArcHeight=2*t.arcR,this.canvasArc.save();let r=setTimeout((()=>{clearTimeout(r),this.canvasArc.arc(t.arcR,t.arcR,t.arcR,0,2*Math.PI),this.canvasArc.clip(),this.canvasArc.drawImage(t.content,t.arcX,t.arcY,t.width,t.height),this.canvasArc.draw(!1,setTimeout((()=>{let r=setTimeout((()=>{clearTimeout(r),i({x:0,y:0,width:2*t.arcR,height:2*t.arcR,fileType:"png",canvasId:"canvas-arc",success:r=>{t.width=2*t.arcR,t.height=2*t.arcR,t.content=r.tempFilePath,this.drawImage(t)},fail:t=>{console.log(t)},complete:()=>{this.canvasArc.restore(),this.canvasArc.fillRect(0,0,0,0),this.canvasArc.clearRect(0,0,this.canvasArcWidth,this.canvasArcHeight)}},this)}),100)})))}),100)},drawImage(t){this.canvas.globalAlpha=t.hasOwnProperty("globalAlpha")?t.globalAlpha:1,this.canvas.drawImage(t.content,t.x,t.y,t.hasOwnProperty("width")?t.width:this.width,t.hasOwnProperty("height")?t.height:this.height),this.checkDrawOver()},drawText(t){this.canvas.setFillStyle(t.hasOwnProperty("color")?t.color:"#000000"),this.canvas.setFontSize(t.hasOwnProperty("size")?t.size:20),this.canvas.setTextAlign(t.hasOwnProperty("align")?t.align:"left"),this.canvas.globalAlpha=t.hasOwnProperty("globalAlpha")?t.globalAlpha:1,t.maxWidth?this.canvas.fillText(t.content,t.x,t.y,t.maxWidth):this.canvas.fillText(t.content,t.x,t.y),this.checkDrawOver()},drawRect(t){this.canvas.setFillStyle(t.hasOwnProperty("color")?t.color:"#000000"),this.canvas.globalAlpha=t.hasOwnProperty("globalAlpha")?t.globalAlpha:1,this.canvas.fillRect(t.x,t.y,t.width,t.height),this.checkDrawOver()},drawArc(t){this.canvas.arc(t.arcX,t.arcY,t.arcR,0,2*Math.PI),this.canvas.setFillStyle(t.hasOwnProperty("color")?t.color:"#000000"),this.canvas.globalAlpha=t.hasOwnProperty("globalAlpha")?t.globalAlpha:1,this.canvas.fill(),this.canvas.closePath(),this.checkDrawOver()},drawQR(t){let r=t.content.length,e=Math.ceil(r/16);e<4&&(e=4),t.qr=rt(t.content,{size:parseInt(300),typeNumber:e}),this.canvas.globalAlpha=t.hasOwnProperty("globalAlpha")?t.globalAlpha:1,this.canvas.drawImage(t.qr,t.x,t.y,t.hasOwnProperty("width")?t.width:this.width,t.hasOwnProperty("height")?t.height:this.height),this.checkDrawOver()},checkDrawOver(){this.listsIndex{setTimeout((()=>{i({x:0,y:0,width:Number(this.width),height:Number(this.height),fileType:this.imgType,canvasId:"canvas",success:t=>{this.$emit("canvasImage",t.tempFilePath),this.showPreview&&this.showPreviewFn(t.tempFilePath)},fail:t=>{console.log(t)},complete:()=>{n()}},this)}),500)}))},showPreviewFn(t){o({current:0,urls:[t]})},clearCanvas(){this.canvas.clearRect(0,0,this.width,this.height)}}},[["render",function(t,r,e,a,n,i){const o=f,w=d;return s(),h(o,{class:"mosowe-canvas-image"},{default:c((()=>[l(o,{class:"slot-view",onClick:i.createCanvas},{default:c((()=>[u(t.$slots,"default",{},void 0,!0)])),_:3},8,["onClick"]),l(o,{class:"canvas-wrap-box"},{default:c((()=>[l(w,{class:"canvas-wrap","canvas-id":"canvas",style:g("width: "+e.width+"px; height: "+e.height+"px;")},null,8,["style"]),l(w,{class:"canvas-wrap","canvas-id":"canvas-arc",style:g("width: "+n.canvasArcWidth+"px; height: "+n.canvasArcHeight+"px;")},null,8,["style"])])),_:1})])),_:3})}],["__scopeId","data-v-e59ccf0d"]]),at=w(v);const nt=t({data:()=>({canvasUrl:"",group_id:0,lists:[],width:500,height:700,title:"我的二维码",contact:{}}),components:{mosoweCanvasImage:et},onLoad(t){this.group_id=t.group_id?t.group_id:"",this.group_id?(this.title="群二维码",this.getGroupInfo()):this.createUserQr()},methods:{createUserQr(){let t=at.userInfo,r=t.qrUrl??"";if(!r)return e({title:"请重新登陆后再生成二维码",icon:"none"}),void p();this.lists=[{type:"rect",color:"#ffffff",width:this.width,height:this.height,x:0,y:0},{type:"image",content:t.avatar,width:100,height:100,x:70,y:60},{type:"text",content:t.displayName,x:190,y:96,maxWidth:400,color:"#000",size:28},{type:"text",content:t.account,x:190,y:135,maxWidth:400,color:"#999",size:20},{type:"qr",content:r,width:360,height:360,x:70,y:200},{type:"text",content:"扫一扫上面的二维码图案,加我为好友",x:105,y:620,color:"#999",maxWidth:400,size:18}],setTimeout((()=>{this.$refs.mosoweCanvasComponents.createCanvas()}),100)},getGroupInfo(){this.userList=[],this.$api.msgApi.groupInfo({group_id:this.group_id}).then((t=>{let r=t.data;this.contact=r;let e=r.name;e.length>12&&(e=e.substring(0,12)+"..."),this.lists=[{type:"rect",color:"#ffffff",width:this.width,height:this.height,x:0,y:0},{type:"image",content:r.avatar,width:100,height:100,x:200,y:40},{type:"text",content:"群聊:"+e,x:this.width/2,align:"center",y:180,maxWidth:400,color:"#000",size:24},{type:"qr",content:r.qrUrl,width:360,height:360,x:70,y:220},{type:"text",content:"该二维码7天内("+r.qrExpire+"前)有效",x:105,y:640,color:"#999",maxWidth:400,size:18}],setTimeout((()=>{this.$refs.mosoweCanvasComponents.createCanvas()}),100)}))},canvasImage(t){this.canvasUrl=t},saveHeadImgFile(){const t=document.createElement("a");t.style.display="none",t.href=this.canvasUrl,t.setAttribute("download",this.contact.name+".jpg"),t.setAttribute("target","_blank"),document.body.appendChild(t),t.click(),document.body.removeChild(t)}}},[["render",function(t,r,e,a,n,i){const o=x("cu-custom"),u=b,g=f,d=C,w=B(I("mosowe-canvas-image"),et);return s(),h(g,null,{default:c((()=>[l(o,{bgColor:"bg-gradual-green",isBack:!0},{backText:c((()=>[])),content:c((()=>[y(m(n.title),1)])),_:1}),l(g,{class:"mt-20 im-flex im-align-items-center"},{default:c((()=>[l(u,{src:n.canvasUrl,mode:"widthFix",style:{margin:"0 auto"}},null,8,["src"])])),_:1}),n.canvasUrl?(s(),h(g,{key:0,class:"padding flex flex-direction mt-10"},{default:c((()=>[l(d,{class:"cu-btn bg-green lg",onClick:i.saveHeadImgFile},{default:c((()=>[y(" 下载图片 ")])),_:1},8,["onClick"])])),_:1})):A("",!0),l(w,{ref:"mosoweCanvasComponents",lists:n.lists,height:n.height,width:n.width,onCanvasImage:i.canvasImage},null,8,["lists","height","width","onCanvasImage"])])),_:1})}],["__scopeId","data-v-26bfbefe"]]);export{nt as default};