import{_ as e,ad as s,aH as n,az as t,aa as a,b as i,d as o,p as r,w as l,H as f,i as u,o as c,f as d,k as h,v as I,e as g,t as p,F as U,C as m,D as v,R as _}from"./index-2PZN6pGH.js";const b=e({data:()=>({title:"getUserInfo",hasUserInfo:!1,userInfo:{},btnLoading:!1}),computed:{...s(["loginProvider","isUniverifyLogin"])},methods:{...n(["getPhoneNumber"]),getUserInfo(){if(this.btnLoading=!0,this.isUniverifyLogin)this.getPhoneNumber(t("univerifyInfo")).then((e=>{this.hasUserInfo=!0,this.userInfo={phoneNumber:e}})).catch((e=>{console.error("getUserInfo fail:",e),this.hasUserInfo=!1})).finally((()=>{this.btnLoading=!1}));else{if("apple"===this.loginProvider){const e=t("apple_nickname");if(e)return this.hasUserInfo=!0,this.userInfo={nickName:e},void(this.btnLoading=!1)}uni.getUserInfo({provider:this.loginProvider,success:e=>{this.hasUserInfo=!0,this.userInfo=e.userInfo},fail:e=>{console.log("getUserInfo fail",e);let s=e.errMsg;~s.indexOf("uni.login")&&(s="请在登录页面完成登录操作"),uni.getSetting({success:e=>{let n=e.authSetting["scope.userInfo"];a(n?{title:"获取用户信息失败",content:"错误原因"+s,showCancel:!1}:{title:"授权失败",content:"Hello uni-app需要获取您的用户信息，请在设置界面打开相关权限",success:e=>{e.confirm&&uni.openSetting()}})}})},complete:()=>{this.btnLoading=!1}})}},mpGetUserInfo(e){console.log("mpGetUserInfo",e),"getUserInfo:ok"===e.detail.errMsg?(this.hasUserInfo=!0,e.detail&&e.detail.userInfo&&(this.userInfo=e.detail.userInfo)):a({title:"获取用户信息失败",content:"错误原因"+e.detail.errMsg,showCancel:!1})},clear(){this.hasUserInfo=!1,this.userInfo={}}}},[["render",function(e,s,n,t,a,b){const k=i(o("page-head"),f),y=m,x=u,L=v,N=_;return c(),r(x,null,{default:l((()=>[d(k,{title:a.title},null,8,["title"]),d(x,{class:"uni-padding-wrap"},{default:l((()=>[d(x,{style:{background:"#FFF",padding:"40rpx"}},{default:l((()=>[!1===a.hasUserInfo?(c(),r(x,{key:0,class:"uni-hello-text uni-center"},{default:l((()=>[d(y,null,{default:l((()=>[h("请点击下方按钮获取用户头像及昵称或手机号")])),_:1})])),_:1})):I("",!0),!0===a.hasUserInfo?(c(),g(U,{key:1},[d(x,{class:"uni-h4 uni-center uni-common-mt"},{default:l((()=>[h(p(a.userInfo.nickName||a.userInfo.nickname||a.userInfo.gender||a.userInfo.email||a.userInfo.phoneNumber),1)])),_:1}),a.userInfo.avatarUrl||a.userInfo.avatar_url?(c(),r(x,{key:0,style:{padding:"30rpx 0","text-align":"center"}},{default:l((()=>[d(L,{class:"userinfo-avatar",src:a.userInfo.avatarUrl||a.userInfo.avatar_url},null,8,["src"])])),_:1})):I("",!0)],64)):I("",!0)])),_:1}),d(x,{class:"uni-btn-v"},{default:l((()=>[d(N,{onClick:b.clear},{default:l((()=>[h("清空")])),_:1},8,["onClick"])])),_:1})])),_:1})])),_:1})}],["__scopeId","data-v-3bce0985"]]);export{b as default};
