"use strict";const e=require("../../common/vendor.js"),i=require("../../components/request.js"),s=require("../../components/postFile.js"),t=require("../../components/generateFileName.js"),n=require("../../stores/counter.js").useCounterStore(),o={inject:["$global"],data:()=>({userinfo:"",name:"",id:"",info:{},userSig:"",lastPage:"",picture:"",Filename:t.generateFileName()}),onLoad(i){e.index.getStorage({key:"userinfo",success:e=>{this.id=e.data.id}}),e.index.getStorage({key:"userSig",success:e=>{this.userSig=e.data}}),e.index.getStorage({key:"lastPage",success:e=>{this.lastPage="/"+e.data},fail:()=>{this.lastPage="/pages/Home/Home"}})},methods:{inputName(e){this.name=e.detail.value},async Userinfo(e){const{avatarUrl:i}=e.detail;this.userinfo=i},async wxLogin(t){if(""!==this.name&&""!==this.userinfo){e.index.showLoading({title:"登录中...",mask:!0});const{code:t}=await e.index.login({provider:"weixin",onlyAuthorize:!0});s.uploadFile({path:this.userinfo,name:this.Filename}).then((s=>{this.picture=s.split("/").pop(),i.request({url:"user/inputUserInfo",method:"POST",data:{id:this.id,headerIcon:this.Filename,nickName:this.name,code:t,usersig:this.userSig.userSig},userInfo:!1}).then((i=>{200===i.code?(e.index.showToast({title:"登录成功",icon:"success"}),e.index.setStorageSync("userinfo",i.data.info),n.$patch({myitem:i.data.info}),e.index.hideLoading(),e.index.reLaunch({url:this.lastPage})):e.index.showToast({title:"登录失败",icon:"none"})}))})).catch((e=>{console.log(e)}))}else e.index.showToast({title:"请填写头像昵称",icon:"success",duration:3e3})}}};const a=e._export_sfc(o,[["render",function(i,s,t,n,o,a){return{a:o.userinfo,b:e.o$1(((...e)=>a.Userinfo&&a.Userinfo(...e))),c:e.o$1(((...e)=>a.inputName&&a.inputName(...e))),d:e.o$1(((...e)=>a.wxLogin&&a.wxLogin(...e)))}}],["__scopeId","data-v-e6c386ec"]]);wx.createPage(a);
