"use strict";

var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");

exports.__esModule = true;
exports.default = void 0;

require("./index.css");

var _account = _interopRequireDefault(require("./account"));

var _dialog = _interopRequireDefault(require("../../components/dialog"));

var _base = require("../../utils/base");

var _vueNormalizeComponent = _interopRequireDefault(require("../../utils/vue-normalize-component.js"));

/* script */
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
var __vue_script__ = {
  name: (0, _base.createComponentName)('account-dialog'),
  components: {
    GdAccount: _account.default,
    GdDialog: _dialog.default
  },
  mixins: [_base.componentMixin],
  props: {
    thirdpartLogin: {
      type: Array,

      default() {
        return [];
      }

    },
    bindphoneSkipable: {
      type: Boolean,
      default: true
    },
    authUrl: {
      type: Object,
      default: null
    },
    // 显示弹窗
    visible: {
      type: Boolean,
      default: false
    },
    // 界面类型
    tab: {
      // `login` / `register` / `resetpwd` / `bindphone`
      type: String,
      default: 'login'
    },
    // 环境
    appStage: {
      // `production` / `development` / `test`
      type: String,
      default: 'production'
    },
    // [Example](https://st-gdx.dancf.com/gaodingx/2/configs/csc_info/20180905-165022-b807.css)
    styleHref: {
      type: String,
      default: ''
    },
    withoutTips: {
      type: Boolean,
      default: false
    }
  },

  data() {
    return {
      skipable: false,
      showThirdpartLogin: false
    };
  },

  computed: {
    dialogVisible: {
      get() {
        return this.visible;
      },

      set(visible) {
        if (!visible) {
          if (this.bindphoneSkipable && this.tab === 'bindphone') {
            window.frames['gd-account-frame'].window.postMessage({
              type: 'skip'
            }, '*');
            return;
          }

          var err = new Error('User cancel');
          err.canceled = true;
          this.$emit('login-error', err);
        }

        this.$emit('update:visible', visible);
      }

    },
    dialogTab: {
      get() {
        return this.tab;
      },

      set(tab) {
        this.$emit('update:tab', tab);
      }

    }
  },
  methods: {
    onLoginSuccess(data) {
      // 登录 success 提示
      this.$emit('login-success', data);
    },

    onRegisterSuccess(data) {
      this.$emit('register-success', data);
    },

    onLoginError(error) {
      // 登录 error 提示
      this.$emit('login-error', error);
    },

    onUIError(data) {
      // error 提示
      // @arg `{message: string}`
      this.$emit('ui-error', data);
    },

    onUITips(data) {
      // tips 提示
      // @arg `{message: string}`
      this.$emit('ui-tips', data);
    },

    onLoginThirdPart() {
      this.showThirdpartLogin = true;
      this.$emit('login-thirdpart');
    }

  }
};
/* template */

var __vue_render__ = function __vue_render__() {
  var _vm = this;

  var _h = _vm.$createElement;

  var _c = _vm._self._c || _h;

  return _c("GdDialog", {
    staticClass: "gd-account-dialog",
    attrs: {
      showCloseButton: _vm.dialogTab === "bindphone" ? _vm.bindphoneSkipable : true,
      closeBtnText: _vm.dialogTab === "bindphone" ? "跳过" : "X",
      visible: _vm.dialogVisible,
      esc: false
    },
    on: {
      "update:visible": function updateVisible($event) {
        _vm.dialogVisible = $event;
      }
    }
  }, [_vm.dialogVisible ? _c("GdAccount", {
    attrs: {
      thirdpartLogin: _vm.thirdpartLogin,
      tab: _vm.dialogTab,
      appStage: _vm.appStage,
      styleHref: _vm.styleHref,
      withoutTips: _vm.withoutTips,
      authUrl: _vm.authUrl
    },
    on: {
      "update:tab": function updateTab($event) {
        _vm.dialogTab = $event;
      },
      "login-success": _vm.onLoginSuccess,
      "register-success": _vm.onRegisterSuccess,
      "login-error": _vm.onLoginError,
      "ui-error": _vm.onUIError,
      "ui-tips": _vm.onUITips,
      "login-thirdpart": _vm.onLoginThirdPart
    }
  }, [_c("template", {
    slot: "login_title"
  }, [_vm._t("login_title")], 2), _vm._v(" "), _c("template", {
    slot: "login_desc"
  }, [_vm._t("login_desc")], 2), _vm._v(" "), _c("template", {
    slot: "login_subtitle"
  }, [_vm._t("login_subtitle")], 2), _vm._v(" "), _c("template", {
    slot: "register_title"
  }, [_vm._t("register_title")], 2), _vm._v(" "), _c("template", {
    slot: "register_desc"
  }, [_vm._t("register_desc")], 2), _vm._v(" "), _c("template", {
    slot: "register_subtitle"
  }, [_vm._t("register_subtitle")], 2), _vm._v(" "), _c("template", {
    slot: "resetpwd_title"
  }, [_vm._t("resetpwd_title")], 2), _vm._v(" "), _c("template", {
    slot: "resetpwd_desc"
  }, [_vm._t("resetpwd_desc")], 2), _vm._v(" "), _c("template", {
    slot: "resetpwd_subtitle"
  }, [_vm._t("resetpwd_subtitle")], 2), _vm._v(" "), _c("template", {
    slot: "bindphone_title"
  }, [_vm._t("bindphone_title")], 2), _vm._v(" "), _c("template", {
    slot: "bindphone_desc"
  }, [_vm._t("bindphone_desc")], 2), _vm._v(" "), _c("template", {
    slot: "bindphone_subtitle"
  }, [_vm._t("bindphone_subtitle")], 2)], 2) : _vm._e()], 1);
};

var __vue_staticRenderFns__ = [];
__vue_render__._withStripped = true;
/* style */

var __vue_inject_styles__ = undefined;
/* scoped */

var __vue_scope_id__ = undefined;
/* module identifier */

var __vue_module_identifier__ = undefined;
/* functional template */

var __vue_is_functional_template__ = false;
/* component normalizer */

/* style inject */

/* style inject SSR */
var _default = (0, _vueNormalizeComponent.default)({
  render: __vue_render__,
  staticRenderFns: __vue_staticRenderFns__
}, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, undefined, undefined);

exports.default = _default;