|
@@ -42,7 +42,7 @@
|
|
</Teleport>
|
|
</Teleport>
|
|
</template>
|
|
</template>
|
|
<script setup>
|
|
<script setup>
|
|
-import { ref, onMounted } from 'vue'
|
|
|
|
|
|
+import { ref, onMounted, inject } from 'vue'
|
|
import { http } from '@/utils/request'
|
|
import { http } from '@/utils/request'
|
|
import common from '@/utils/common'
|
|
import common from '@/utils/common'
|
|
import browser from '@/utils/browser'
|
|
import browser from '@/utils/browser'
|
|
@@ -50,11 +50,24 @@ import { useI18n, getLocale } from '@/i18n'
|
|
const projectId = browser.valueFromUrl('projectId') || ''
|
|
const projectId = browser.valueFromUrl('projectId') || ''
|
|
const { t } = useI18n({ useScope: 'global' })
|
|
const { t } = useI18n({ useScope: 'global' })
|
|
const emits = defineEmits(['close', 'user'])
|
|
const emits = defineEmits(['close', 'user'])
|
|
|
|
+const isAuth = inject('isAuth')
|
|
const showpass = ref(false)
|
|
const showpass = ref(false)
|
|
const remember = ref(false)
|
|
const remember = ref(false)
|
|
const username = ref('')
|
|
const username = ref('')
|
|
const password = ref('')
|
|
const password = ref('')
|
|
const errors = ref({})
|
|
const errors = ref({})
|
|
|
|
+const getAuth = () => {
|
|
|
|
+ http.post(`smart-site/validatedProject/${projectId}`)
|
|
|
|
+ .then(res => {
|
|
|
|
+ if (res.code == 0) {
|
|
|
|
+ isAuth.value = true
|
|
|
|
+ } else if (res.code == 4002) {
|
|
|
|
+ //没有权限
|
|
|
|
+ isAuth.value = false
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ .catch(() => {})
|
|
|
|
+}
|
|
const onLogin = () => {
|
|
const onLogin = () => {
|
|
errors.value = {}
|
|
errors.value = {}
|
|
if (!username.value) {
|
|
if (!username.value) {
|
|
@@ -75,10 +88,11 @@ const onLogin = () => {
|
|
phoneNum: username.value,
|
|
phoneNum: username.value,
|
|
rememberMe: remember.value,
|
|
rememberMe: remember.value,
|
|
randomcode: '1234',
|
|
randomcode: '1234',
|
|
- projectId
|
|
|
|
|
|
+ projectId,
|
|
})
|
|
})
|
|
.then(response => {
|
|
.then(response => {
|
|
if (response.success) {
|
|
if (response.success) {
|
|
|
|
+ getAuth()
|
|
if (remember.value) {
|
|
if (remember.value) {
|
|
localStorage.setItem('remember', true)
|
|
localStorage.setItem('remember', true)
|
|
localStorage.setItem('username', username.value)
|
|
localStorage.setItem('username', username.value)
|