w-ui-v1 1.0.38 → 1.0.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/w-login/w-login.vue +139 -134
package/package.json
CHANGED
package/w-login/w-login.vue
CHANGED
|
@@ -1,150 +1,155 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { onMounted, reactive, ref } from 'vue'
|
|
3
|
-
import { useToast } from 'wot-design-uni'
|
|
4
|
-
import { login, pubKey, getUserConfig } from '../utils/apis/login'
|
|
5
|
-
import WSwitchLang from '../w-switch-lang/w-switch-lang.vue'
|
|
2
|
+
import { onMounted, reactive, ref } from 'vue'
|
|
3
|
+
import { useToast } from 'wot-design-uni'
|
|
4
|
+
import { login, pubKey, getUserConfig } from '../utils/apis/login'
|
|
5
|
+
import WSwitchLang from '../w-switch-lang/w-switch-lang.vue'
|
|
6
6
|
|
|
7
|
-
defineOptions({
|
|
8
|
-
|
|
9
|
-
})
|
|
10
|
-
// 定义props
|
|
11
|
-
const props = defineProps({
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
})
|
|
22
|
-
onMounted(() => {
|
|
23
|
-
|
|
24
|
-
})
|
|
25
|
-
const { success: showSuccess, error: showError, loading: showLoading } = useToast()
|
|
26
|
-
const pKey = ref('')
|
|
27
|
-
const model = reactive<{
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}>({
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
})
|
|
7
|
+
defineOptions({
|
|
8
|
+
name: 'WLogin',
|
|
9
|
+
})
|
|
10
|
+
// 定义props
|
|
11
|
+
const props = defineProps({
|
|
12
|
+
// 图片
|
|
13
|
+
loginImge: {
|
|
14
|
+
type: String,
|
|
15
|
+
default: '',
|
|
16
|
+
},
|
|
17
|
+
langSwitch: {
|
|
18
|
+
type: Boolean,
|
|
19
|
+
default: false,
|
|
20
|
+
},
|
|
21
|
+
})
|
|
22
|
+
onMounted(() => {
|
|
23
|
+
getPublicKey()
|
|
24
|
+
})
|
|
25
|
+
const { success: showSuccess, error: showError, loading: showLoading } = useToast()
|
|
26
|
+
const pKey = ref('')
|
|
27
|
+
const model = reactive<{
|
|
28
|
+
username : string
|
|
29
|
+
password : string
|
|
30
|
+
}>({
|
|
31
|
+
username: '',
|
|
32
|
+
password: '',
|
|
33
|
+
})
|
|
34
34
|
|
|
35
|
-
const form = ref()
|
|
35
|
+
const form = ref()
|
|
36
36
|
|
|
37
|
-
// 获取公匙
|
|
38
|
-
function getPublicKey() {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
37
|
+
// 获取公匙
|
|
38
|
+
function getPublicKey() {
|
|
39
|
+
pubKey().then(({ data } : any) => {
|
|
40
|
+
pKey.value = data.rasPubkey
|
|
41
|
+
})
|
|
42
|
+
}
|
|
43
43
|
|
|
44
|
-
// 登录
|
|
45
|
-
function handleLogin() {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
44
|
+
// 登录
|
|
45
|
+
function handleLogin() {
|
|
46
|
+
showLoading('登录中...')
|
|
47
|
+
login(model.username, model.password, pKey.value).then(({ data } : any) => {
|
|
48
|
+
if (data.status === 'error') {
|
|
49
|
+
return showError(data.message)
|
|
50
|
+
}
|
|
51
|
+
showSuccess('登录成功')
|
|
52
|
+
uni.setStorageSync('token', data.token)
|
|
53
|
+
getUserConfig().then(({ data } : any) => {
|
|
54
|
+
uni.setStorageSync('userInfo', {
|
|
55
|
+
...data.user
|
|
56
|
+
})
|
|
57
|
+
})
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
function handleSubmit() {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
59
|
+
uni.reLaunch({
|
|
60
|
+
url: '/pages/index/index',
|
|
61
|
+
})
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
function handleSubmit() {
|
|
65
|
+
form.value
|
|
66
|
+
.validate()
|
|
67
|
+
.then(({ valid } : any) => {
|
|
68
|
+
if (valid) {
|
|
69
|
+
handleLogin()
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
.catch((error : any) => {
|
|
73
|
+
console.error(error, 'error')
|
|
74
|
+
})
|
|
75
|
+
}
|
|
76
76
|
</script>
|
|
77
77
|
|
|
78
78
|
<template>
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
79
|
+
<view class="login">
|
|
80
|
+
<view class="form-box">
|
|
81
|
+
<WSwitchLang v-if="props.langSwitch" />
|
|
82
|
+
<view v-if="props.loginImge" class="avatar">
|
|
83
|
+
<wd-img width="200rpx" height="200rpx" :src="props.loginImge">
|
|
84
|
+
<template #error>
|
|
85
|
+
<view class="error-wrap">
|
|
86
|
+
<wd-icon name="image" size="200rpx" color="#ccc" />
|
|
87
|
+
</view>
|
|
88
|
+
</template>
|
|
89
|
+
</wd-img>
|
|
90
|
+
</view>
|
|
91
91
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
92
|
+
<wd-form ref="form" :model="model">
|
|
93
|
+
<wd-cell-group border>
|
|
94
|
+
<wd-input v-model="model.username" label="用户名" label-width="100px" prop="username" clearable
|
|
95
|
+
placeholder="请输入用户名" :rules="[{ required: true, message: '请填写用户名' }]" />
|
|
96
|
+
<wd-input v-model="model.password" label="密码" label-width="100px" prop="password" show-password
|
|
97
|
+
clearable placeholder="请输入密码" :rules="[{ required: true, message: '请填写密码' }]" />
|
|
98
|
+
</wd-cell-group>
|
|
99
|
+
<view class="footer">
|
|
100
|
+
<wd-button type="primary" block :round="false" @click="handleSubmit">
|
|
101
|
+
登录
|
|
102
|
+
</wd-button>
|
|
103
|
+
</view>
|
|
104
|
+
</wd-form>
|
|
105
|
+
</view>
|
|
106
|
+
<image class="footer-img" src="./footerImg.png"></image>
|
|
107
|
+
<wd-toast />
|
|
108
|
+
</view>
|
|
109
109
|
</template>
|
|
110
110
|
|
|
111
111
|
<style scoped lang="scss">
|
|
112
|
-
.login {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
border-radius: 8px;
|
|
121
|
-
z-index: 1;
|
|
122
|
-
position: absolute;
|
|
123
|
-
left: 50%;
|
|
124
|
-
top: 30%;
|
|
125
|
-
transform: translate(-50%, -50%);
|
|
126
|
-
width: 650rpx;
|
|
127
|
-
.lang {
|
|
128
|
-
display: flex;
|
|
129
|
-
justify-content: flex-end;
|
|
130
|
-
}
|
|
112
|
+
.login {
|
|
113
|
+
height: 100vh;
|
|
114
|
+
/* #ifdef H5 */
|
|
115
|
+
height: calc(100vh - 44px);
|
|
116
|
+
/* #endif */
|
|
117
|
+
position: relative;
|
|
118
|
+
//设置背景颜色#4d80f0 由上到下逐渐变浅
|
|
119
|
+
background: linear-gradient(to bottom, #4d80f0 30%, #2c5def 70%);
|
|
131
120
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
121
|
+
.form-box {
|
|
122
|
+
padding: 20rpx;
|
|
123
|
+
background-color: #fff;
|
|
124
|
+
border-radius: 8px;
|
|
125
|
+
z-index: 1;
|
|
126
|
+
position: absolute;
|
|
127
|
+
left: 50%;
|
|
128
|
+
top: 30%;
|
|
129
|
+
transform: translate(-50%, -50%);
|
|
130
|
+
width: 650rpx;
|
|
136
131
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
132
|
+
.lang {
|
|
133
|
+
display: flex;
|
|
134
|
+
justify-content: flex-end;
|
|
135
|
+
}
|
|
141
136
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
|
|
137
|
+
.avatar {
|
|
138
|
+
display: flex;
|
|
139
|
+
justify-content: center;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.footer {
|
|
143
|
+
padding: 12px;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
.footer-img {
|
|
149
|
+
position: absolute;
|
|
150
|
+
bottom: 0;
|
|
151
|
+
left: 50%;
|
|
152
|
+
transform: translateX(-50%);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
</style>
|