dev
This commit is contained in:
parent
9bddab3122
commit
fd92dc315d
|
|
@ -11,28 +11,64 @@ import {useWsStore} from "@/stores/wsStore.ts";
|
|||
|
||||
const username = ref('')
|
||||
const password = ref('')
|
||||
const rememberMe = ref(false)
|
||||
const router = useRouter();
|
||||
interface NetWorkType{
|
||||
ip: string,
|
||||
mac: string,
|
||||
}
|
||||
const netWork=ref<NetWorkType>({
|
||||
ip: "192.168.1.1",
|
||||
mac: "00-00-00-00-00"
|
||||
})
|
||||
|
||||
|
||||
const handleLogin = () => {
|
||||
if(netWork.value.mac=="00-00-00-00-00"){
|
||||
//提示 获取本地IP地址失败,将使用默认IP地址
|
||||
ElMessage({
|
||||
message: "获取本地IP地址失败,将使用默认IP地址",
|
||||
type: 'warning',
|
||||
duration: 1000,
|
||||
onClose: () => {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
post(apiConfig.ManagerLogin, {username: username.value, password: password.value}).then((token: any) => {
|
||||
localStorage.setItem('token', token)
|
||||
getNetwork()
|
||||
|
||||
// ElMessage({
|
||||
// message: "登录成功,即将为您跳转到首页",
|
||||
// type: 'success',
|
||||
// duration: 1000,
|
||||
// onClose: () => {
|
||||
// router.push("/home/index")
|
||||
// }
|
||||
// })
|
||||
//签到,如果 签到成功,则直接调用success,如果失败,调用error
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
const success = () => {
|
||||
ElMessage({
|
||||
message: "登录成功,即将为您跳转到首页",
|
||||
type: 'success',
|
||||
duration: 1000,
|
||||
onClose: () => {
|
||||
router.push("/home/index")
|
||||
}
|
||||
})
|
||||
}
|
||||
const error = () => {
|
||||
ElMessage({
|
||||
message: "签到失败,我们将已非签到模式启动系统",
|
||||
type: 'warning',
|
||||
duration: 1000,
|
||||
onClose: () => {
|
||||
router.push("/home/index")
|
||||
}
|
||||
})
|
||||
}
|
||||
const wsStore = useWsStore();
|
||||
const reciceMessage = (response: Response) => {
|
||||
post(apiConfig.signUp, {mac:response.Data[0].MACAddress,ip:response.Data[0].IPAddress})
|
||||
console.log(response)
|
||||
}
|
||||
const getNetwork = () => {
|
||||
let data: any = {}
|
||||
|
|
@ -46,6 +82,7 @@ const getNetwork = () => {
|
|||
|
||||
onMounted(async () => {
|
||||
wsStore.setMessageCallback(reciceMessage)
|
||||
getNetwork()
|
||||
});
|
||||
onUnmounted(() => {
|
||||
wsStore.removeAllMessageCallback()
|
||||
|
|
|
|||
Loading…
Reference in New Issue