index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <div
  3. class="relative size-full bg-[url('@/assets/images/login-bg.png')] bg-[length:100%_100%] bg-no-repeat"
  4. >
  5. <img
  6. class="absolute top-11 left-15 h-11 w-69"
  7. src="@/assets/images/taiji-logo.png"
  8. />
  9. <div
  10. class="absolute top-0 right-0 flex h-full w-[42.5rem] items-center justify-center bg-[var(--czr-dialog-bg)]"
  11. >
  12. <div class="flex w-[26.5rem] flex-col" v-loading="state.loading">
  13. <template v-if="state.detail">
  14. <div class="text-[1.88rem] font-bold text-[#373D4C]">
  15. {{ state.detail.userName }}邀请您加入
  16. </div>
  17. <div class="mt-4 text-[1.88rem] font-bold text-[#3363DE]">
  18. {{ state.detail.tenantName }}组织
  19. </div>
  20. <div
  21. class="mt-4 text-[1.88rem] font-bold text-[#3363DE]"
  22. v-if="state.detail.type == 0"
  23. >
  24. 成为管理员
  25. </div>
  26. <div
  27. class="__hover mt-2 mt-12 flex h-[2.5rem] w-full items-center justify-center bg-[#3363DE] text-sm text-[#ffffff]"
  28. @click="onSubmit"
  29. v-loading="state.loading"
  30. >
  31. 加入组织
  32. </div>
  33. <div class="mt-3 text-sm text-[#576275]">
  34. 链接将在
  35. <span class="text-[#3363DE]">{{ state.detail.validateTime }}</span>
  36. 失效
  37. </div>
  38. </template>
  39. <template v-else>
  40. <div class="text-[1.88rem] font-bold text-[#373D4C]">无效的链接</div>
  41. </template>
  42. </div>
  43. </div>
  44. </div>
  45. </template>
  46. <script setup lang="ts">
  47. import { computed, getCurrentInstance, reactive, ref, onMounted } from 'vue'
  48. import { User, Lock, Clock } from '@element-plus/icons-vue'
  49. import { ElMessage } from 'element-plus'
  50. import { useRoute, useRouter } from 'vue-router'
  51. import { useAppStore } from '@/stores'
  52. import { accountLinkAccess, accountOpenLink } from '@/api/modules/global/invite'
  53. const AppStore = useAppStore()
  54. const router = useRouter()
  55. const route = useRoute()
  56. const emit = defineEmits([])
  57. const props = defineProps({})
  58. const { proxy }: any = getCurrentInstance()
  59. const state: any = reactive({
  60. inviteCode: route.query.inviteCode,
  61. loading: false,
  62. detail: null,
  63. })
  64. const onSubmit = () => {
  65. if (!state.loading) {
  66. state.loading = true
  67. accountLinkAccess({
  68. tenantId: state.detail.tenantId,
  69. type: state.detail.type,
  70. userId: AppStore.userInfo?.id,
  71. })
  72. .then(({ data }: any) => {
  73. ElMessage.success('加入组织成功!')
  74. router.replace({ name: 'root' })
  75. AppStore.initUserInfo()
  76. })
  77. .catch(() => {})
  78. .finally(() => {
  79. state.loading = true
  80. })
  81. }
  82. }
  83. const errorMsg = () => {}
  84. onMounted(() => {
  85. initDetail()
  86. })
  87. const initDetail = () => {
  88. state.loading = true
  89. if (state.inviteCode) {
  90. accountOpenLink(state.inviteCode)
  91. .then(({ data }: any) => {
  92. state.detail = data
  93. })
  94. .catch(() => {})
  95. .finally(() => {
  96. state.loading = false
  97. })
  98. } else {
  99. errorMsg()
  100. }
  101. }
  102. </script>
  103. <style lang="scss" scoped></style>