import{d as e}from"./vendor-CB_mu4eO.js";import{f as n,u as t,R as r,j as o,E as l}from"./souav-BTAG2baT.js";import{u as a}from"./vendor-C03G4T8j.js";import{j as u,k as i}from"./vendor-BJZ6tUoe.js";import{r as s,c as v}from"./vendor-BXdGExd0.js";const c=e("promotionCenter",()=>{const e=n(),c=t(),d=s([]),f=s(r.loading),m=v(()=>{var e;return(null==(e=c.config)?void 0:e.spreadDesc)||"推广描述加载中..."}),h=v(()=>{if(0===d.value.length)return"";const n=d.value.find(n=>{var t;return n.level===(null==(t=e.userInfo)?void 0:t.level)});return(null==n?void 0:n.levelName)||""}),p=v(()=>{var n;if(0===d.value.length)return"";const t=(null==(n=e.userInfo)?void 0:n.level)||0;if(d.value[d.value.length-1].level===t)return d.value[d.value.length-1].levelName||"";const r=d.value.find(e=>e.level===t+1);return(null==r?void 0:r.levelName)||""}),g=v(()=>{var n;return 100*((null==(n=e.userInfo)?void 0:n.upgradePercent)??0)}),C=v(()=>{var n,t;return null==(t=null==(n=e.userInfo)?void 0:n.shareContent)?void 0:t.url}),y=v(()=>{var n,t;return null==(t=null==(n=e.userInfo)?void 0:n.shareContent)?void 0:t.title});async function L(){try{f.value=r.loading;const e=await o.userLevelConfig(),{code:n,data:t}=e;n===l.Success?(d.value=(null==t?void 0:t.levelConfigList)||[],f.value=0===d.value.length?r.EmptyData:r.success):f.value=r.NetError}catch(e){f.value=r.NetError}}return{shareTitle:y,qrCodeUrl:C,levelList:d,refreshStatus:f,curLevelName:h,nextLevelName:p,upgradePercent:g,spreadDesc:m,init:function(){L(),e.refreshUserInfo()},getPromoteCondition:function(e){return 0===e.level?"":1===e.level?"(注册登录)":`(推广${e.inviteNum}人)`},reqLevelConfigList:L,onNetErrorRefresh:function(){L()},copyInviteCode:async function(){var n;if(null==(n=e.userInfo)?void 0:n.inviteCode)try{const{copy:n}=a();await n(e.userInfo.inviteCode),u("复制成功")}catch(t){u("复制失败")}},promotionRules:["1. 邀请好友注册并升级VIP，您可获得对应奖励","2. 好友使用您的邀请码注册即可建立邀请关系","3. 邀请奖励将在好友完成支付后自动发放","4. 对于恶意刷奖励的行为，平台将收回奖励并封禁账号"],handleQrClick:()=>{i({title:"确认",message:"您确认要下载二维码吗？",confirmButtonText:"下载",cancelButtonText:"取消"}).then(()=>{const e=(()=>{const e=document.querySelector("#qr_code canvas");return null==e?void 0:e.toDataURL("image/png")})();e&&(async(e,n)=>{try{const t=await fetch(e),r=await t.blob(),o=document.createElement("a"),l=window.URL.createObjectURL(r);o.href=l,o.download=n,document.body.appendChild(o),o.click(),document.body.removeChild(o),window.URL.revokeObjectURL(l)}catch(t){u("下载失败")}})(e,`invite_code_${Date.now()}.png`)}).catch(()=>{})}}});export{c as u};
