regex = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0,5-9]))\\d{8}$";
//创建presenter
registPresenter = new RegistPresenter(this);
}
registPresenter = new RegistPresenter(this);
}
public void regist(View view) {
String phone = edit_phone.getText().toString();
String pwd = edit_pwd.getText().toString();
String phone = edit_phone.getText().toString();
String pwd = edit_pwd.getText().toString();
//非空判断
if (! TextUtils.isEmpty(phone) && !TextUtils.isEmpty(pwd)){
//验证手机号
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(phone);
if (m.matches() && pwd.length()>=6){
if (! TextUtils.isEmpty(phone) && !TextUtils.isEmpty(pwd)){
//验证手机号
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(phone);
if (m.matches() && pwd.length()>=6){
//MD5加密....Md5Encoder.encode(pwd)
try {
registPresenter.registUser(phone, pwd, ApiUtil.REGIST_URL);
try {
registPresenter.registUser(phone, pwd, ApiUtil.REGIST_URL);
} catch (Exception e) {
e.printStackTrace();
}
e.printStackTrace();
}
}else if (!m.matches()){
Toast.makeText(RegistActivity.this,"请输入正确的手机号",Toast.LENGTH_SHORT).show();
}else if (pwd.length()<6){
Toast.makeText(RegistActivity.this,"密码长度至少六位",Toast.LENGTH_SHORT).show();
}
Toast.makeText(RegistActivity.this,"请输入正确的手机号",Toast.LENGTH_SHORT).show();
}else if (pwd.length()<6){
Toast.makeText(RegistActivity.this,"密码长度至少六位",Toast.LENGTH_SHORT).show();
}
}else if (TextUtils.isEmpty(phone)){
Toast.makeText(RegistActivity.this,"手机号不能为空",Toast.LENGTH_SHORT).show();
}else if (TextUtils.isEmpty(pwd)){
Toast.makeText(RegistActivity.this,"密码不能为空",Toast.LENGTH_SHORT).show();
}