gpc-ui 0.1.16 → 0.1.18

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gpc-ui",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
4
4
  "description": "二小UI",
5
5
  "private": false,
6
6
  "main": "lib/gpc-ui.umd.min.js",
@@ -4,7 +4,7 @@
4
4
  <div style="color: #018a46; font-size: 40px; font-style: unset; text-align: right;">
5
5
  {{systemTitle}}
6
6
  </div>
7
- <div style="color: #018a46; font-size: 32px; font-style: unset; text-align: right;">●{{subtitle}}</div>
7
+ <div style="color: #018a46; font-size: 32px; font-style: unset; text-align: right;">·{{subtitle}}</div>
8
8
  </div>
9
9
  <div class="wrap-box">
10
10
  <div class="box-content">
@@ -28,15 +28,15 @@
28
28
  <input type="text" placeholder="用户名/手机号" v-model="accountFrom.username">
29
29
  </div>
30
30
  <div class="input-box">
31
- <input type="password" placeholder="密码" v-model="accountFrom.password">
32
- <i class="el-icon-edit"></i>
31
+ <input :type="inputType" placeholder="密码" v-model="accountFrom.password">
32
+ <i class="el-icon-view" :class="{ icon: Color }" @click="Show" ></i>
33
33
  </div>
34
34
  <drag-verify ref="dragVerifyLogin" :width="300" :isPassing.sync="isPassingAccount" text="请按住滑块拖动" successText="验证通过" progressBarBg="#11C36A"
35
35
  handlerIcon="el-icon-d-arrow-right" successIcon="el-icon-circle-check"
36
36
  @passcallback="passCallAccountBack">
37
37
  </drag-verify>
38
38
  <div class="buttons clearfix">
39
- <button type="button" class="btn-login fr button" @click="getAccountLogin">登录</button>
39
+ <el-button class="btn-login fr button" :loading="loading" @click="getAccountLogin">登录</el-button>
40
40
  <el-button type="text" style="color: #028037;" size="small" @click="getRegister">重置密码</el-button>
41
41
  </div>
42
42
  </div>
@@ -54,12 +54,12 @@
54
54
  </div>
55
55
  <div class="input-box">
56
56
  <div class="drag-verify-box">
57
- <input type="text" placeholder="验证码" v-model="verifyFrom.authCode">
57
+ <input type="text" placeholder="验证码" v-model="verifyFrom.smsCode">
58
58
  <el-button style="border-color: #028037; color: #028037;" plain size="small" @click="getLoginVerifyCode" :disabled="isDisabledLogin">{{buttonLoginText}}</el-button>
59
59
  </div>
60
60
  </div>
61
61
  <div class="buttons clearfix">
62
- <button type="button" class="btn-login fr button" @click="getVerifyCodeLogin">登录</button>
62
+ <el-button class="btn-login fr button" :loading="loadingVerify" @click="getVerifyCodeLogin">登录</el-button>
63
63
  </div>
64
64
  </div>
65
65
  </TabPane>
@@ -69,7 +69,7 @@
69
69
  <div>
70
70
  <h3>重置密码</h3>
71
71
  <div class="input-box">
72
- <input type="text" placeholder="手机号" v-model="verifyFrom.username">
72
+ <input type="text" placeholder="手机号" v-model="resetFrom.username">
73
73
  </div>
74
74
  <div class="input-box">
75
75
  <drag-verify ref="dragVerifyRest" :width="320" :isPassing.sync="isPassingRest" text="请按住滑块拖动" successText="验证通过" progressBarBg="#11C36A"
@@ -79,12 +79,12 @@
79
79
  </div>
80
80
  <div class="input-box">
81
81
  <div class="drag-verify-box">
82
- <input type="text" placeholder="验证码" v-model="verifyFrom.authCode">
82
+ <input type="text" placeholder="验证码" v-model="resetFrom.smsCode">
83
83
  <el-button style="border-color: #028037; color: #028037;" plain size="small" @click="getRestVerifyCode" :disabled="isDisabledRest">{{buttonRestText}}</el-button>
84
84
  </div>
85
85
  </div>
86
86
  <div class="buttons clearfix">
87
- <button type="button" class="btn-register fr button" @click="getRegisterPw">重置</button>
87
+ <el-button class="btn-login fr button" :loading="loadingRest" @click="getRegisterPw">重置</el-button>
88
88
  </div>
89
89
  </div>
90
90
  </div>
@@ -144,10 +144,24 @@ export default {
144
144
  type: String,
145
145
  default: ''
146
146
  },
147
+ loading: {
148
+ type: Boolean,
149
+ default: false
150
+ },
151
+ loadingVerify: {
152
+ type: Boolean,
153
+ default: false
154
+ },
155
+ loadingRest: {
156
+ type: Boolean,
157
+ default: false
158
+ },
147
159
  },
148
160
  data() {
149
161
  return {
150
162
  isLogin: true,
163
+ inputType: "password",
164
+ Color: false,
151
165
  // 当前选中的标签
152
166
  curTab: "1",
153
167
 
@@ -163,6 +177,7 @@ export default {
163
177
  verifyFrom:{
164
178
  username: "",
165
179
  authCode: "",
180
+ smsCode: "",
166
181
  },
167
182
  // 滑块验证 - 验证码登录
168
183
  isPassingLogin: false,
@@ -172,6 +187,7 @@ export default {
172
187
  resetFrom:{
173
188
  username: "",
174
189
  authCode: "",
190
+ smsCode: "",
175
191
  },
176
192
  // 滑块验证 - 验证码登录
177
193
  isPassingRest: false,
@@ -193,7 +209,7 @@ export default {
193
209
  console.log('getCodeRequest', type, authCode)
194
210
  if(type === 'account'){
195
211
  this.accountFrom.authCode = authCode
196
- } else if(type === 'login'){
212
+ } else if(type === 'smsCode'){
197
213
  this.verifyFrom.authCode = authCode
198
214
  } else if(type === 'rest'){
199
215
  this.resetFrom.authCode = authCode
@@ -218,13 +234,64 @@ export default {
218
234
  console.log('passCallAccountBack \'验证通过\'', this.isPassingAccount);
219
235
  this.$emit('getCodeRequest', 'account');
220
236
  },
221
- // 验证码登录
237
+ // 验证码登录-提取公共校验逻辑
238
+ validateVerifyForm() {
239
+ if (!this.verifyFrom || typeof this.verifyFrom !== 'object') {
240
+ this.$notify.error({ message: '表单数据未正确初始化,请刷新页面重试。' });
241
+ return false;
242
+ }
243
+ if (!this.verifyFrom.username) {
244
+ this.$notify.error({ message: '请输入手机号' });
245
+ return false;
246
+ }
247
+ if (!this.isPassingLogin) {
248
+ this.$notify.error({ message: '请先进行滑块验证' });
249
+ return false;
250
+ }
251
+ if (!this.verifyFrom.authCode) {
252
+ this.$notify.error({ message: '验证滑块码获取失败,请刷新页面,重新获取1。' });
253
+ return false;
254
+ }
255
+ return true;
256
+ },
257
+ // 验证码登录-登录
222
258
  getVerifyCodeLogin(){
223
-
259
+ try {
260
+ // 校验公共逻辑
261
+ if (!this.validateVerifyForm()) return false;
262
+ // 校验短信验证码
263
+ if (!this.verifyFrom.smsCode) {
264
+ this.$notify.error({ message: '请输入短信验证码' });
265
+ return false;
266
+ }
267
+ // 触发事件
268
+ this.$emit('getVerifyCodeLoginRequest', this.verifyFrom);
269
+ return true;
270
+ } catch (error) {
271
+ console.error('重置密码过程中发生错误:', error);
272
+ this.$notify.error({ message: '系统异常,请稍后再试。' });
273
+ return false;
274
+ }
224
275
  },
225
- // 获取验证码(登录)
276
+ // 验证码登录-获取验证码(登录)
226
277
  getLoginVerifyCode(){
278
+ try {
279
+ // 校验公共逻辑
280
+ if (!this.validateVerifyForm()) return false;
281
+
282
+ // 调用验证码设置方法
283
+ this.setLoginVerifyCodeBack();
284
+ return true;
285
+ } catch (error) {
286
+ console.error('获取验证码过程中发生错误:', error);
287
+ this.$notify.error({ message: '系统异常,请稍后再试。' });
288
+ return false;
289
+ }
290
+ },
291
+ // 验证码登录-获取验证码(重置)- 回调
292
+ setLoginVerifyCodeBack() {
227
293
  if(this.isPassingLogin){
294
+ this.$emit('applySMSCodeRequest', this.verifyFrom);
228
295
  this.isDisabledLogin = true
229
296
  this.countdownLogin = 3
230
297
  const interval = setInterval(()=>{
@@ -237,22 +304,74 @@ export default {
237
304
  },1000)
238
305
  }
239
306
  },
307
+ // 验证码登录- 发送获取authCode
240
308
  passCallLoginBack() {
241
- console.log('passCallLoginBack \'验证通过\'');
242
- this.$emit('getCodeRequest', 'code');
243
- // this.isPassingLogin = false
309
+ this.$emit('getCodeRequest', 'smsCode');
244
310
  },
245
311
  resetLogin() {
246
312
  this.isPassingLogin = false;
247
313
  this.$refs.dragVerifyLogin.reset()
248
314
  },
315
+ // 提取公共校验逻辑 - 重置密码
316
+ validateResetForm() {
317
+ if (!this.resetFrom || typeof this.resetFrom !== 'object') {
318
+ this.$notify.error({ message: '表单数据未正确初始化,请刷新页面重试。' });
319
+ return false;
320
+ }
321
+ if (!this.resetFrom.username) {
322
+ this.$notify.error({ message: '请输入手机号' });
323
+ return false;
324
+ }
325
+ if (!this.isPassingRest) {
326
+ this.$notify.error({ message: '请先进行滑块验证' });
327
+ return false;
328
+ }
329
+ if (!this.resetFrom.authCode) {
330
+ this.$notify.error({ message: '验证滑块码获取失败,请刷新页面,重新获取。' });
331
+ return false;
332
+ }
333
+ return true;
334
+ },
249
335
  // 重置密码
250
336
  getRegisterPw(){
251
-
337
+ try {
338
+ // 校验公共逻辑
339
+ if (!this.validateResetForm()) return false;
340
+
341
+ // 校验短信验证码
342
+ if (!this.resetFrom.smsCode) {
343
+ this.$notify.error({ message: '请输入短信验证码' });
344
+ return false;
345
+ }
346
+
347
+ // 触发事件
348
+ this.$emit('getRegisterPwRequest', this.resetFrom);
349
+ return true;
350
+ } catch (error) {
351
+ console.error('重置密码过程中发生错误:', error);
352
+ this.$notify.error({ message: '系统异常,请稍后再试。' });
353
+ return false;
354
+ }
252
355
  },
253
356
  // 获取验证码(重置)
254
357
  getRestVerifyCode(){
358
+ try {
359
+ // 校验公共逻辑
360
+ if (!this.validateResetForm()) return false;
361
+
362
+ // 调用验证码设置方法
363
+ this.setRestVerifyCodeBack();
364
+ return true;
365
+ } catch (error) {
366
+ console.error('获取验证码过程中发生错误:', error);
367
+ this.$notify.error({ message: '系统异常,请稍后再试。' });
368
+ return false;
369
+ }
370
+ },
371
+ // 获取验证码(重置)- 回调
372
+ setRestVerifyCodeBack() {
255
373
  if(this.isPassingRest){
374
+ this.$emit('applySMSCodeRequest', this.resetFrom);
256
375
  this.isDisabledRest = true
257
376
  this.countdownRest = 3
258
377
  const interval = setInterval(()=>{
@@ -266,8 +385,6 @@ export default {
266
385
  }
267
386
  },
268
387
  passCallRestBack() {
269
- console.log('passCallRestBack \'验证通过\'');
270
- // this.isPassingRest = false
271
388
  this.$emit('getCodeRequest', 'rest');
272
389
  },
273
390
  resetPw() {
@@ -297,7 +414,12 @@ export default {
297
414
  console.warn(`Element with selector ${selector} not found.`);
298
415
  }
299
416
  },
300
-
417
+ // 密码的可见和不可见
418
+ Show() {
419
+ // 点击改变input框的展示方式
420
+ this.inputType = this.inputType === "password" ? "text" : "password";
421
+ this.Color = !this.Color;
422
+ },
301
423
  },
302
424
  mounted() {
303
425
  // 确保在组件挂载后执行 DOM 操作
@@ -585,7 +707,7 @@ a {
585
707
  background-color: #00b85c;
586
708
  transition: all .36s;
587
709
  right: 20px;
588
- color: #ccc;
710
+ //color: #ccc;
589
711
  }
590
712
 
591
713
  .input-box input {
@@ -679,4 +801,8 @@ a {
679
801
  flex-direction: row;
680
802
  justify-content: space-evenly;
681
803
  }
804
+
805
+ .icon {
806
+ color: #028037;
807
+ }
682
808
  </style>