gpc-ui 0.1.17 → 0.1.19

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.17",
3
+ "version": "0.1.19",
4
4
  "description": "二小UI",
5
5
  "private": false,
6
6
  "main": "lib/gpc-ui.umd.min.js",
@@ -44,7 +44,7 @@
44
44
  <TabPane label="验证码登录" name="2">
45
45
  <div>
46
46
  <div class="input-box">
47
- <input type="text" placeholder="手机号" v-model="verifyFrom.username">
47
+ <input type="text" placeholder="手机号" v-model="verifyFrom.phoneNum">
48
48
  </div>
49
49
  <div class="input-box">
50
50
  <drag-verify ref="dragVerifyLogin" :width="300" :isPassing.sync="isPassingLogin" text="请按住滑块拖动" successText="验证通过" progressBarBg="#11C36A"
@@ -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.phoneNum">
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>
@@ -147,7 +147,15 @@ export default {
147
147
  loading: {
148
148
  type: Boolean,
149
149
  default: false
150
- }
150
+ },
151
+ loadingVerify: {
152
+ type: Boolean,
153
+ default: false
154
+ },
155
+ loadingRest: {
156
+ type: Boolean,
157
+ default: false
158
+ },
151
159
  },
152
160
  data() {
153
161
  return {
@@ -167,8 +175,9 @@ export default {
167
175
  isPassingAccount: false,
168
176
  // 验证码登录
169
177
  verifyFrom:{
170
- username: "",
178
+ phoneNum: "",
171
179
  authCode: "",
180
+ smsCode: "",
172
181
  },
173
182
  // 滑块验证 - 验证码登录
174
183
  isPassingLogin: false,
@@ -176,8 +185,9 @@ export default {
176
185
  isDisabledLogin: false,
177
186
  // 重置密码
178
187
  resetFrom:{
179
- username: "",
188
+ phoneNum: "",
180
189
  authCode: "",
190
+ smsCode: "",
181
191
  },
182
192
  // 滑块验证 - 验证码登录
183
193
  isPassingRest: false,
@@ -199,7 +209,7 @@ export default {
199
209
  console.log('getCodeRequest', type, authCode)
200
210
  if(type === 'account'){
201
211
  this.accountFrom.authCode = authCode
202
- } else if(type === 'login'){
212
+ } else if(type === 'smsCode'){
203
213
  this.verifyFrom.authCode = authCode
204
214
  } else if(type === 'rest'){
205
215
  this.resetFrom.authCode = authCode
@@ -224,13 +234,64 @@ export default {
224
234
  console.log('passCallAccountBack \'验证通过\'', this.isPassingAccount);
225
235
  this.$emit('getCodeRequest', 'account');
226
236
  },
227
- // 验证码登录
237
+ // 验证码登录-提取公共校验逻辑
238
+ validateVerifyForm() {
239
+ if (!this.verifyFrom || typeof this.verifyFrom !== 'object') {
240
+ this.$notify.error({ message: '表单数据未正确初始化,请刷新页面重试。' });
241
+ return false;
242
+ }
243
+ if (!this.verifyFrom.phoneNum) {
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
+ // 验证码登录-登录
228
258
  getVerifyCodeLogin(){
229
-
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
+ }
230
275
  },
231
- // 获取验证码(登录)
276
+ // 验证码登录-获取验证码(登录)
232
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() {
233
293
  if(this.isPassingLogin){
294
+ this.$emit('applySMSCodeRequest', this.verifyFrom);
234
295
  this.isDisabledLogin = true
235
296
  this.countdownLogin = 3
236
297
  const interval = setInterval(()=>{
@@ -243,22 +304,74 @@ export default {
243
304
  },1000)
244
305
  }
245
306
  },
307
+ // 验证码登录- 发送获取authCode
246
308
  passCallLoginBack() {
247
- console.log('passCallLoginBack \'验证通过\'');
248
- this.$emit('getCodeRequest', 'code');
249
- // this.isPassingLogin = false
309
+ this.$emit('getCodeRequest', 'smsCode');
250
310
  },
251
311
  resetLogin() {
252
312
  this.isPassingLogin = false;
253
313
  this.$refs.dragVerifyLogin.reset()
254
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.phoneNum) {
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
+ },
255
335
  // 重置密码
256
336
  getRegisterPw(){
257
-
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
+ }
258
355
  },
259
356
  // 获取验证码(重置)
260
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() {
261
373
  if(this.isPassingRest){
374
+ this.$emit('applySMSCodeRequest', this.resetFrom);
262
375
  this.isDisabledRest = true
263
376
  this.countdownRest = 3
264
377
  const interval = setInterval(()=>{
@@ -272,8 +385,6 @@ export default {
272
385
  }
273
386
  },
274
387
  passCallRestBack() {
275
- console.log('passCallRestBack \'验证通过\'');
276
- // this.isPassingRest = false
277
388
  this.$emit('getCodeRequest', 'rest');
278
389
  },
279
390
  resetPw() {