Browse Source

feat: 添加loading

rindy 2 years ago
parent
commit
921fd090b2
1 changed files with 6 additions and 0 deletions
  1. 6 0
      src/components/header/index.vue

+ 6 - 0
src/components/header/index.vue

@@ -41,6 +41,7 @@
     <Toast v-if="showCopyDone" content="复制成功" />
     <Toast v-if="showTips" :content="showTips" :close="() => (showTips = null)" />
     <Login v-if="showLogin" @close="showLogin = false" @user="info => (user = info)" />
+    <Loading v-if="showLoading"/>
     <CopyLink v-if="showLink" @close="showLink = false" @done="showCopyDone = true;showLink = false" />
 </template>
 <script setup>
@@ -48,6 +49,7 @@ import { ref, defineProps, onMounted, watchEffect } from 'vue'
 import { http } from '@/utils/request'
 import browser from '@/utils/browser'
 import Toast from '@/components/dialog/Toast'
+import Loading from '@/components/loading/Loading'
 import Login from './Login'
 import CopyLink from './CopyLink'
 import sync from '@/utils/sync'
@@ -61,6 +63,7 @@ const emits = defineEmits(['update'])
 const user = ref(null)
 const points = ref({ p1: null, p2: null })
 const showLink = ref(false)
+const showLoading = ref(false)
 const showLogin = ref(false)
 const showCopyDone = ref(false)
 const showTips = ref(null)
@@ -127,11 +130,13 @@ const onCancel = () => {
     window.location.href = window.location.href.replace('&adjust', '')
 }
 const onSubmit = () => {
+    showLoading.value = true
     http.post(`smart-site/project/updatePanos`, {
         projectId: props.project.projectId,
         panos: JSON.stringify(points.value),
     })
         .then(response => {
+            showLoading.value = false
             if (response.success) {
                 showTips.value = 'BIM同步成功'
                 setTimeout(() => {
@@ -144,6 +149,7 @@ const onSubmit = () => {
             }
         })
         .catch(() => {
+            showLoading.value = false
             showTips.value = '连接服务器失败'
         })
 }