import "./QQ.css";
/* script */
//
//
//
//
//
//
//
//
//
//
//
//
//
import { componentMixin, createComponentName } from '../_utils/component';
import Modal from '../Modal';
import { UMS_URL } from '../_utils/constant';
const __vue_script__ = {
  name: createComponentName('auth-qq'),
  components: {
    Modal
  },
  mixins: [componentMixin],
  inject: ['vm'],

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

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

  },

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

  mounted() {
    window.addEventListener('message', 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 () {
  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 ($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 */

const __vue_inject_styles__ = undefined;
/* scoped */

const __vue_scope_id__ = undefined;
/* module identifier */

const __vue_module_identifier__ = undefined;
/* functional template */

const __vue_is_functional_template__ = false;
/* component normalizer */

import __vue_normalize__ from '../_utils/vue-normalize-component.js';
/* style inject */

/* style inject SSR */

export default __vue_normalize__({
  render: __vue_render__,
  staticRenderFns: __vue_staticRenderFns__
}, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, undefined, undefined);