|
|
@@ -1,7 +1,6 @@
|
|
|
<script setup lang="ts">
|
|
|
import {ElForm, ElFormItem} from "element-plus";
|
|
|
import { ref, computed } from 'vue';
|
|
|
- import axios from "axios";
|
|
|
import {router} from '../router'
|
|
|
import {userLogin} from "../api/user.ts";
|
|
|
|
|
|
@@ -32,27 +31,24 @@
|
|
|
// response
|
|
|
// token: string
|
|
|
async function handleLogin() {
|
|
|
- try {
|
|
|
- const payload = {
|
|
|
- phone: tel.value,
|
|
|
- password: password.value,
|
|
|
- }
|
|
|
- userLogin(payload).then(res => {
|
|
|
- console.log(res)
|
|
|
- // token塞入饼干中
|
|
|
- const token = res.result;
|
|
|
- document.cookie = `token=${token}`
|
|
|
-
|
|
|
- // 路由跳转
|
|
|
- router.push({ path: "/home" })
|
|
|
- })
|
|
|
-
|
|
|
- } catch (e) {
|
|
|
- console.log(e)
|
|
|
- // 可以给用户弹窗
|
|
|
+ const payload = {
|
|
|
+ phone: tel.value,
|
|
|
+ password: password.value,
|
|
|
}
|
|
|
|
|
|
- // router.push({ path: "/home" })
|
|
|
+ userLogin(payload)
|
|
|
+ .then(res => {
|
|
|
+ console.log(res)
|
|
|
+ // token塞入饼干中
|
|
|
+ const token = res.result;
|
|
|
+ document.cookie = `token=${token}`
|
|
|
+
|
|
|
+ // 路由跳转
|
|
|
+ router.push({ path: "/home" })
|
|
|
+ })
|
|
|
+ .catch(e => {
|
|
|
+ console.log(e.message)
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
</script>
|