|
|
|
@ -3,18 +3,29 @@ |
|
|
|
<div class="login-content"> |
|
|
|
<van-nav-bar> |
|
|
|
<template #title> |
|
|
|
<div class="title"> |
|
|
|
登录 |
|
|
|
</div> |
|
|
|
<div class="title">登录</div> |
|
|
|
</template> |
|
|
|
</van-nav-bar> |
|
|
|
<van-form @submit="onSubmit"> |
|
|
|
<van-field v-model="loginParam.secretName" name="secretName" label="用户名" placeholder="用户名" |
|
|
|
:rules="[{ required: true, message: '请填写用户名' }]"/> |
|
|
|
<van-field v-model="loginParam.secretKey" type="password" name="secretKey" label="密码" placeholder="密码" |
|
|
|
:rules="[{ required: true, message: '请填写密码' }]"/> |
|
|
|
<van-field |
|
|
|
v-model="loginParam.secretName" |
|
|
|
name="secretName" |
|
|
|
label="用户名" |
|
|
|
placeholder="用户名" |
|
|
|
:rules="[{ required: true, message: '请填写用户名' }]" |
|
|
|
/> |
|
|
|
<van-field |
|
|
|
v-model="loginParam.secretKey" |
|
|
|
type="password" |
|
|
|
name="secretKey" |
|
|
|
label="密码" |
|
|
|
placeholder="密码" |
|
|
|
:rules="[{ required: true, message: '请填写密码' }]" |
|
|
|
/> |
|
|
|
<div style="margin: 0.42rem"> |
|
|
|
<van-button block type="primary" native-type="submit">登录</van-button> |
|
|
|
<van-button block type="primary" native-type="submit" |
|
|
|
>登录</van-button |
|
|
|
> |
|
|
|
</div> |
|
|
|
</van-form> |
|
|
|
<router-link to="/register" class="link">还没有账号,去注册</router-link> |
|
|
|
@ -22,52 +33,56 @@ |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
<script setup> |
|
|
|
import {reactive} from 'vue'; |
|
|
|
import {userLogin, testLogin} from '../api/Home'; |
|
|
|
import CryptoJS from "crypto-js"; |
|
|
|
import { reactive } from "vue"; |
|
|
|
import { userLogin, testLogin } from "../api/Home"; |
|
|
|
import CryptoJS from "crypto-js"; |
|
|
|
|
|
|
|
const {useCommon} = $globalStore; |
|
|
|
const router = useRouter(); |
|
|
|
const loginParam = reactive({ |
|
|
|
const { useCommon } = $globalStore; |
|
|
|
const router = useRouter(); |
|
|
|
const loginParam = reactive({ |
|
|
|
secretName: "", |
|
|
|
secretKey: "" |
|
|
|
}) |
|
|
|
const userLoginParam = {}; |
|
|
|
userLoginParam.username = loginParam.username; |
|
|
|
userLoginParam.password = loginParam.password; |
|
|
|
const onSubmit = async (values) => { |
|
|
|
secretKey: "", |
|
|
|
}); |
|
|
|
const userLoginParam = {}; |
|
|
|
userLoginParam.username = loginParam.username; |
|
|
|
userLoginParam.password = loginParam.password; |
|
|
|
const onSubmit = async (values) => { |
|
|
|
// await getGoodsnum(); |
|
|
|
// await getLang(); |
|
|
|
// values.secretName = values.name; |
|
|
|
values.secretKey = Encrypt(values.secretKey); |
|
|
|
// return; |
|
|
|
// userLogin(values,success=>{ |
|
|
|
testLogin({"secretName": loginParam.secretName, "secretKey": values.secretKey}, success => { |
|
|
|
testLogin( |
|
|
|
{ secretName: loginParam.secretName, secretKey: values.secretKey }, |
|
|
|
(success) => { |
|
|
|
if (success.success) { |
|
|
|
//企业端 |
|
|
|
router.push({ name: "Home" }); |
|
|
|
//执法端 |
|
|
|
// router.push({name: "enforceHome"}); |
|
|
|
// router.push({ name: "enforceHome" }); |
|
|
|
//设置全局变量 |
|
|
|
useCommon.SET_USER_PHONENUMBER(success.data.phonenumber.toString()); |
|
|
|
useCommon.SET_USER_ID(success.data.userId); |
|
|
|
useCommon.SET_TOKEN(success.data.token); |
|
|
|
// 监听uni-app发送的消息 |
|
|
|
window.addEventListener('message', (event) => { |
|
|
|
console.log('Received message from uni-app:', event.data); |
|
|
|
window.addEventListener("message", (event) => { |
|
|
|
console.log("Received message from uni-app:", event.data); |
|
|
|
// 向uni-app返回消息 |
|
|
|
window.parent.postMessage('Hello, uni-app!', '*'); |
|
|
|
window.parent.postMessage("Hello, uni-app!", "*"); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
console.log("登录失败") |
|
|
|
console.log("登录失败"); |
|
|
|
} |
|
|
|
}, error => { |
|
|
|
console.log("登录失败") |
|
|
|
}) |
|
|
|
}; |
|
|
|
}, |
|
|
|
(error) => { |
|
|
|
console.log("登录失败"); |
|
|
|
}, |
|
|
|
); |
|
|
|
}; |
|
|
|
|
|
|
|
const Encrypt = (passWord) => { |
|
|
|
var keyStr = '1234567898745621'; |
|
|
|
const Encrypt = (passWord) => { |
|
|
|
var keyStr = "1234567898745621"; |
|
|
|
var ivStr = keyStr; |
|
|
|
var key = CryptoJS.enc.Utf8.parse(keyStr); |
|
|
|
var iv = CryptoJS.enc.Utf8.parse(ivStr); |
|
|
|
@ -75,14 +90,14 @@ |
|
|
|
var encrypted = CryptoJS.AES.encrypt(srcs, key, { |
|
|
|
iv: iv, |
|
|
|
mode: CryptoJS.mode.CBC, |
|
|
|
padding: CryptoJS.pad.ZeroPadding |
|
|
|
padding: CryptoJS.pad.ZeroPadding, |
|
|
|
}); |
|
|
|
return CryptoJS.enc.Base64.stringify(encrypted.ciphertext); |
|
|
|
} |
|
|
|
}; |
|
|
|
</script> |
|
|
|
|
|
|
|
<style lang="less" scoped> |
|
|
|
.login-page { |
|
|
|
.login-page { |
|
|
|
width: 100%; |
|
|
|
height: 100%; |
|
|
|
display: flex; |
|
|
|
@ -112,5 +127,5 @@ |
|
|
|
float: right; |
|
|
|
margin-right: 0.4rem; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
</style> |
|
|
|
|