Explorar el Código

验证码校验

chenzubin hace 2 meses
padre
commit
9b5c505b71
Se han modificado 2 ficheros con 12 adiciones y 0 borrados
  1. 8 0
      lib/change_password.dart
  2. 4 0
      lib/change_phoneno.dart

+ 8 - 0
lib/change_password.dart

@@ -69,6 +69,10 @@ class _ChangePasswordPageState extends State<ChangePasswordPage> {
69 69
 
70 70
   Future<void> _changePassword(
71 71
       {required String newPassword, required String phoneNo}) async {
72
+    if ((!(phoneNo == tmpPhone) || !(mController.text == tmpCode))) {
73
+      Component.toast("手机号与验证码不匹配!", 0);
74
+      return null;
75
+    }
72 76
     var params = {
73 77
       'phoneNumber': phoneNo,
74 78
       'password': newPassword,
@@ -267,7 +271,10 @@ class _ChangePasswordPageState extends State<ChangePasswordPage> {
267 271
     );
268 272
   }
269 273
 
274
+  String tmpPhone = "";
275
+  String tmpCode = "";
270 276
   Future<String?> sendCaptchaCode() async {
277
+    tmpPhone = Global.loginPhoneNo;
271 278
     var params = {
272 279
       'phoneNumber': Global.loginPhoneNo,
273 280
     };
@@ -282,6 +289,7 @@ class _ChangePasswordPageState extends State<ChangePasswordPage> {
282 289
       new NormalResponse.fromJson(jsonResponse);
283 290
       if (mNormalResponse.code == Global.responseSuccessCode) {
284 291
         Component.toast("短信发送成功,请查收!", 2);
292
+        tmpCode = mNormalResponse.data.toString();
285 293
       } else {
286 294
         Component.toast(mNormalResponse.msg.toString(), 0);
287 295
       }

+ 4 - 0
lib/change_phoneno.dart

@@ -268,11 +268,14 @@ class ChangePhoneNoState extends State<ChangePhoneNo> {
268 268
     );
269 269
   }
270 270
 
271
+  String tmpPhone = "";
272
+  String tmpCode = "";
271 273
   Future<String?> sendCaptchaCode() async {
272 274
     if (!Utils.isChinaPhoneLegal(newPhoneController.text)) {
273 275
       Component.toast("请输入正确手机号码!", 0);
274 276
       return null;
275 277
     }
278
+    tmpPhone = newPhoneController.text;
276 279
     var params = {
277 280
       'phoneNumber': newPhoneController.text,
278 281
     };
@@ -287,6 +290,7 @@ class ChangePhoneNoState extends State<ChangePhoneNo> {
287 290
       new NormalResponse.fromJson(jsonResponse);
288 291
       if (mNormalResponse.code == Global.responseSuccessCode) {
289 292
         Component.toast("短信发送成功,请查收!", 2);
293
+        tmpCode = mNormalResponse.data.toString();
290 294
       } else {
291 295
         Component.toast(mNormalResponse.msg.toString(), 0);
292 296
       }