index.js 1009 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import i18n from '@/util/lang/lang'
  2. let dom = null
  3. async function asyncConstructor (Vue, comp) {
  4. if (!comp) {
  5. let component = await import('./index.vue')
  6. comp = Vue.extend(component.default)
  7. return comp
  8. }
  9. return comp
  10. }
  11. const Invite = {}
  12. Invite.install = function (Vue, store, router) {
  13. let instance
  14. Vue.prototype.$showInvite = async (type, ext) => {
  15. let Constructor = await asyncConstructor(Vue, dom)
  16. if (instance) {
  17. document.body.removeChild(instance.$el)
  18. instance = null
  19. }
  20. instance = new Constructor({
  21. el: document.createElement('div'),
  22. router,
  23. computed: {
  24. $store () { return store }
  25. },
  26. i18n,
  27. data () {
  28. return {
  29. visible: true,
  30. inviteType: type, // 弹框邀请类型{1:建群,2:邀请好友进群,3:删除群好友,4:添加群管理,5:转让群主}
  31. ext // 额外数据
  32. }
  33. }
  34. })
  35. document.body.appendChild(instance.$el)
  36. }
  37. }
  38. export default Invite