lxf
2025-07-16 8588fe30f17d0d28190a279aab8675de0dbf1a5b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// import { getStorage, setStorage, getBrowserLang } from "@/utils/utis";
import { _register, _userInfo } from '@/service/user.api'
import { SET_USERINFO, GET_USERINFO, SET_OUT, CONNECT_WALLET, SET_STATUS } from "@/store/const.store";
import { _getBalance } from '@/service/user.api.js'
export default {
  namespaced: true,
  state: {
    status: 0, // 状态
    gasObj: {}, //
    userInfo: {
      usercode: '', // 
      token: '', // 登录token
      username: ''
    }
  },
  getters: {
    mingStatus: state => state.status,
    isToken: state => state.token,
    userInfo: state => state.userInfo
  },
  mutations: {
    // SET_GAS_OBJ(state,gasObj){
    //   state.gasObj=gasObj
    // },
    [SET_STATUS](state, status) { // 质押状态
      state.status = status;
    },
    [SET_USERINFO](state, info) {
      console.log('用户信息', info)
      state.userInfo = { ...state.userInfo, ...info }
    },
    [SET_OUT](state) { // 退出
      state.userInfo = {}
    }
  },
  actions: {
    // actionsGasObj({commit},data){
    //   commit("SET_GAS_OBJ", data);
    // },
    // actionsLogin({ commit }, data) {
    //   commit("SET_UESR_OBJ", data);
    // },
    async [GET_USERINFO]({ commit }, accounts) { // 发送请求获取信息
      commit(SET_USERINFO, accounts) // 登陆
      let data = await _userInfo()
      commit(SET_USERINFO, data) // 用户信息
      data = await _getBalance()
      commit(SET_USERINFO, { balance: data.money }) // 余额
    },
  },
};