路径和页面调整

This commit is contained in:
weiwei committed 2025-05-21 09:47:33 +08:00
1 parent 9b4614a5cc
commit c44b5b56d8
10 files changed
+192 -373

No files matched your search

+81
View File
@@ -0,0 +1,81 @@
<script setup lang="ts">
import { ref, reactive } from "vue"
import { onShow } from "@dcloudio/uni-app"
import { constant, router } from "@@/index"
import { userApi } from "@@/api"
const state = reactive<any>({
userInfo: null,
})
const applyForm = reactive<any>({
username: "",
password: "",
})
const applyFormRules = reactive<any>({
username: [{ required: true, message: "请输入用户名" }],
password: [{ required: true, message: "请输入密码" }],
})
onShow(() => {
const userInfoKey = constant.storageConstant.USERINFO
state.userInfo = uni.getStorageSync(userInfoKey)
})
const applyFormRef = ref<any>(null)
const doSubmit = async () => {
applyFormRef.value.submit()
const { isPass } = applyFormRef.value.validate()
if (!isPass) return
const tokenKey = constant.storageConstant.TOKEN
const userInfoKey = constant.storageConstant.USERINFO
uni.removeStorageSync(tokenKey)
uni.showLoading({ title: "登录中...", mask: true })
const res: any = await userApi.login({
...applyForm,
grant_type: "password",
scope: "server",
})
if (res.code != 0) {
uni.showToast({ title: res.msg + ",登录失败,请重新登录", icon: "error" })
return
}
uni.setStorageSync(tokenKey, res.data)
const { data: userData } = await userApi.userInfo()
uni.setStorageSync(userInfoKey, userData)
uni.hideLoading()
uni.showToast({ title: "登录成功", icon: "none" })
router.back()
}
</script>
<template>
<crud-layout title="登录" bg="/static/page/blue-bg.png">
<view class="h-30rpx" />
<view class="card p-x-30rpx p-y-40rpx">
<tm-form ref="applyFormRef" v-model="applyForm" :rules="applyFormRules" direction="vertical">
<tm-form-item name="username" label="用户名" :showBottom="false">
<tm-input v-model="applyForm.username" placeholder="请输入用户名.." />
</tm-form-item>
<view class="h-30rpx" />
<tm-form-item name="password" label="密码" :showBottom="false">
<tm-input password showEye v-model="applyForm.password" placeholder="请输入用户密码.." />
</tm-form-item>
</tm-form>
</view>
<view
v-if="state.detailType != 'view'"
class="bg-#0094ff p-y-20rpx text-center rounded-40rpx m-x-30rpx m-t-60rpx sub-text-30 color-white!"
@tap="doSubmit"
>
登录
</view>
</crud-layout>
</template>
<style lang="scss" scoped>
:deep() {
.tmFormItemLabel {
padding-bottom: 10rpx !important;
}
}
</style>