"use strict";

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

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

require("./QQ.css");

var _component = require("../_utils/component");

var _Modal = _interopRequireDefault(require("../Modal"));

var _constant = require("../_utils/constant");

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

/* script */
//
//
//
//
//
//
//
//
//
//
//
//
//
var __vue_script__ = {
  name: (0, _component.createComponentName)('auth-qq'),
  components: {
    Modal: _Modal.default
  },
  mixins: [_component.componentMixin],
  inject: ['vm'],

  data() {
    return {
      visible: true
    };
  },

  watch: {
    visible(value) {
      if (!value) {
        this.vm.switchType(this.vm.lastType);
      }
    }

  },

  created() {
    this.src = _constant.UMS_URL + '/sso/qq';
  },

  mounted() {
    var _this = this;

    window.addEventListener('message', function (event) {
      if (event.data) {
        if (event.data.action === 'login.success') {
          _this.vm.onLogin(event.data.data.authorization_code, 'qq');

          _this.vm.switchType(_this.vm.lastType);
        } else if (event.data.action === 'bindphone') {
          _this.vm.bindphoneType = 'qq';

          _this.vm.switchType('bindphone');
        }
      }
    });
  }

};
/* 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("Modal", {
    class: _vm.bem("modal"),
    attrs: {
      visible: _vm.visible,
      width: "886px"
    },
    on: {
      "update:visible": function updateVisible($event) {
        _vm.visible = $event;
      }
    }
  }, [_vm._m(0)])], 1);
};

var __vue_staticRenderFns__ = [function () {
  var _vm = this;

  var _h = _vm.$createElement;

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

  return _c("iframe", {
    class: _vm.bem("qq"),
    attrs: {
      src: _vm.src,
      frameborder: "0"
    }
  });
}];
__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;