|
@@ -14,9 +14,18 @@
|
|
|
<a-input v-model:value="accountValue" placeholder="请输入用户名" />
|
|
|
</a-form-item>
|
|
|
<a-form-item>
|
|
|
- <a-input v-model:value="password" placeholder="请输入密码" />
|
|
|
+ <a-input-password
|
|
|
+ v-model:value="password"
|
|
|
+ type="pa"
|
|
|
+ placeholder="请输入密码"
|
|
|
+ @keypress.enter="login"
|
|
|
+ />
|
|
|
</a-form-item>
|
|
|
|
|
|
+ <div class="tw-text-red-500 tw-pb-4">
|
|
|
+ {{ errorInfo }}
|
|
|
+ </div>
|
|
|
+
|
|
|
<a-button type="primary" @click="login">立即登录</a-button>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -27,18 +36,33 @@
|
|
|
<script setup lang="ts">
|
|
|
import { loginByUsername } from "@/api/loginPage";
|
|
|
import { ref } from "vue";
|
|
|
+import { useRoute, useRouter } from "vue-router";
|
|
|
+import { useMainStore } from "@/store";
|
|
|
+const store = useMainStore();
|
|
|
|
|
|
let accountValue = ref("");
|
|
|
let password = ref("");
|
|
|
-const rootOrgId = "1";
|
|
|
+const route = useRoute();
|
|
|
+const rootOrgId = route.query.rootOrgId as string;
|
|
|
+const router = useRouter();
|
|
|
+if (!rootOrgId) {
|
|
|
+ router.push("/?rootOrgId=1");
|
|
|
+}
|
|
|
+
|
|
|
+let errorInfo = ref("");
|
|
|
|
|
|
async function login() {
|
|
|
- const res = await loginByUsername({
|
|
|
- accountValue: accountValue.value,
|
|
|
- password: password.value,
|
|
|
- rootOrgId: rootOrgId,
|
|
|
- });
|
|
|
- console.log(res);
|
|
|
+ try {
|
|
|
+ const res = await loginByUsername({
|
|
|
+ accountValue: accountValue.value,
|
|
|
+ password: password.value,
|
|
|
+ rootOrgId: rootOrgId,
|
|
|
+ });
|
|
|
+ console.log(res);
|
|
|
+ store.setUserInfo(res.data);
|
|
|
+ } catch (error) {
|
|
|
+ errorInfo.value = (<any>error).response.data.desc;
|
|
|
+ }
|
|
|
}
|
|
|
</script>
|
|
|
|