|
@@ -1,42 +1,80 @@
|
|
<script setup>
|
|
<script setup>
|
|
-import { ref } from 'vue';
|
|
|
|
|
|
+import { ref, unref } from 'vue';
|
|
|
|
+import { userApi } from '@/api/login';
|
|
|
|
+import { useUserStore } from '@/stores/modules/userStore';
|
|
|
|
+
|
|
|
|
+const REMOTE_PATH = {
|
|
|
|
+ logo: 'https://static.fuxicarbon.com/bigModel/wechat/login/img-desc.png',
|
|
|
|
+ username: 'https://static.fuxicarbon.com/bigModel/wechat/login/icon-username.png',
|
|
|
|
+ password: 'https://static.fuxicarbon.com/bigModel/wechat/login/icon-password.png'
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+const userStore = useUserStore();
|
|
|
|
|
|
-const showPassword = ref(false);
|
|
|
|
-const formData = ref({
|
|
|
|
- username: '',
|
|
|
|
- password: ''
|
|
|
|
|
|
+const showPasswordIcon = ref(false);
|
|
|
|
+const loading = ref(false);
|
|
|
|
+const loginFormData = ref({
|
|
|
|
+ username: 'admin',
|
|
|
|
+ password: 'admin123'
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+const handleSubmit = async () => {
|
|
|
|
+
|
|
|
|
+ const { username, password } = unref(loginFormData);
|
|
|
|
+
|
|
|
|
+ if (!username) {
|
|
|
|
+ return uni.showToast({ icon: 'none', title: "请输入账号", duration: 3 * 1000 });
|
|
|
|
+ }
|
|
|
|
+ if (!password) {
|
|
|
|
+ return uni.showToast({ icon: 'none', title: "请输入密码", duration: 3 * 1000 });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ loading.value = true;
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ const { token } = await userApi.postLogin({ username, password });
|
|
|
|
+
|
|
|
|
+ userStore.setUserInfo({ token });
|
|
|
|
+
|
|
|
|
+ const { user } = await userApi.getUserInfo();
|
|
|
|
+
|
|
|
|
+ userStore.setUserInfo({ ...user });
|
|
|
|
+
|
|
|
|
+ await uni.showToast({ icon: 'none', title: "登录成功", duration: 2 * 1000});
|
|
|
|
+
|
|
|
|
+ setTimeout(() => uni.redirectTo({url: '/pages/home/index'}), 2 * 1000);
|
|
|
|
+ } catch (error) {
|
|
|
|
+ console.log("打印error", error);
|
|
|
|
+ } finally {
|
|
|
|
+ loading.value = false;
|
|
|
|
+ }
|
|
|
|
+}
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<template>
|
|
<template>
|
|
-
|
|
|
|
<view class="login-viewport">
|
|
<view class="login-viewport">
|
|
<TheNavBar title-text="登录" class="nav-bar"></TheNavBar>
|
|
<TheNavBar title-text="登录" class="nav-bar"></TheNavBar>
|
|
-
|
|
|
|
<view class="login-content">
|
|
<view class="login-content">
|
|
-
|
|
|
|
<view class="logo-inner">
|
|
<view class="logo-inner">
|
|
- <image src="https://static.fuxicarbon.com/bigModel/wechat/login/img-desc.png" class="img-desc"></image>
|
|
|
|
|
|
+ <image :src="REMOTE_PATH.logo" class="img-desc"></image>
|
|
</view>
|
|
</view>
|
|
-
|
|
|
|
<view class="form-inner">
|
|
<view class="form-inner">
|
|
<view class="login-form-item">
|
|
<view class="login-form-item">
|
|
- <image src="https://static.fuxicarbon.com/bigModel/wechat/login/icon-username.png" class="image"></image>
|
|
|
|
- <input class="inp" v-model="formData.username" placeholder="请输入账号" placeholder-style="color: #ADB0BD" />
|
|
|
|
|
|
+ <image :src="REMOTE_PATH.username" class="image"></image>
|
|
|
|
+ <input class="inp" v-model.trim="loginFormData.username" placeholder="请输入账号"
|
|
|
|
+ placeholder-style="color: #ADB0BD" />
|
|
</view>
|
|
</view>
|
|
<view class="login-form-item">
|
|
<view class="login-form-item">
|
|
- <image src="https://static.fuxicarbon.com/bigModel/wechat/login/icon-password.png" class="image"></image>
|
|
|
|
- <input class="inp uni-input" :password="!showPassword" v-model="formData.password" placeholder="请输入密码"
|
|
|
|
- placeholder-style="color: #ADB0BD" />
|
|
|
|
- <uni-icons size="20" :type="showPassword ? 'eye' : 'eye-slash'" color="#ADB0BD" class="icon-eye"
|
|
|
|
- @click="showPassword = !showPassword"></uni-icons>
|
|
|
|
|
|
+ <image :src="REMOTE_PATH.password" class="image"></image>
|
|
|
|
+ <input class="inp" v-model.trim="loginFormData.password" placeholder="请输入密码"
|
|
|
|
+ placeholder-style="color: #ADB0BD" :password="!showPasswordIcon" />
|
|
|
|
+ <uni-icons size="20" color="#ADB0BD" class="icon-eye" :type="showPasswordIcon ? 'eye' : 'eye-slash'"
|
|
|
|
+ @click="showPasswordIcon = !showPasswordIcon"></uni-icons>
|
|
</view>
|
|
</view>
|
|
- <button class="sub-btn" hover-color="sub-btn_hover">
|
|
|
|
|
|
+ <button class="sub-btn" hover-class="sub-btn_hover" :loading="loading" @click="handleSubmit">
|
|
<text>登录</text>
|
|
<text>登录</text>
|
|
</button>
|
|
</button>
|
|
</view>
|
|
</view>
|
|
-
|
|
|
|
<view class="text-inner">
|
|
<view class="text-inner">
|
|
<text>人工智能运营体智慧决策助手</text>
|
|
<text>人工智能运营体智慧决策助手</text>
|
|
</view>
|
|
</view>
|
|
@@ -77,8 +115,9 @@ const formData = ref({
|
|
height: 52rpx;
|
|
height: 52rpx;
|
|
padding: 24rpx 96rpx 24rpx 96rpx;
|
|
padding: 24rpx 96rpx 24rpx 96rpx;
|
|
border-radius: 100rpx;
|
|
border-radius: 100rpx;
|
|
- background: #F6F7F8;
|
|
|
|
|
|
+ background: #f6f7f8;
|
|
line-height: 100rpx;
|
|
line-height: 100rpx;
|
|
|
|
+ font-size: 32rpx;
|
|
}
|
|
}
|
|
|
|
|
|
.image {
|
|
.image {
|
|
@@ -113,7 +152,11 @@ const formData = ref({
|
|
line-height: 100rpx;
|
|
line-height: 100rpx;
|
|
font-size: 32rpx;
|
|
font-size: 32rpx;
|
|
color: #fff;
|
|
color: #fff;
|
|
- background: #8AB1FF;
|
|
|
|
|
|
+ background: #8ab1ff;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ .sub-btn_hover {
|
|
|
|
+ background: #6495f7;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -125,4 +168,4 @@ const formData = ref({
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-</style>
|
|
|
|
|
|
+</style>
|