u
This commit is contained in:
1 parent
35951777b0
commit
63f1d4d1dc
39 files changed
+880
-133
No files matched your search
@@ -0,0 +1,127 @@
|
||||
<script setup>
|
||||
import { ElMessage } from 'element-plus'
|
||||
|
||||
import { ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
import { useUserStore } from '@/stores/userStore'
|
||||
import { axiosPost } from '@/utils/axios'
|
||||
|
||||
const userStore = useUserStore()
|
||||
|
||||
const router = useRouter()
|
||||
const form = ref({
|
||||
orgid: userStore.userInfo.orgid,
|
||||
userid: userStore.userInfo.userid,
|
||||
password: '',
|
||||
})
|
||||
const loginLoading = ref(false)
|
||||
|
||||
async function onLogin() {
|
||||
loginLoading.value = true
|
||||
try {
|
||||
const resData = await axiosPost(
|
||||
'/login',
|
||||
{
|
||||
orgid: form.value.orgid,
|
||||
userid: form.value.userid,
|
||||
password: form.value.password,
|
||||
},
|
||||
)
|
||||
if (resData.token) {
|
||||
userStore.setUserInfo(form.value.orgid, form.value.userid, resData.userInfo.username, resData.token)
|
||||
ElMessage.success(resData.message || '登录成功')
|
||||
router.push('/home')
|
||||
}
|
||||
else {
|
||||
ElMessage.error(resData.message || '登录失败')
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
ElMessage.error(`请求错误:${err.response?.data?.message || err.message}`)
|
||||
}
|
||||
finally {
|
||||
loginLoading.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="app">
|
||||
<div class="login">
|
||||
<div class="login-left">
|
||||
<img src="/vite.svg" alt="Logo">
|
||||
</div>
|
||||
<div class="login-right">
|
||||
<div class="login-right-title">
|
||||
Online
|
||||
</div>
|
||||
<el-form :model="form" label-width="auto" label-position="top" size="large">
|
||||
<el-form-item label="用户名" required>
|
||||
<el-input v-model="form.userid" style="height: 36px !important" />
|
||||
</el-form-item>
|
||||
<el-form-item label="密码">
|
||||
<el-input
|
||||
v-model="form.password" type="password" show-password style="height: 36px !important"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button
|
||||
type="primary" :loading="loginLoading" style="width: 100%; margin-top: 16px"
|
||||
@click="onLogin"
|
||||
>
|
||||
登录
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="css">
|
||||
.app {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.login {
|
||||
display: flex;
|
||||
width: 1000px;
|
||||
height: 500px;
|
||||
overflow: hidden;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0px 6px 24px -8px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.login-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 60%;
|
||||
padding: 32px;
|
||||
border-right: 1px solid #e9e9e9;
|
||||
}
|
||||
|
||||
.login-left img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.login-right {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 24px;
|
||||
justify-content: center;
|
||||
width: 50%;
|
||||
padding: 32px;
|
||||
}
|
||||
|
||||
.login-right-title {
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,67 @@
|
||||
<script setup>
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useUserStore } from '@/stores/userStore'
|
||||
import { axiosGet, axiosPost } from '@/utils/axios'
|
||||
import { useWebSocket } from '../../stores/websocketStore'
|
||||
|
||||
const userStore = useUserStore()
|
||||
const websocket = useWebSocket()
|
||||
|
||||
const tableData = ref([])
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
const res = await axiosGet('/loadCompanyList')
|
||||
tableData.value = res.data
|
||||
}
|
||||
catch (err) {
|
||||
ElMessage.error(`请求错误:${err.response?.data?.message || err.message}`)
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="home-container">
|
||||
<div class="welcome">
|
||||
{{ userStore.userInfo.username }},欢迎登录
|
||||
</div>
|
||||
<div class="home-header">
|
||||
IM 聊天列表(支持多公司,单公司聊天)
|
||||
</div>
|
||||
<el-table :data="tableData" border stripe style="width: 50%;">
|
||||
<el-table-column prop="b_name" label="用户名称" />
|
||||
<el-table-column prop="_online" label="在线状态" />
|
||||
|
||||
<el-table-column fixed="right" label="操作">
|
||||
<template #default="scope">
|
||||
<el-button v-if="userStore.userInfo.userid !== scope.row.b_id" link type="primary" size="small">
|
||||
聊天
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.home-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
margin: 40px 20px;
|
||||
}
|
||||
|
||||
.welcome {
|
||||
font-size: 16px;
|
||||
color: #555;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.home-header {
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
margin-bottom: 24px;
|
||||
color: #333;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user