You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
118 lines
2.7 KiB
118 lines
2.7 KiB
<template>
|
|
<view class="login-page">
|
|
<view class="login-card">
|
|
<view class="login-title">登录</view>
|
|
<view class="form-group">
|
|
<input class="input" type="text" placeholder="请输入用户名" v-model="username" />
|
|
</view>
|
|
<view class="form-group">
|
|
<input class="input" type="password" placeholder="请输入密码" v-model="password" />
|
|
</view>
|
|
<button class="login-btn" @click="login">登录</button>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
name: 'LoginPage',
|
|
data() {
|
|
return {
|
|
username: '',
|
|
password: ''
|
|
}
|
|
},
|
|
methods: {
|
|
login() {
|
|
if (!this.username) {
|
|
uni.showToast({ title: '请输入用户名', icon: 'none' });
|
|
return;
|
|
}
|
|
if (!this.password) {
|
|
uni.showToast({ title: '请输入密码', icon: 'none' });
|
|
return;
|
|
}
|
|
// 这里可接入登录逻辑
|
|
uni.showToast({
|
|
title: '登录成功',
|
|
icon: 'success',
|
|
duration: 1500,
|
|
success: () => {
|
|
// 登录成功后跳转到首页
|
|
setTimeout(() => {
|
|
uni.switchTab({
|
|
url: '/pages/index/index',
|
|
success: () => {
|
|
console.log('跳转首页成功');
|
|
},
|
|
fail: (err) => {
|
|
console.error('跳转首页失败', err);
|
|
uni.showToast({
|
|
title: '跳转失败,请重试',
|
|
icon: 'none'
|
|
});
|
|
}
|
|
});
|
|
}, 800);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
.login-page {
|
|
min-height: 100vh;
|
|
background: linear-gradient(180deg, #cbe6ff 0%, #f6faff 100%);
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
font-family: 'SourceHanSansCN', 'PingFang SC', 'Microsoft YaHei', sans-serif;
|
|
}
|
|
.login-card {
|
|
background: #fff;
|
|
border-radius: 18px;
|
|
box-shadow: 0 2px 12px rgba(59,124,255,0.08);
|
|
padding: 48px 32px 32px 32px;
|
|
width: 90vw;
|
|
max-width: 400px;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
}
|
|
.login-title {
|
|
font-size: 28px;
|
|
font-weight: bold;
|
|
color: #217aff;
|
|
margin-bottom: 32px;
|
|
letter-spacing: 2px;
|
|
}
|
|
.form-group {
|
|
width: 100%;
|
|
margin-bottom: 20px;
|
|
}
|
|
.input {
|
|
width: 100%;
|
|
height: 44px;
|
|
border: 1px solid #eaeaea;
|
|
border-radius: 8px;
|
|
padding: 0 12px;
|
|
font-size: 16px;
|
|
background: #f7faff;
|
|
color: #222;
|
|
box-sizing: border-box;
|
|
}
|
|
.login-btn {
|
|
width: 100%;
|
|
height: 44px;
|
|
background: linear-gradient(90deg, #3b7cff 0%, #5bb6ff 100%);
|
|
color: #fff;
|
|
border: none;
|
|
border-radius: 8px;
|
|
font-size: 18px;
|
|
font-weight: 500;
|
|
margin-top: 12px;
|
|
letter-spacing: 2px;
|
|
}
|
|
</style> |