<!-- 登录页 -->
|
<template>
|
<view>
|
<view class="login-form-wrap">
|
<view class="title"> 掌控智飞</view>
|
<input
|
v-model="loginForm.username"
|
class="u-border-bottom"
|
placeholder="请输入用户名"
|
/>
|
<input
|
v-model="loginForm.password"
|
class="u-border-bottom"
|
type="password"
|
placeholder="请输入密码"
|
/>
|
<button class="login-btn" :style="[inputStyle]" @tap="submit">
|
登录
|
<text class="i-mdi-login" />
|
</button>
|
</view>
|
</view>
|
</template>
|
|
<script setup>
|
import md5 from "js-md5";
|
import { loginByUsername } from "@/api/user/index.js";
|
import { useUserStore } from "@/store/index.js";
|
import { HOME_PATH, LOGIN_PATH, removeQueryString } from "@/router";
|
const userStore = useUserStore();
|
const loginForm = ref({
|
username: "cpz3",
|
password: "cpz3@2025",
|
});
|
const inputStyle = computed(() => {
|
const style = {};
|
if (loginForm.value.username && loginForm.value.password) {
|
style.color = "#fff";
|
style.backgroundColor = uni.$u.color.warning;
|
}
|
return style;
|
});
|
let redirect = HOME_PATH;
|
|
async function submit() {
|
let userInfo = {
|
tenantId: "000000",
|
deptId: "",
|
roleId: "",
|
username: loginForm.value.username,
|
password: loginForm.value.password,
|
type: "account",
|
code: "",
|
key: "",
|
};
|
loginByUsername(
|
userInfo.tenantId,
|
userInfo.deptId,
|
userInfo.roleId,
|
userInfo.username,
|
md5(userInfo.password),
|
userInfo.type,
|
userInfo.key,
|
userInfo.code
|
).then((res) => {
|
userStore.setUserInfo(res.data);
|
uni.switchTab({
|
url: "/pages/user/index",
|
});
|
});
|
}
|
|
onLoad((options) => {
|
if (options.redirect && removeQueryString(options.redirect) !== LOGIN_PATH) {
|
redirect = decodeURIComponent(options.redirect);
|
}
|
});
|
</script>
|
|
<style lang="scss" scoped>
|
.login-form-wrap {
|
@apply mt-80rpx mx-auto mb-0 w-600rpx;
|
|
.title {
|
@apply mb-100rpx text-60rpx text-left font-500;
|
}
|
|
input {
|
@apply pb-6rpx mb-10rpx text-left;
|
}
|
|
.tips {
|
@apply mt-8rpx mb-60rpx;
|
|
color: $u-info;
|
}
|
|
.login-btn {
|
@apply flex items-center justify-center py-12rpx px-0 text-30rpx bg-#fdf3d0 border-none;
|
|
color: $u-tips-color;
|
|
&::after {
|
@apply border-none;
|
}
|
}
|
|
.alternative {
|
@apply flex justify-between mt-30rpx;
|
|
color: $u-tips-color;
|
}
|
}
|
|
.login-type-wrap {
|
@apply flex justify-between pt-350rpx px-150rpx pb-150rpx;
|
|
.item {
|
@apply flex items-center flex-col text-28rpx;
|
|
color: $u-content-color;
|
}
|
}
|
|
.hint {
|
@apply px-40rpx py-20rpx text-24rpx;
|
|
color: $u-tips-color;
|
|
.link {
|
color: $u-warning;
|
}
|
}
|
</style>
|