{ var LZString=function(){var r=String.fromCharCode,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",e={};function t(r,o){if(!e[r]){e[r]={};for(var n=0;n>>8,n[2*e+1]=s%256}return n},decompressFromUint8Array:function(o){if(null==o)return i.decompress(o);for(var n=new Array(o.length/2),e=0,t=n.length;e>=1}else{for(t=1,e=0;e>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[c]}else for(t=s[c],e=0;e>=1;0==--l&&(l=Math.pow(2,h),h++),s[p]=f++,c=String(a)}if(""!==c){if(Object.prototype.hasOwnProperty.call(u,c)){if(c.charCodeAt(0)<256){for(e=0;e>=1}else{for(t=1,e=0;e>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[c]}else for(t=s[c],e=0;e>=1;0==--l&&(l=Math.pow(2,h),h++)}for(t=2,e=0;e>=1;for(;;){if(m<<=1,v==o-1){d.push(n(m));break}v++}return d.join("")},decompress:function(r){return null==r?"":""==r?null:i._decompress(r.length,32768,function(o){return r.charCodeAt(o)})},_decompress:function(o,n,e){var t,i,s,u,a,p,c,l=[],f=4,h=4,d=3,m="",v=[],g={val:e(0),position:n,index:1};for(t=0;t<3;t+=1)l[t]=t;for(s=0,a=Math.pow(2,2),p=1;p!=a;)u=g.val&g.position,g.position>>=1,0==g.position&&(g.position=n,g.val=e(g.index++)),s|=(u>0?1:0)*p,p<<=1;switch(s){case 0:for(s=0,a=Math.pow(2,8),p=1;p!=a;)u=g.val&g.position,g.position>>=1,0==g.position&&(g.position=n,g.val=e(g.index++)),s|=(u>0?1:0)*p,p<<=1;c=r(s);break;case 1:for(s=0,a=Math.pow(2,16),p=1;p!=a;)u=g.val&g.position,g.position>>=1,0==g.position&&(g.position=n,g.val=e(g.index++)),s|=(u>0?1:0)*p,p<<=1;c=r(s);break;case 2:return""}for(l[3]=c,i=c,v.push(c);;){if(g.index>o)return"";for(s=0,a=Math.pow(2,d),p=1;p!=a;)u=g.val&g.position,g.position>>=1,0==g.position&&(g.position=n,g.val=e(g.index++)),s|=(u>0?1:0)*p,p<<=1;switch(c=s){case 0:for(s=0,a=Math.pow(2,8),p=1;p!=a;)u=g.val&g.position,g.position>>=1,0==g.position&&(g.position=n,g.val=e(g.index++)),s|=(u>0?1:0)*p,p<<=1;l[h++]=r(s),c=h-1,f--;break;case 1:for(s=0,a=Math.pow(2,16),p=1;p!=a;)u=g.val&g.position,g.position>>=1,0==g.position&&(g.position=n,g.val=e(g.index++)),s|=(u>0?1:0)*p,p<<=1;l[h++]=r(s),c=h-1,f--;break;case 2:return v.join("")}if(0==f&&(f=Math.pow(2,d),d++),l[c])m=l[c];else{if(c!==h)return null;m=i+i.charAt(0)}v.push(m),l[h++]=i+m.charAt(0),i=m,0==--f&&(f=Math.pow(2,d),d++)}}};return i}();"function"==typeof define&&define.amd?define(function(){return LZString}):"undefined"!=typeof module&&null!=module?module.exports=LZString:"undefined"!=typeof angular&&null!=angular&&angular.module("LZString",[]).factory("LZString",function(){return LZString}); const oss_domain = 'https://matchexpo.obs.cn-north-1.myhuaweicloud.com' let host = '' function getParams(){ const scripts = document.getElementsByTagName('script') for(let script of scripts){ const src = script.src if(src && src.includes('/shareModule/initShare.js')){ let url = new URL(src) host = mpShareModule.host return url.searchParams } } return null } function initModule(){ let params = getParams() if(params.get('url') === undefined){ console.error('多果表单分享初始化失败,分享代码未携带apiUrl') }else{ console.log('多果表单分享初始化成功') class mpShareCard extends HTMLElement { static observedAttributes = ['res'] renderData = {} expoData = {} shadow = null getData(){ window.fetch(`${params.get('url')}/api/expo/info?key=${this.renderData.key}`,{ method: 'GET' }) .then(res => { return res.json() }) .then(json => { if(json.data){ json = json.data } json.images = JSON.parse(json.images) json.social_links = JSON.parse(json.social_links) this.expoData = json this.render() }) .catch(err => { console.error('多果表单分享卡片数据获取失败',err) }) } render(){ console.log('多果表单分享卡片渲染开始') if(!this.shadow){ this.shadow = this.attachShadow({mode: 'open'}) } let url = '' if(this.renderData.utm){ url= `https://s1.matchexpo.cn/${this.renderData.utm}` }else{ url = `${host}/register/${this.renderData.key}` } const body = `
${this.expoData.expo_name}
${this.expoData.content}
` const style = ` ` this.shadow.innerHTML = '' this.shadow.innerHTML = style + body } constructor() { super() } attributeChangedCallback(name, oldValue, newValue) { if(name === 'res'){ let attr = ['key','themecolor','backcolor','fontcolor','cardbuttontext','cardbuttoncolor','cardfontinherit','utm'] let dataArr = LZString.decompressFromBase64(newValue).split(',') if(dataArr[0] !== this.renderData.key){ for(let i = 0; i < dataArr.length; i++){ this.renderData[attr[i]] = dataArr[i] } this.getData() }else{ for(let i = 0; i < dataArr.length; i++){ this.renderData[attr[i]] = dataArr[i] } this.render() } } } } class mpFloatButton extends HTMLElement { static observedAttributes = ['res'] renderData = {} expoData = {} shadow = null getData(){ window.fetch(`${params.get('url')}/api/expo/info?key=${this.renderData.key}`,{ method: 'GET' }) .then(res => { return res.json() }) .then(json => { if(json.data){ json = json.data } json.images = JSON.parse(json.images) json.social_links = JSON.parse(json.social_links) this.expoData = json this.render() }) .catch(err => { console.error('多果表单浮动按钮数据获取失败',err) }) } render() { if(!this.shadow){ this.shadow = this.attachShadow({mode: 'open'}) } let url = '' if(this.renderData.utm){ url= `https://s1.matchexpo.cn/${this.renderData.utm}` }else{ url = `${host}/register/${this.renderData.key}` } const body = `
${this.expoData.expo_name}
${this.renderData.buttontext}
` const style = ` ` this.shadow.innerHTML = '' this.shadow.innerHTML = style + body } constructor() { super() } attributeChangedCallback(name, oldValue, newValue) { if(name === 'res'){ let attr = ['key','themecolor','backcolor','fontcolor','buttontext','buttoncolor','buttonposition','utm'] let dataArr = LZString.decompressFromBase64(newValue).split(',') if(dataArr[0] !== this.renderData.key){ for(let i = 0; i < dataArr.length; i++){ this.renderData[attr[i]] = dataArr[i] } this.getData() }else{ for(let i = 0; i < dataArr.length; i++){ this.renderData[attr[i]] = dataArr[i] } this.render() } } } } customElements.define('mp-share-card', mpShareCard) customElements.define('mp-float-button', mpFloatButton) } } initModule() }