import{ap as p,d as x,r as h,O as I,B as N,aP as j,o as d,l as L,w as m,i,g as v,t as z,c as w,j as U,F as g,a as B,L as D,M as F,_ as H,__tla as M}from"./index-8c6726e5.js";import{_ as O,__tla as X}from"./XTextButton-18b047c6.js";import{S as k}from"./constants-a1da293a.js";import{g as $,__tla as A}from"./profile-a6274c0c.js";import{u as E,__tla as G}from"./useMessage-9f6930df.js";let C,J=Promise.all([(()=>{try{return M}catch{}})(),(()=>{try{return X}catch{}})(),(()=>{try{return A}catch{}})(),(()=>{try{return G}catch{}})()]).then(async()=>{let y,_;y=["src"],_={class:"mr-5"},C=H(x({name:"UserSocial",__name:"UserSocial",props:{activeName:{type:String,required:!0}},emits:["update:activeName"],setup(K,{emit:S}){const f=E(),n=h([]),o=h(),c=I(),b=S,R=()=>{const a=(t="type",new URL(decodeURIComponent(location.href)).searchParams.get(t)??"");var t;const e=c.query.code,s=c.query.state;e&&((l,r,u)=>p.post({url:"/system/social-user/bind",data:{type:l,code:r,state:u}}))(a,e,s).then(()=>{f.success("\u7ED1\u5B9A\u6210\u529F"),b("update:activeName","userSocial")})},q=a=>{const t=location.origin+"/user/profile?"+encodeURIComponent(`type=${a.type}`);((e,s)=>p.get({url:"/system/auth/social-auth-redirect?type="+e+"&redirectUri="+s}))(a.type,encodeURIComponent(t)).then(e=>{window.location.href=e})},P=async a=>{var t,e;await(t=a.type,e=a.openid,p.delete({url:"/system/social-user/unbind",data:{type:t,openid:e}}))&&(a.openid=void 0),f.success("\u89E3\u7ED1\u6210\u529F")};return N(async()=>{await(async()=>{var t;n.value=[];const a=await $();o.value=a;for(const e in k){const s={...k[e]};if(n.value.push(s),(t=o.value)==null?void 0:t.socialUsers){for(const l in o.value.socialUsers)if(s.type===o.value.socialUsers[l].type){s.openid=o.value.socialUsers[l].openid;break}}}})()}),j(()=>c,()=>{R()},{immediate:!0}),(a,t)=>{const e=D,s=O,l=F;return d(),L(l,{data:B(n),"show-header":!1},{default:m(()=>[i(e,{fixed:"left",title:"\u5E8F\u53F7",type:"seq",width:"60"}),i(e,{align:"left",label:"\u793E\u4EA4\u5E73\u53F0",width:"120"},{default:m(({row:r})=>[v("img",{src:r.img,alt:"",class:"h-5 align-middle"},null,8,y),v("p",_,z(r.title),1)]),_:1}),i(e,{align:"center",label:"\u64CD\u4F5C"},{default:m(({row:r})=>[r.openid?(d(),w(g,{key:0},[U(" \u5DF2\u7ED1\u5B9A "),i(s,{class:"mr-5",title:"(\u89E3\u7ED1)",type:"primary",onClick:u=>P(r)},null,8,["onClick"])],64)):(d(),w(g,{key:1},[U(" \u672A\u7ED1\u5B9A "),i(s,{class:"mr-5",title:"(\u7ED1\u5B9A)",type:"primary",onClick:u=>q(r)},null,8,["onClick"])],64))]),_:1})]),_:1},8,["data"])}}}),[["__file","/Users/RuHu.Xu/Desktop/mall-newfeifan-zx-admin/src/views/Profile/components/UserSocial.vue"]])});export{J as __tla,C as default};
