|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+<template>
|
|
|
2
|
+ <view class="login-container">
|
|
|
3
|
+ <image class="bg-image" src="../../static/login/login-bj.png"></image>
|
|
|
4
|
+ <view class="login-title">
|
|
|
5
|
+ <view class="welcome-text">您好,欢迎使用</view>
|
|
|
6
|
+ <view class="system-name">交收库管理系统</view>
|
|
|
7
|
+ </view>
|
|
|
8
|
+ <view class="login-form">
|
|
|
9
|
+ <view class="input-group">
|
|
|
10
|
+
|
|
|
11
|
+ <view class="input-label">
|
|
|
12
|
+ <uni-icons custom-prefix="iconfont" type="icon-yonghu_yonghuming" color="#000000" size="18"></uni-icons>
|
|
|
13
|
+ 用户名称
|
|
|
14
|
+ </view>
|
|
|
15
|
+ <view class="uni-input-wrapper">
|
|
|
16
|
+ <input v-model="username" class="input-field" placeholder="请输入用户名" />
|
|
|
17
|
+ </view>
|
|
|
18
|
+ </view>
|
|
|
19
|
+
|
|
|
20
|
+ <view class="input-group">
|
|
|
21
|
+ <view class="input-label">
|
|
|
22
|
+ <uni-icons custom-prefix="iconfont" type="icon-mima" color="#000000" size="18"></uni-icons>
|
|
|
23
|
+ 登录密码
|
|
|
24
|
+ </view>
|
|
|
25
|
+ <view class="uni-input-wrapper">
|
|
|
26
|
+ <input v-model="password" class="input-field" placeholder="请输入密码" :password="showPassword" />
|
|
|
27
|
+ <uni-icons @click="changePassword" :type="!showPassword ? 'eye' : 'eye-slash'" color="#000000" size="32"></uni-icons>
|
|
|
28
|
+ </view>
|
|
|
29
|
+ </view>
|
|
|
30
|
+
|
|
|
31
|
+ <button class="login-button" @click="handleLogin">登录</button>
|
|
|
32
|
+ </view>
|
|
|
33
|
+ </view>
|
|
|
34
|
+</template>
|
|
|
35
|
+
|
|
|
36
|
+<script setup>
|
|
|
37
|
+import { ref } from 'vue';
|
|
|
38
|
+
|
|
|
39
|
+const username = ref('');
|
|
|
40
|
+const password = ref('');
|
|
|
41
|
+
|
|
|
42
|
+const showPassword = ref(true)
|
|
|
43
|
+
|
|
|
44
|
+const changePassword = () => {
|
|
|
45
|
+ showPassword.value = !showPassword.value;
|
|
|
46
|
+}
|
|
|
47
|
+const handleLogin = async () => {
|
|
|
48
|
+ if (!username.value || !password.value) {
|
|
|
49
|
+ uni.showToast({
|
|
|
50
|
+ title: '请输入用户名和密码',
|
|
|
51
|
+ icon: 'none'
|
|
|
52
|
+ });
|
|
|
53
|
+ return;
|
|
|
54
|
+ }
|
|
|
55
|
+
|
|
|
56
|
+ uni.request({
|
|
|
57
|
+ url: 'http://172.16.6.128:8011/admin-api/system/auth/login',
|
|
|
58
|
+ method: 'POST',
|
|
|
59
|
+ data: {
|
|
|
60
|
+ username: username.value,
|
|
|
61
|
+ password: password.value
|
|
|
62
|
+ },
|
|
|
63
|
+ success: (res) => {
|
|
|
64
|
+ if (res.data.code === 0) {
|
|
|
65
|
+ uni.showToast({
|
|
|
66
|
+ title: '登录成功',
|
|
|
67
|
+ icon: 'success'
|
|
|
68
|
+ });
|
|
|
69
|
+ // 跳转到首页或其他页面
|
|
|
70
|
+ uni.switchTab({
|
|
|
71
|
+ url: '/pages/home/home' // 注意路径前的斜杠
|
|
|
72
|
+ });
|
|
|
73
|
+ } else {
|
|
|
74
|
+ uni.showToast({
|
|
|
75
|
+ title: res.data.msg,
|
|
|
76
|
+ icon: 'none'
|
|
|
77
|
+ });
|
|
|
78
|
+ }
|
|
|
79
|
+ },
|
|
|
80
|
+ fail: (err) => {
|
|
|
81
|
+ console.error(err); // 失败回调
|
|
|
82
|
+ }
|
|
|
83
|
+ });
|
|
|
84
|
+
|
|
|
85
|
+};
|
|
|
86
|
+</script>
|
|
|
87
|
+
|
|
|
88
|
+<style lang="scss" scoped>
|
|
|
89
|
+.login-container {
|
|
|
90
|
+ height: 100vh;
|
|
|
91
|
+ display: flex;
|
|
|
92
|
+ flex-direction: column;
|
|
|
93
|
+ position: relative;
|
|
|
94
|
+ overflow: hidden;
|
|
|
95
|
+ .bg-image {
|
|
|
96
|
+ position: absolute;
|
|
|
97
|
+ width: 100%;
|
|
|
98
|
+ height: 100vh;
|
|
|
99
|
+ top: 0;
|
|
|
100
|
+ left: 0;
|
|
|
101
|
+ object-fit: cover;
|
|
|
102
|
+ z-index: -1;
|
|
|
103
|
+ }
|
|
|
104
|
+ .login-title{
|
|
|
105
|
+ margin: 100rpx 30rpx 0;
|
|
|
106
|
+ .welcome-text {
|
|
|
107
|
+ font-size: 58rpx;
|
|
|
108
|
+ margin-bottom: 15rpx;
|
|
|
109
|
+ letter-spacing: 5rpx;
|
|
|
110
|
+ }
|
|
|
111
|
+
|
|
|
112
|
+ .system-name {
|
|
|
113
|
+ font-size: 68rpx;
|
|
|
114
|
+ font-weight: bold;
|
|
|
115
|
+ letter-spacing: 10rpx;
|
|
|
116
|
+ }
|
|
|
117
|
+ }
|
|
|
118
|
+
|
|
|
119
|
+}
|
|
|
120
|
+
|
|
|
121
|
+.login-form {
|
|
|
122
|
+ margin: 60rpx 30rpx 0;
|
|
|
123
|
+ padding: 70rpx;
|
|
|
124
|
+ background: linear-gradient(to bottom, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0));
|
|
|
125
|
+ border-radius: 25px 25px 0 0;
|
|
|
126
|
+ box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
|
|
127
|
+ height: 100vh;
|
|
|
128
|
+}
|
|
|
129
|
+
|
|
|
130
|
+
|
|
|
131
|
+.input-group {
|
|
|
132
|
+ margin-bottom: 55rpx;
|
|
|
133
|
+}
|
|
|
134
|
+
|
|
|
135
|
+.input-label {
|
|
|
136
|
+ font-size: 30rpx;
|
|
|
137
|
+ margin-bottom: 10rpx;
|
|
|
138
|
+ display: block;
|
|
|
139
|
+}
|
|
|
140
|
+.uni-input-wrapper {
|
|
|
141
|
+ display: flex;
|
|
|
142
|
+ margin: 10rpx 0;
|
|
|
143
|
+ flex-direction: row;
|
|
|
144
|
+ flex-wrap: nowrap;
|
|
|
145
|
+ border: 1px solid #B2C7E6;
|
|
|
146
|
+ background-color: #ffffff;
|
|
|
147
|
+ padding: 0px 10px 0 20px;
|
|
|
148
|
+ border-radius: 4px;
|
|
|
149
|
+ align-items: center;
|
|
|
150
|
+ }
|
|
|
151
|
+.input-field {
|
|
|
152
|
+ width: 100%;
|
|
|
153
|
+ padding: 10px 0;
|
|
|
154
|
+}
|
|
|
155
|
+
|
|
|
156
|
+.login-button {
|
|
|
157
|
+ width: 100%;
|
|
|
158
|
+ height: 70rpx;
|
|
|
159
|
+ line-height: 70rpx;
|
|
|
160
|
+ border-radius: 10rpx;
|
|
|
161
|
+ background-color: #1E5FDF;
|
|
|
162
|
+ color: #fff;
|
|
|
163
|
+ font-size: 28rpx;
|
|
|
164
|
+ text-align: center;
|
|
|
165
|
+}
|
|
|
166
|
+
|
|
|
167
|
+.login-button:hover {
|
|
|
168
|
+ background-color: #005bb5;
|
|
|
169
|
+}
|
|
|
170
|
+</style>
|