jinx 2 年之前
父節點
當前提交
57b5e9e187
共有 2 個文件被更改,包括 31 次插入6 次删除
  1. 25 2
      src/components/header/index.vue
  2. 6 4
      src/pages/Viewer.vue

+ 25 - 2
src/components/header/index.vue

@@ -15,7 +15,7 @@
                 </li>
                 </li>
                 <li><em></em></li>
                 <li><em></em></li>
                 <li v-if="user" class="uinfo" @click="showDrop = true">
                 <li v-if="user" class="uinfo" @click="showDrop = true">
-                    <img :src="user.head.indexOf('/newHead.png') != -1 ? user.head : user.head + '&x-oss-process=image/resize,m_fill,w_64,h_64/quality,q_70'" alt="" />
+                    <img :src="creatAvatar(user.head)" alt="" />
                     <div class="menu">
                     <div class="menu">
                         <ul>
                         <ul>
                             <li>
                             <li>
@@ -65,6 +65,7 @@ const props = defineProps({
 })
 })
 const emits = defineEmits(['update', 'getUserId'])
 const emits = defineEmits(['update', 'getUserId'])
 const isLogin = inject('isLogin')
 const isLogin = inject('isLogin')
+const isAuth = inject('isAuth')
 const user = ref(null)
 const user = ref(null)
 const points = ref({ p1: null, p2: null })
 const points = ref({ p1: null, p2: null })
 const showLink = ref(false)
 const showLink = ref(false)
@@ -85,6 +86,16 @@ const openLink = () => {
     showLink.value = true
     showLink.value = true
     showCopyDone.value = false
     showCopyDone.value = false
 }
 }
+const creatAvatar = head => {
+    let url
+    if (head.indexOf('?') != -1) {
+        url = head + '&x-oss-process=image/resize,m_fill,w_64,h_64/quality,q_70'
+    } else {
+        url = head + '?x-oss-process=image/resize,m_fill,w_64,h_64/quality,q_70'
+    }
+
+    return url
+}
 const getCurPosInfo = () => {
 const getCurPosInfo = () => {
     let app = sync.sourceInst
     let app = sync.sourceInst
     let id
     let id
@@ -120,7 +131,18 @@ const onSetP2 = () => {
     points.value.p2 = p2
     points.value.p2 = p2
     emits('update', 'p2', points.value.p2)
     emits('update', 'p2', points.value.p2)
 }
 }
-
+const getAuth = () => {
+    http.post(`smart-site/validatedProject/${props.project.projectId}`)
+        .then(res => {
+            if (res.code == 0) {
+                isAuth.value = true
+            } else if (res.code == 4002) {
+                //没有权限
+                isAuth.value = false
+            }
+        })
+        .catch(() => {})
+}
 const getUserInfo = () => {
 const getUserInfo = () => {
     http.post(`smart-site/getUserInfo`)
     http.post(`smart-site/getUserInfo`)
         .then(response => {
         .then(response => {
@@ -131,6 +153,7 @@ const getUserInfo = () => {
                 }
                 }
                 localStorage.setItem('userId', response.data.id)
                 localStorage.setItem('userId', response.data.id)
                 isLogin.value = true
                 isLogin.value = true
+                getAuth()
             } else {
             } else {
                 if (response.code == 4008) {
                 if (response.code == 4008) {
                     // 未登录
                     // 未登录

+ 6 - 4
src/pages/Viewer.vue

@@ -78,7 +78,7 @@
                         <span>{{ $t('common.measure') }}</span>
                         <span>{{ $t('common.measure') }}</span>
                     </div>
                     </div>
                 </div>
                 </div>
-                <div v-if="isLogin" class="file" :class="{ active: fileChecked, disable: fileDisable }" v-show="!fscChecked && !showBim && !dbsChecked && !bimChecked && !ruleChecked">
+                <div v-if="isLogin && isAuth" class="file" :class="{ active: fileChecked, disable: fileDisable }" v-show="!fscChecked && !showBim && !dbsChecked && !bimChecked && !ruleChecked">
                     <div @click="onFileChecked">
                     <div @click="onFileChecked">
                         <i class="iconfont icon-note1"></i>
                         <i class="iconfont icon-note1"></i>
                         <span>{{ $t('home.tag') }}</span>
                         <span>{{ $t('home.tag') }}</span>
@@ -131,12 +131,14 @@ const isEdit = ref(false)
 const isLogin = ref(false)
 const isLogin = ref(false)
 const isFlying = ref(false)
 const isFlying = ref(false)
 const editTagId = ref(null)
 const editTagId = ref(null)
+const isAuth = ref(false)
 provide('tags', tags)
 provide('tags', tags)
 provide('notify', notify)
 provide('notify', notify)
 provide('isEdit', isEdit)
 provide('isEdit', isEdit)
 provide('editTagId', editTagId)
 provide('editTagId', editTagId)
 provide('isLogin', isLogin)
 provide('isLogin', isLogin)
 provide('isFlying', isFlying)
 provide('isFlying', isFlying)
+provide('isAuth', isAuth)
 const userId = ref(localStorage.getItem('userId') || null)
 const userId = ref(localStorage.getItem('userId') || null)
 
 
 const getUserId = id => {
 const getUserId = id => {
@@ -355,7 +357,7 @@ const onModeChange = targetMode => {
 }
 }
 
 
 const onDensityChange = density => {
 const onDensityChange = density => {
-    if (sync.sourceInst) { 
+    if (sync.sourceInst) {
         sync.sourceInst.loaded.then(sdk => {
         sync.sourceInst.loaded.then(sdk => {
             //console.log('onDensityChange',sync.sourceInst.sceneName, density.type)
             //console.log('onDensityChange',sync.sourceInst.sceneName, density.type)
             let data = sdk.scene.changePointDensity(density.type)
             let data = sdk.scene.changePointDensity(density.type)
@@ -581,7 +583,7 @@ const onP2Click = type => {
     flyToP1P2(points.value.p2)
     flyToP1P2(points.value.p2)
 }
 }
 
 
-const onRuleHandler = (sdk) =>{
+const onRuleHandler = sdk => {
     let rule = sdk.startMeasure()
     let rule = sdk.startMeasure()
     rule.bus.on('end',()=>{
     rule.bus.on('end',()=>{
         setTimeout(() => {
         setTimeout(() => {
@@ -692,7 +694,7 @@ onMounted(() => {
                 fscChecked.value = false
                 fscChecked.value = false
             }
             }
         }
         }
-    });
+    })
 })
 })
 </script>
 </script>