App.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <template>
  2. <router-view />
  3. <Notify v-model:show="notify.show" :title="notify.title" :content="notify.content" />
  4. </template>
  5. <script lang="ts" setup>
  6. import { reactive } from 'vue'
  7. import { useNavigation } from '@mobile/router/navigation'
  8. import { dialog } from '@/utils/vant'
  9. import { useLogin } from '@/business/login'
  10. import eventBus from '@/services/bus'
  11. import Notify from '@mobile/components/base/notify/index.vue'
  12. const { userLogout } = useLogin()
  13. const { backHome } = useNavigation()
  14. const notify = reactive({
  15. show: false,
  16. title: '',
  17. content: ''
  18. })
  19. // 接收用户登出通知
  20. eventBus.$on('LogoutNotify', (msg) => {
  21. userLogout(() => {
  22. if (msg) {
  23. dialog({
  24. message: msg as string,
  25. confirmButtonText: '确定'
  26. }).then(() => {
  27. backHome()
  28. })
  29. } else {
  30. backHome()
  31. }
  32. })
  33. })
  34. // 接收风控通知
  35. eventBus.$on('RiskToWebNtf', (msg, type) => {
  36. const res = msg as { title: string, content: string }
  37. if (type === 1) {
  38. notify.title = res.title
  39. notify.content = res.content
  40. notify.show = true
  41. } else {
  42. dialog({
  43. title: res.title,
  44. message: res.content,
  45. confirmButtonText: '确定'
  46. })
  47. }
  48. })
  49. </script>