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

        state.alipayAccount = maskAccount(alipayAccount);
        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;
      },
    },
  };
}