"use strict";const e=require("../../common/vendor.js"),i=require("../../components/request.js"),t=require("../../components/debug/GenerateTestUserSig.js"),n=require("../../components/TUILogin.js"),s=require("../../stores/counter.js").useCounterStore(),o={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:{async getPhoneNumber(o){e.index.showLoading({title:"登录中...",mask:!0});const a=await i.request({url:"user/loginWithPhoneNumber",method:"POST",data:{code:o.detail.code},userInfo:!1});this.info=a;const r=Number(this.info.data.chatInfo.appId);this.userSig=t.genTestUserSig({SDKAPPID:r,SECRETKEY:this.info.data.chatInfo.appKey,userID:"administrator"}),this.myuserSig=t.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),s.$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(o,[["render",function(i,t,n,s,o,a){return{a:o.userInfo.avatarUrl,b:e.t(o.userInfo.nickName),c:e.o$1(((...e)=>a.getPhoneNumber&&a.getPhoneNumber(...e)))}}]]);wx.createPage(a);
