bindAccount.js 1.21 KB
import { maskAccount } from '../../utils/mine-handler';
export default function() {
  return {
    namespaced: true,
    state: {
      alipayAccount: '',
      certName: '',
      nickName: '',
      validStatus: 0
    },
    mutations: {
      addUserAliPayAccount(state, data) {
        let {
          alipayAccount,
          certName,
          nickName,
          validStatus
        } = data;

        // state.alipayAccount = maskAccount(alipayAccount);
        state.alipayAccount = alipayAccount;
        state.nickName = nickName || '';
        state.certName = certName;
        state.validStatus = validStatus;
      }
    },
    actions: {
      async fetchUserAliPayAccount({ commit }) {
        const result = await this.$api.get('/api/ufo/home/getUserAliPayAccount');

        console.log(result);
        if (result.code === 200) {
          commit('addUserAliPayAccount', result.data);
        }
      },
      async bindAliPayAccount({ commit }, {account, name}) {
        const result = await this.$api.get('/api/ufo/home/bindAliPayAccount', {
          alipayAccount: account,
          certName: name
        });

        // commit('addUserAliPayAccount', result.data);
        return result;
      },
    },
  };
}