"use strict";var e=require("../../common/vendor.js"),o=require("../../api/user.js");require("../../common/request.js");const n={components:{wxAuth:()=>"../components/wxAuth.js"},data:()=>({wxShow:!1,isAgreement:!1,code:null}),computed:{},onLoad(o){e.index.$on("refreshLogin",(()=>{e.index.navigateBack({delta:1})})),this.getCode()},onUnload(){},mounted(){},methods:{updateUser(){this.wxShow=!1,e.index.$emit("refreshLogin"),e.index.$emit("refreshIM")},wxAuthOpen(){this.wxShow=!0;var e=this;setTimeout((function(){e.$refs.wxauth.getUserInfo()}))},wxAuthClose(){this.wxShow=!1},wxLogin(o){if(!this.isAgreement)return e.index.showToast({icon:"none",title:"请先同意协议后再登录"}),!1;e.index.showLoading({title:"处理中..."}),this.$getProvider().then((n=>{console.log("当前的环境商",n),n||reject(),e.index.login({provider:n,success:async e=>{console.log(111),console.log(o),console.log(e)}})})).catch((o=>{e.index.showToast({icon:"none",title:o})}))},handleAgree(){this.isAgreement||e.index.showToast({icon:"none",title:"请先同意协议后再登录"})},openContent(o){console.log(o),e.index.navigateTo({url:"/pages_user/agreement?type="+o})},handleAgreement(){this.isAgreement=!this.isAgreement},getCode(){var o=this;o.$getProvider().then((n=>{n||reject(),e.index.login({provider:n,success:async e=>{o.code=e.code}})})).catch((e=>{}))},phoneLogin(n){var t=this;e.index.showLoading({title:"处理中"}),console.log(n),"getPhoneNumber:ok"==n.detail.errMsg?this.$getProvider().then((i=>{console.log("当前的环境商",i),i||reject(),e.index.login({provider:i,success:async i=>{console.log(i);let s=i.code;var r=e.index.getStorageSync("tuiUserId");o.wxLogin({encryptedData:n.detail.encryptedData,iv:n.detail.iv,code:s,tuiUserId:r}).then((o=>{e.index.hideLoading(),200==o.code?(e.index.showToast({icon:"none",title:"登录成功"}),e.index.setStorageSync("AppToken",o.token),e.index.setStorageSync("userId",o.user.userId),e.index.setStorageSync("avatar",o.user.avatar),e.index.setStorageSync("nickName",o.user.nickName),0==o.user.isWeixinAuth?t.wxAuthOpen():(e.index.$emit("refreshLogin"),e.index.$emit("refreshIM"))):e.index.showToast({icon:"none",title:"授权登录失败,请重新登录"})})).catch((o=>{console.log(o),e.index.hideLoading(),e.index.showToast({icon:"none",title:"授权登录失败,请重新登录"})}))}})})).catch((e=>{})):e.index.showToast({title:"已拒绝授权",icon:"none",duration:2e3})},back(){e.index.reLaunch({url:"/pages/index/index",animationType:"pop-in",animationDuration:100})}}};if(!Array){(e.resolveComponent("wx-auth")+e.resolveComponent("u-popup"))()}Math;var t=e._export_sfc(n,[["render",function(o,n,t,i,s,r){return e.e({a:e.o(((...e)=>r.phoneLogin&&r.phoneLogin(...e))),b:0==s.isAgreement},0==s.isAgreement?{c:e.o((e=>r.handleAgree()))}:{},{d:e.o(((...e)=>r.back&&r.back(...e))),e:s.isAgreement,f:e.o((e=>r.handleAgreement())),g:e.o((e=>r.handleAgreement())),h:e.o((e=>r.openContent("userRegister"))),i:e.o((e=>r.openContent("userPrivacy"))),j:e.sr("wxauth","1e427071-1,1e427071-0"),k:e.o((e=>r.updateUser())),l:e.o(r.wxAuthClose),m:e.o(r.wxAuthOpen),n:e.p({bgColor:"#f6f6f6",safeAreaInsetBottom:!1,round:15,mode:"bottom",show:s.wxShow})})}]]);wx.createPage(t);
