import Vue from 'vue'
import Rules from './rules.vue';
import i18n from '@/util/lang/lang'

const rulesConstructor = Vue.extend(Rules)

Rules.install = function(Vue) {
  // Vue.component(Rules.name, Rules);
}

let instance;
Rules.show = (title, content) => {
  if(!instance) {
    instance = new rulesConstructor({
      el: document.createElement('div'),
      data () {
        return {
          visible : true,
          showTitle: title,
          showContent: content
        }
      },
      i18n
    })
  
    document.body.appendChild(instance.$el)
  } else {
    instance.visible = true;
    instance.showTitle = title;
    instance.showContent = content;
  }
}

/**
 * 显示游戏规则
 */
Rules.showRules = () => {
  Rules.show('title1', 'content1');
}

/**
 * 显示GT规则
 */
Rules.showGTRules = () => {
  Rules.show('title2', 'content2');
}

/**
 * 显示充值说明
 */
Rules.showIntroRules = () => {
  Rules.show('title3', 'content3');
}

Rules.hide = () =>{
  if(instance) {
    instance.visible = false;
  }
}

export default Rules




