import { connect } from 'herculex';

Component(connect({
  mapStateToProps: {
  },
})({
  props: {
    showLoginModal: false,
  },
  data: {},
  methods: {
    onCancel() {
      this.hideLoginModal();
    },
    onSubmit(e) {
      this.commit('$global:updateFormId', {
        formId: e.detail.formId,
      });
      const { scopes } = this.globalState;
      if (!scopes) {
        this.hideLoginModal();
        // 没有scope 走第一种登录方式
        this.dispatchGlobal('doLogin');
      }
    },
    async onGetAuthorize() {
      const { scopes } = this.globalState;

      this.hideLoginModal();
      if (!scopes) return;
      this.dispatchGlobal('doLogin');
    },
    hideLoginModal() {
      this.commit('updateModalStatus', false);
    },
  },
}));
