@lambo-design/login-form 1.0.0-beta.11 → 1.0.0-beta.13
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 +23 -16
- package/src/login-form.vue +135 -6
package/package.json
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@lambo-design/login-form",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
4
|
-
"description": "",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"@lambo-design/
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@lambo-design/login-form",
|
|
3
|
+
"version": "1.0.0-beta.13",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"author": "lambo",
|
|
7
|
+
"license": "ISC",
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public",
|
|
10
|
+
"registry": "https://registry.npmjs.org/"
|
|
11
|
+
},
|
|
12
|
+
"devDependencies": {
|
|
13
|
+
"@lambo-design/core": "^4.7.1-beta.147",
|
|
14
|
+
"@lambo-design/shared": "^1.0.0-beta.233"
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"release": "pnpm release-beta && git push --follow-tags && pnpm re-publish",
|
|
18
|
+
"release-major": "standard-version --release-as major",
|
|
19
|
+
"release-minor": "standard-version --release-as minor",
|
|
20
|
+
"release-patch": "standard-version --release-as patch",
|
|
21
|
+
"release-beta": "standard-version --prerelease beta",
|
|
22
|
+
"re-publish": "pnpm publish --access public --no-git-checks"
|
|
23
|
+
}
|
|
17
24
|
}
|
package/src/login-form.vue
CHANGED
|
@@ -16,16 +16,44 @@
|
|
|
16
16
|
</span>
|
|
17
17
|
</Input>
|
|
18
18
|
</FormItem>
|
|
19
|
-
<FormItem prop="validCode">
|
|
19
|
+
<FormItem prop="validCode" v-if="captchaMethod === '图片'">
|
|
20
20
|
<Input v-model="form.validCode" class="captcha" placeholder="请输入验证码">
|
|
21
21
|
<template slot="prepend">
|
|
22
|
-
<img class="prefix" src="
|
|
22
|
+
<img class="prefix" src="@/assets/images/captcha.svg">
|
|
23
23
|
</template>
|
|
24
24
|
</Input>
|
|
25
25
|
<div class="Imgbox"><img :src="captchaUrl" class="captchaImg" @click="getCaptcha"></div>
|
|
26
26
|
</FormItem>
|
|
27
|
+
<FormItem prop="validCode" v-if="captchaMethod === '短信'">
|
|
28
|
+
<Input
|
|
29
|
+
search
|
|
30
|
+
:enter-button="ValidNumText"
|
|
31
|
+
placeholder="请查收短信并输入验证码"
|
|
32
|
+
v-model="form.validCode"
|
|
33
|
+
@on-search="getVaildCode">
|
|
34
|
+
<template slot="prepend">
|
|
35
|
+
<img class="prefix" src="@/assets/images/captcha.svg">
|
|
36
|
+
</template>
|
|
37
|
+
</Input>
|
|
38
|
+
</FormItem>
|
|
39
|
+
<FormItem prop="validCode" v-if="captchaMethod === '邮箱'">
|
|
40
|
+
<Input
|
|
41
|
+
search
|
|
42
|
+
:enter-button="ValidNumText"
|
|
43
|
+
placeholder="请查收邮件并输入验证码"
|
|
44
|
+
v-model="form.validCode"
|
|
45
|
+
@on-search="getVaildCode">
|
|
46
|
+
<template slot="prepend">
|
|
47
|
+
<img class="prefix" src="@/assets/images/captcha.svg">
|
|
48
|
+
</template>
|
|
49
|
+
</Input>
|
|
50
|
+
</FormItem>
|
|
51
|
+
<FormItem v-if="captchaMethod === '滑动图片'">
|
|
52
|
+
<Button long :disabled="isDisabled" @click="showSlideVerify">{{ buttonText }}</Button>
|
|
53
|
+
</FormItem>
|
|
27
54
|
<FormItem>
|
|
28
55
|
<Checkbox v-model="rememberMe"><span class="remember">记住用户名</span></Checkbox>
|
|
56
|
+
<label v-if="showForgetPassword==='1'" style="float: right;"><router-link to="/forgetPasswordForget">忘记密码?</router-link></label>
|
|
29
57
|
</FormItem>
|
|
30
58
|
<FormItem>
|
|
31
59
|
<Button :loading="loading" long type="primary" @click="handleSubmit">登录</Button>
|
|
@@ -37,9 +65,14 @@ import config from "@lambo-design/shared/config/config";
|
|
|
37
65
|
import {getLocalStorage, removeLocalStorage, setLocalStorage} from "@lambo-design/shared/utils/platform";
|
|
38
66
|
import {guid} from "@lambo-design/shared/utils/number";
|
|
39
67
|
import crypto from "@lambo-design/shared/utils/crypto"
|
|
68
|
+
import ajax from "@lambo-design/shared/utils/ajax";
|
|
69
|
+
import slideVerify from '@/view/login/slide-verify/src/slide-verify';
|
|
40
70
|
|
|
41
71
|
export default {
|
|
42
72
|
name: 'LoginForm',
|
|
73
|
+
components:{
|
|
74
|
+
slideVerify,
|
|
75
|
+
},
|
|
43
76
|
props: {
|
|
44
77
|
userNameRules: {
|
|
45
78
|
type: Array,
|
|
@@ -76,17 +109,29 @@ export default {
|
|
|
76
109
|
pasCryptor: {
|
|
77
110
|
type: String,
|
|
78
111
|
default: 'sm3'
|
|
79
|
-
}
|
|
112
|
+
},
|
|
113
|
+
captchaMethod:{type: String},
|
|
114
|
+
showForgetPassword:{type: String},
|
|
115
|
+
passwordRetrievalMethod:{type: Array},
|
|
116
|
+
smConfigId:{type: String},
|
|
117
|
+
templateId:{type: String},
|
|
118
|
+
mailConfigId:{type: String},
|
|
119
|
+
isSlideVerify:{type: Boolean},
|
|
120
|
+
buttonText: {type:String}, // 初始按钮文本
|
|
121
|
+
isDisabled: {type:Boolean},
|
|
80
122
|
},
|
|
81
123
|
data() {
|
|
82
124
|
return {
|
|
125
|
+
ValidNumText: "获取验证码",
|
|
83
126
|
form: {
|
|
84
127
|
userName: '',
|
|
85
128
|
password: '',
|
|
86
129
|
validCode: ''
|
|
87
130
|
},
|
|
88
131
|
rememberMe: false,
|
|
89
|
-
validCodeId: ''
|
|
132
|
+
validCodeId: '',
|
|
133
|
+
countDown: 60,
|
|
134
|
+
countDownNum: 60,
|
|
90
135
|
}
|
|
91
136
|
},
|
|
92
137
|
computed: {
|
|
@@ -119,9 +164,89 @@ export default {
|
|
|
119
164
|
false
|
|
120
165
|
)
|
|
121
166
|
},
|
|
167
|
+
getVaildCode() {
|
|
168
|
+
let self = this;
|
|
169
|
+
if (self.ValidNumText == "获取验证码") {
|
|
170
|
+
self.ValidNumText = self.countDown + "s后再次获取";
|
|
171
|
+
self.clock = window.setInterval(() => {
|
|
172
|
+
self.countDown--;
|
|
173
|
+
self.ValidNumText = self.countDown + "s后再次获取";
|
|
174
|
+
if (self.countDown <= 0) {
|
|
175
|
+
window.clearInterval(self.clock);
|
|
176
|
+
self.ValidNumText = "获取验证码";
|
|
177
|
+
self.countDown = self.countDownNum;
|
|
178
|
+
}
|
|
179
|
+
}, 1000);
|
|
180
|
+
let param
|
|
181
|
+
let url
|
|
182
|
+
if(self.captchaMethod === '邮箱'){
|
|
183
|
+
url = config.upmsServerContext + "/anon/user/sendMailForLogin"
|
|
184
|
+
param = {
|
|
185
|
+
userId: self.form.userName,
|
|
186
|
+
//mailAddress: self.form.mailAddress
|
|
187
|
+
validCodeId: self.validCodeId,
|
|
188
|
+
mailConfigId: self.mailConfigId
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
if(self.captchaMethod === '短信'){
|
|
192
|
+
url = config.upmsServerContext + "/anon/user/sendSmsForLogin"
|
|
193
|
+
param = {
|
|
194
|
+
userId: self.form.userName,
|
|
195
|
+
//phoneNumber: self.form.phoneNumber
|
|
196
|
+
validCodeId: self.validCodeId,
|
|
197
|
+
smConfigId: self.smConfigId,
|
|
198
|
+
templateId: self.templateId
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
if (self.form.userName && self.form.userName.trim().length > 0){
|
|
202
|
+
ajax
|
|
203
|
+
.post(url, param)
|
|
204
|
+
.then(function(resp) {
|
|
205
|
+
if (resp.data.code == 200) {
|
|
206
|
+
self.$Message.success({
|
|
207
|
+
content: "发送成功",})
|
|
208
|
+
} else {
|
|
209
|
+
self.$Message.error(resp.data.data);
|
|
210
|
+
window.clearInterval(self.clock);
|
|
211
|
+
self.ValidNumText = "获取验证码";
|
|
212
|
+
self.countDown = self.countDownNum;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
);
|
|
216
|
+
}else{
|
|
217
|
+
self.$Message.error("请输入用户名");
|
|
218
|
+
window.clearInterval(self.clock);
|
|
219
|
+
self.ValidNumText = "获取验证码";
|
|
220
|
+
self.countDown = self.countDownNum;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
showSlideVerify(){
|
|
225
|
+
if (this.form.userName && this.form.userName.trim().length > 0){
|
|
226
|
+
let params = {
|
|
227
|
+
userName: this.form.userName,
|
|
228
|
+
password: this.form.password,
|
|
229
|
+
validCodeInput: this.form.validCode,
|
|
230
|
+
validCodeId: this.validCodeId
|
|
231
|
+
}
|
|
232
|
+
if (this.pasCryptor) {
|
|
233
|
+
params.pasCryptor = this.pasCryptor;
|
|
234
|
+
params.pasEncode = this.getCryptorPassword(this.form.password,this.form.validCode,this.pasCryptor);
|
|
235
|
+
} else {
|
|
236
|
+
params.pasMd5 = this.getCryptorPassword(this.form.password,this.form.validCode,'md5');
|
|
237
|
+
params.pasSm3 = this.getCryptorPassword(this.form.password,this.form.validCode,'sm3');
|
|
238
|
+
}
|
|
239
|
+
this.$emit('show-slide-verify', true,params)
|
|
240
|
+
}else{
|
|
241
|
+
this.$Message.error("请输入用户名");
|
|
242
|
+
}
|
|
243
|
+
},
|
|
122
244
|
handleSubmit() {
|
|
123
245
|
this.$refs.loginForm.validate((valid) => {
|
|
124
|
-
if
|
|
246
|
+
if(valid && this.captchaMethod == '滑动图片' && !this.isSlideVerify){
|
|
247
|
+
this.$Message.error("请点击验证进行登录验证");
|
|
248
|
+
}
|
|
249
|
+
if (valid && ((this.captchaMethod == '滑动图片' && this.isSlideVerify) || this.captchaMethod != '滑动图片')) {
|
|
125
250
|
let params = {
|
|
126
251
|
userName: this.form.userName,
|
|
127
252
|
password: this.form.password,
|
|
@@ -136,6 +261,7 @@ export default {
|
|
|
136
261
|
params.pasSm3 = this.getCryptorPassword(this.form.password,this.form.validCode,'sm3');
|
|
137
262
|
}
|
|
138
263
|
this.$emit('on-success-valid', params)
|
|
264
|
+
this.setLocalUserId(this.form.userName)
|
|
139
265
|
if (this.rememberMe == true) {
|
|
140
266
|
this.setLocalStorage(this.form.userName)
|
|
141
267
|
}
|
|
@@ -154,6 +280,9 @@ export default {
|
|
|
154
280
|
setLocalStorage(name) {
|
|
155
281
|
setLocalStorage("username", name);
|
|
156
282
|
},
|
|
283
|
+
setLocalUserId(name){
|
|
284
|
+
setLocalStorage('userId',name)
|
|
285
|
+
},
|
|
157
286
|
clearLocalStorage() {
|
|
158
287
|
removeLocalStorage("username");
|
|
159
288
|
}
|
|
@@ -165,5 +294,5 @@ export default {
|
|
|
165
294
|
}
|
|
166
295
|
</script>
|
|
167
296
|
<style lang="less">
|
|
168
|
-
@import 'styles/css/login-form';
|
|
297
|
+
@import 'styles/css/login-form';
|
|
169
298
|
</style>
|