Browse Source

修复bug

Pq 3 years ago
parent
commit
1975671ff3

+ 15 - 1
BaseLibrary/src/main/java/com/cooleshow/base/utils/PhoneUtils.java

@@ -8,6 +8,8 @@ import android.text.TextUtils;
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import androidx.annotation.NonNull;
 import androidx.annotation.RequiresPermission;
@@ -24,7 +26,7 @@ import static android.Manifest.permission.READ_PHONE_STATE;
  * </pre>
  */
 public final class PhoneUtils {
-
+    public static final String MOBLIE_PHONE_PATTERN = "^[1][0-9][0-9]{9}$";
     private PhoneUtils() {
         throw new UnsupportedOperationException("u can't instantiate me...");
     }
@@ -40,6 +42,18 @@ public final class PhoneUtils {
     }
 
     /**
+     * 通过正则验证是否是合法手机号码
+     *
+     * @param phoneNumber 待验证的手机号码
+     * @return 验证结果
+     */
+    public static boolean isMobile(String phoneNumber) {
+        Pattern p = Pattern.compile(MOBLIE_PHONE_PATTERN);
+        Matcher m = p.matcher(phoneNumber);
+        return m.matches();
+    }
+
+    /**
      * Return the unique device id.
      * <p>If the version of SDK is greater than 28, it will return an empty string.</p>
      * <p>Must hold {@code <uses-permission android:name="android.permission.READ_PHONE_STATE" />}</p>

+ 1 - 1
student/src/main/java/com/cooleshow/student/wxapi/WXPayEntryActivity.java

@@ -58,7 +58,7 @@ public class WXPayEntryActivity extends Activity implements IWXAPIEventHandler {
                 EventBus.getDefault().post("PAY_SUCCESS");
 
             } else {
-                ToastUtil.getInstance().showShort("支付失败:" + resp.errCode);
+                ToastUtil.getInstance().showShort("支付失败");
                 EventBus.getDefault().post("PAY_ERROR");
             }
 			/*AlertDialog.Builder builder = new AlertDialog.Builder(this);

+ 1 - 1
teacher/src/main/java/com/cooleshow/teacher/wxapi/WXPayEntryActivity.java

@@ -57,7 +57,7 @@ public class WXPayEntryActivity extends Activity implements IWXAPIEventHandler {
                 ToastUtil.getInstance().showShort("支付成功");
 
             } else {
-                ToastUtil.getInstance().showShort("支付失败:" + resp.errCode);
+                ToastUtil.getInstance().showShort("支付失败");
             }
 			/*AlertDialog.Builder builder = new AlertDialog.Builder(this);
 			builder.setTitle("提示");

+ 2 - 1
usercenter/src/main/java/com/cooleshow/usercenter/ui/activity/VerifyCodeLoginActivity.java

@@ -19,6 +19,7 @@ import com.cooleshow.base.data.net.CommonParamsHelper;
 import com.cooleshow.base.event.LoginStatusEvent;
 import com.cooleshow.base.router.RouterPath;
 import com.cooleshow.base.ui.activity.BaseMVPActivity;
+import com.cooleshow.base.utils.PhoneUtils;
 import com.cooleshow.base.utils.SpannableStringUtils;
 import com.cooleshow.base.utils.ToastUtil;
 import com.cooleshow.base.utils.ToastUtils;
@@ -102,7 +103,7 @@ public class VerifyCodeLoginActivity extends BaseMVPActivity<ActivityVerifyCodeL
             }
             //获取验证码
             String phone = viewBinding.etPhoneNum.getText().toString();
-            if (phone.length() != 11) {
+            if (phone.length() != 11 || !PhoneUtils.isMobile(phone)) {
                 ToastUtil.getInstance().showShort("请输入正确手机号");
                 return;
             }