"use strict";const e=require("../../common/vendor.js"),t=require("../../components/request.js"),i=require("../../components/debug/GenerateTestUserSig.js"),n=require("../../components/TUILogin.js"),o=require("../../stores/counter.js").useCounterStore(),s={inject:["$global"],data:()=>({userInfo:{},info:{},userSig:"",lastPage:"",myuserSig:""}),onLoad(){e.index.getUserInfo({provider:"weixin",success:e=>{this.userInfo=e.userInfo}}),e.index.getStorage({key:"lastPage",success:e=>{this.lastPage="/"+e.data},fail:()=>{this.lastPage="/pages/Home/Home"}})},methods:{Return(){e.index.reLaunch({url:"/pages/Home/Home"})},async getPhoneNumber(s){if(null==s.detail.code)return void e.index.showToast({title:"登录失败",icon:"none"});e.index.showLoading({title:"登录中...",mask:!0});const a=await t.request({url:"user/loginWithPhoneNumber",method:"POST",data:{code:s.detail.code},userInfo:!1});this.info=a;const r=Number(this.info.data.chatInfo.appId);this.userSig=i.genTestUserSig({SDKAPPID:r,SECRETKEY:this.info.data.chatInfo.appKey,userID:"administrator"}),this.myuserSig=i.genTestUserSig({SDKAPPID:r,SECRETKEY:this.info.data.chatInfo.appKey,userID:String(a.data.info.id)}),e.index.setStorageSync("myuserSig",this.myuserSig),e.index.setStorageSync("chatInfo",this.info.data.chatInfo),e.index.setStorageSync("userSig",this.userSig),e.index.setStorageSync("userinfo",this.info.data.info),o.$patch({myitem:this.info.data.info}),200===this.info.code?this.info.data.newAccount?(e.index.reLaunch({url:"/pages/UserInformation/UserInformation"}),n.TUIlogin(this.info.data.chatInfo.appId,this.info.data.info.id,this.myuserSig.userSig),e.index.hideLoading()):(e.index.setStorageSync("userinfo",this.info.data.info),n.TUIlogin(this.info.data.chatInfo.appId,this.info.data.info.id,this.myuserSig.userSig),e.index.hideLoading(),e.index.reLaunch({url:this.lastPage})):e.index.showToast({title:"登录失败",icon:"none"})}}};const a=e._export_sfc(s,[["render",function(t,i,n,o,s,a){return{a:e.o$1(((...e)=>a.Return&&a.Return(...e))),b:s.userInfo.avatarUrl,c:e.t(s.userInfo.nickName),d:e.o$1(((...e)=>a.getPhoneNumber&&a.getPhoneNumber(...e)))}}]]);wx.createPage(a);
