|
@@ -2,6 +2,7 @@ package com.sheep.jiuyan.samllsheep.page;
|
|
|
|
|
|
|
|
import android.content.Intent;
|
|
import android.content.Intent;
|
|
|
import android.os.Handler;
|
|
import android.os.Handler;
|
|
|
|
|
+import android.support.v7.widget.AppCompatEditText;
|
|
|
import android.text.TextUtils;
|
|
import android.text.TextUtils;
|
|
|
import android.view.View;
|
|
import android.view.View;
|
|
|
import android.widget.EditText;
|
|
import android.widget.EditText;
|
|
@@ -15,6 +16,7 @@ import com.sheep.jiuyan.samllsheep.net.SheepCallback;
|
|
|
import com.sheep.jiuyan.samllsheep.net.Url;
|
|
import com.sheep.jiuyan.samllsheep.net.Url;
|
|
|
import com.sheep.jiuyan.samllsheep.page.entry.BindUserEntiey;
|
|
import com.sheep.jiuyan.samllsheep.page.entry.BindUserEntiey;
|
|
|
import com.sheep.jiuyan.samllsheep.utils.SpUtils;
|
|
import com.sheep.jiuyan.samllsheep.utils.SpUtils;
|
|
|
|
|
+import com.sheep.jiuyan.samllsheep.utils.StringUtils;
|
|
|
import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
|
|
import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
@@ -28,14 +30,16 @@ import okhttp3.Call;
|
|
|
|
|
|
|
|
public class RegisterActivity extends BaseActivity {
|
|
public class RegisterActivity extends BaseActivity {
|
|
|
|
|
|
|
|
- private EditText mEtAccount;
|
|
|
|
|
- private EditText mEtCode;
|
|
|
|
|
|
|
+ private AppCompatEditText mEtAccount;
|
|
|
|
|
+ private AppCompatEditText mEtCode;
|
|
|
private TextView mBtnCode;
|
|
private TextView mBtnCode;
|
|
|
- private EditText mEtPsw;
|
|
|
|
|
- private EditText mEtInvite;
|
|
|
|
|
|
|
+ private AppCompatEditText mEtPsw;
|
|
|
|
|
+ private AppCompatEditText mEtInvite;
|
|
|
private TextView mTvWx;
|
|
private TextView mTvWx;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ private boolean isSendCodeSuccess=false;
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
protected int getLayoutId() {
|
|
protected int getLayoutId() {
|
|
|
return R.layout.register_activity;
|
|
return R.layout.register_activity;
|
|
@@ -48,11 +52,11 @@ public class RegisterActivity extends BaseActivity {
|
|
|
|
|
|
|
|
|
|
|
|
|
private void findViews() {
|
|
private void findViews() {
|
|
|
- mEtAccount = (EditText) findViewById(R.id.et_account);
|
|
|
|
|
- mEtCode = (EditText) findViewById(R.id.et_code);
|
|
|
|
|
|
|
+ mEtAccount = (AppCompatEditText) findViewById(R.id.et_account);
|
|
|
|
|
+ mEtCode = (AppCompatEditText) findViewById(R.id.et_code);
|
|
|
mBtnCode = (TextView) findViewById(R.id.btn_code);
|
|
mBtnCode = (TextView) findViewById(R.id.btn_code);
|
|
|
- mEtPsw = (EditText) findViewById(R.id.et_psw);
|
|
|
|
|
- mEtInvite = (EditText) findViewById(R.id.et_invite);
|
|
|
|
|
|
|
+ mEtPsw = (AppCompatEditText) findViewById(R.id.et_psw);
|
|
|
|
|
+ mEtInvite = (AppCompatEditText) findViewById(R.id.et_invite);
|
|
|
mTvWx = (TextView) findViewById(R.id.tv_wx);
|
|
mTvWx = (TextView) findViewById(R.id.tv_wx);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -65,7 +69,6 @@ public class RegisterActivity extends BaseActivity {
|
|
|
register();
|
|
register();
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
-
|
|
|
|
|
mBtnCode.setOnClickListener(new View.OnClickListener() {
|
|
mBtnCode.setOnClickListener(new View.OnClickListener() {
|
|
|
@Override
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
public void onClick(View v) {
|
|
@@ -86,7 +89,13 @@ public class RegisterActivity extends BaseActivity {
|
|
|
mBtnCode.setEnabled(false);
|
|
mBtnCode.setEnabled(false);
|
|
|
String moble = mEtAccount.getText().toString().trim();
|
|
String moble = mEtAccount.getText().toString().trim();
|
|
|
if (TextUtils.isEmpty(moble)) {
|
|
if (TextUtils.isEmpty(moble)) {
|
|
|
- Toast.makeText(this, "请输入手机号", Toast.LENGTH_SHORT).show();
|
|
|
|
|
|
|
+ mEtAccount.setError("请输入手机号");
|
|
|
|
|
+ mBtnCode.setEnabled(true);
|
|
|
|
|
+
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if(!StringUtils.checkMobileNum(moble)){
|
|
|
|
|
+ mEtAccount.setError("请填写正确的手机号码");
|
|
|
mBtnCode.setEnabled(true);
|
|
mBtnCode.setEnabled(true);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -96,6 +105,8 @@ public class RegisterActivity extends BaseActivity {
|
|
|
NetManager.post(Url.REGISTER_HW, map, getApplicationContext(), new SheepCallback<String>(RegisterActivity.this) {
|
|
NetManager.post(Url.REGISTER_HW, map, getApplicationContext(), new SheepCallback<String>(RegisterActivity.this) {
|
|
|
@Override
|
|
@Override
|
|
|
public void success(String o) {
|
|
public void success(String o) {
|
|
|
|
|
+
|
|
|
|
|
+ isSendCodeSuccess=true;
|
|
|
Toast.makeText(RegisterActivity.this, "验证码已发送", Toast.LENGTH_SHORT).show();
|
|
Toast.makeText(RegisterActivity.this, "验证码已发送", Toast.LENGTH_SHORT).show();
|
|
|
mTime = 60;
|
|
mTime = 60;
|
|
|
handler.postDelayed(runnable, 1000);
|
|
handler.postDelayed(runnable, 1000);
|
|
@@ -103,6 +114,7 @@ public class RegisterActivity extends BaseActivity {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void failure(IOException e) {
|
|
public void failure(IOException e) {
|
|
|
|
|
+
|
|
|
mBtnCode.setEnabled(true);
|
|
mBtnCode.setEnabled(true);
|
|
|
String message = e.getMessage();
|
|
String message = e.getMessage();
|
|
|
if (message.contains("参数错误")) {
|
|
if (message.contains("参数错误")) {
|
|
@@ -138,35 +150,55 @@ public class RegisterActivity extends BaseActivity {
|
|
|
String code = mEtCode.getText().toString().trim();
|
|
String code = mEtCode.getText().toString().trim();
|
|
|
String inviteCode = mEtInvite.getText().toString().trim();
|
|
String inviteCode = mEtInvite.getText().toString().trim();
|
|
|
if (TextUtils.isEmpty(moble)) {
|
|
if (TextUtils.isEmpty(moble)) {
|
|
|
- Toast.makeText(this, "请输入手机号", Toast.LENGTH_SHORT).show();
|
|
|
|
|
|
|
+ mTvWx.setEnabled(true);
|
|
|
|
|
+ mEtAccount.setError("请输入手机号");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if(!StringUtils.checkMobileNum(moble)){
|
|
|
|
|
+ mEtAccount.setError("请填写正确的手机号码");
|
|
|
mTvWx.setEnabled(true);
|
|
mTvWx.setEnabled(true);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
if (TextUtils.isEmpty(code)) {
|
|
if (TextUtils.isEmpty(code)) {
|
|
|
- Toast.makeText(this, "请输入验证码", Toast.LENGTH_SHORT).show();
|
|
|
|
|
mTvWx.setEnabled(true);
|
|
mTvWx.setEnabled(true);
|
|
|
|
|
+ mEtCode.setError("请输入验证码");
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- if (TextUtils.isEmpty(psw)) {
|
|
|
|
|
- Toast.makeText(this, "请输入密码", Toast.LENGTH_SHORT).show();
|
|
|
|
|
|
|
+ if (code.length()!=6) {
|
|
|
mTvWx.setEnabled(true);
|
|
mTvWx.setEnabled(true);
|
|
|
|
|
+ mEtCode.setError("请填写6位手机验证码");
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if (TextUtils.isEmpty(psw)) {
|
|
|
|
|
+ mTvWx.setEnabled(true);
|
|
|
|
|
+ mEtPsw.setError("请输入密码");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (psw.length()<6) {
|
|
|
|
|
+ mTvWx.setEnabled(true);
|
|
|
|
|
+ mEtPsw.setError("密码长度必须大于6位");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
HashMap<String, String> map = new HashMap<>();
|
|
HashMap<String, String> map = new HashMap<>();
|
|
|
map.put("mobile", moble);
|
|
map.put("mobile", moble);
|
|
|
map.put("psw", psw);
|
|
map.put("psw", psw);
|
|
|
map.put("code", code);
|
|
map.put("code", code);
|
|
|
map.put("step", "2");
|
|
map.put("step", "2");
|
|
|
map.put("invite", inviteCode);
|
|
map.put("invite", inviteCode);
|
|
|
|
|
+ showProgress();
|
|
|
NetManager.post(Url.REGISTER_HW, map, getApplicationContext(), new SheepCallback<String>(RegisterActivity.this) {
|
|
NetManager.post(Url.REGISTER_HW, map, getApplicationContext(), new SheepCallback<String>(RegisterActivity.this) {
|
|
|
@Override
|
|
@Override
|
|
|
public void success(String token) {
|
|
public void success(String token) {
|
|
|
|
|
+ hideProgress();
|
|
|
loginAuto(token);
|
|
loginAuto(token);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void failure(IOException e) {
|
|
public void failure(IOException e) {
|
|
|
|
|
+ hideProgress();
|
|
|
String message = e.getMessage();
|
|
String message = e.getMessage();
|
|
|
if (message.contains("参数错误")) {
|
|
if (message.contains("参数错误")) {
|
|
|
message = message.replace("参数错误", "");
|
|
message = message.replace("参数错误", "");
|
|
@@ -181,24 +213,25 @@ public class RegisterActivity extends BaseActivity {
|
|
|
private void loginAuto(String token) {
|
|
private void loginAuto(String token) {
|
|
|
HashMap<String, String> map = new HashMap<>();
|
|
HashMap<String, String> map = new HashMap<>();
|
|
|
map.put("token", token);
|
|
map.put("token", token);
|
|
|
|
|
+ showProgress();
|
|
|
NetManager.get(Url.REGISTER_SHEEP, map, getApplicationContext(), new SheepCallback<BindUserEntiey>(RegisterActivity.this) {
|
|
NetManager.get(Url.REGISTER_SHEEP, map, getApplicationContext(), new SheepCallback<BindUserEntiey>(RegisterActivity.this) {
|
|
|
@Override
|
|
@Override
|
|
|
public void success(BindUserEntiey o) {
|
|
public void success(BindUserEntiey o) {
|
|
|
|
|
+ hideProgress();
|
|
|
SpUtils.login(RegisterActivity.this, o.getOpenId());
|
|
SpUtils.login(RegisterActivity.this, o.getOpenId());
|
|
|
Intent intent = new Intent(RegisterActivity.this, MainActivity.class);
|
|
Intent intent = new Intent(RegisterActivity.this, MainActivity.class);
|
|
|
intent.putExtra("tag", "once");
|
|
intent.putExtra("tag", "once");
|
|
|
startActivity(intent);
|
|
startActivity(intent);
|
|
|
finish();
|
|
finish();
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void failure(IOException e) {
|
|
public void failure(IOException e) {
|
|
|
|
|
+ hideProgress();
|
|
|
Toast.makeText(RegisterActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
|
|
Toast.makeText(RegisterActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
|
|
|
mTvWx.setEnabled(true);
|
|
mTvWx.setEnabled(true);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void initData() {
|
|
public void initData() {
|
|
|
|
|
|