"use strict";

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

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

require("./phone.css");

var _button = _interopRequireDefault(require("../button"));

var _icon = _interopRequireDefault(require("../icon"));

var _tips = _interopRequireDefault(require("../tips"));

var _phoneNumber = _interopRequireDefault(require("./phone-number"));

var _input = _interopRequireDefault(require("../input"));

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

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

/* script */
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
var __vue_script__ = {
  name: (0, _base.createComponentName)('auth-login'),
  components: {
    Button: _button.default,
    PhoneNumber: _phoneNumber.default,
    Icon: _icon.default,
    Input: _input.default
  },
  mixins: [_base.componentMixin],
  inject: ['vm'],
  props: {
    countries: {
      type: Array,
      required: true
    }
  },

  data() {
    return {
      loading: false
    };
  },

  methods: {
    onLogin() {
      var _this = this;

      if (this.loading) return;
      this.loading = true;
      this.vm.requestUms('login', this.vm.form).then(function (res) {
        _this.loading = false;

        _this.vm.onLogin(res.authorization_code, 'password');
      }).catch(function (error) {
        (0, _tips.default)(error);
        _this.loading = false;

        _this.vm.$emit('error', {
          error,
          action: 'login',
          type: 'password'
        });
      });
    }

  }
};
/* template */

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

  var _h = _vm.$createElement;

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

  return _c("div", {
    class: _vm.bem()
  }, [_c("div", {
    class: _vm.bem("title")
  }, [_vm._v("手机号登录")]), _vm._v(" "), _c("div", {
    class: _vm.bem("item")
  }, [_c("PhoneNumber", {
    attrs: {
      countries: _vm.vm.countries,
      name: "username"
    },
    model: {
      value: _vm.vm.form.phone,
      callback: function callback($$v) {
        _vm.$set(_vm.vm.form, "phone", $$v);
      },
      expression: "vm.form.phone"
    }
  })], 1), _vm._v(" "), _c("div", {
    class: _vm.bem("item")
  }, [_c("Input", {
    attrs: {
      label: "密码",
      type: "password",
      name: "password",
      placeholder: "输入6-30位密码",
      maxlength: "30"
    },
    model: {
      value: _vm.vm.form.password,
      callback: function callback($$v) {
        _vm.$set(_vm.vm.form, "password", $$v);
      },
      expression: "vm.form.password"
    }
  })], 1), _vm._v(" "), _c("div", {
    class: _vm.bem("links")
  }, [_c("Button", {
    class: _vm.bem("resetwod"),
    attrs: {
      nativeType: "button",
      type: "text"
    },
    on: {
      click: function click($event) {
        _vm.vm.switchType("resetpwd");
      }
    }
  }, [_vm._v("忘记密码")])], 1), _vm._v(" "), _c("Button", {
    class: _vm.bem("submit"),
    attrs: {
      rect: "",
      type: "primary",
      size: "large",
      nativeType: "submit",
      disabled: this.loading
    },
    on: {
      click: _vm.onLogin
    }
  }, [_vm._v(_vm._s(this.loading ? "登录中…" : "登录"))]), _vm._v(" "), _c("div", {
    class: _vm.bem("third-parties")
  }, [_c("div", {
    on: {
      click: function click($event) {
        _vm.vm.switchType("wechat");
      }
    }
  }, [_c("img", {
    class: _vm.bem("icon-wechat"),
    attrs: {
      src: require("../../assets/img/wechat.svg"),
      alt: "wechat"
    }
  }), _vm._v("\n            微信登录\n        ")]), _vm._v(" "), _c("div", {
    on: {
      click: function click($event) {
        _vm.vm.switchType("qq");
      }
    }
  }, [_c("img", {
    class: _vm.bem("icon-qq"),
    attrs: {
      src: require("../../assets/img/qq.svg"),
      alt: "qq"
    }
  }), _vm._v("\n            QQ登录\n        ")])]), _vm._v(" "), _c("div", {
    class: _vm.bem("footer")
  }, [_c("Button", {
    attrs: {
      type: "text"
    },
    on: {
      click: function click($event) {
        _vm.vm.switchType("register");
      }
    }
  }, [_c("span", [_vm._v("手机号注册")]), _c("Icon", {
    attrs: {
      name: "arrow-right"
    }
  })], 1)], 1)], 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;