|
|
@@ -29,9 +29,12 @@ import com.sheep.gamegroup.util.MyDbManager;
|
|
|
import com.sheep.gamegroup.util.SelfCountDownTimer;
|
|
|
|
|
|
import com.sheep.gamegroup.util.XXTEA;
|
|
|
+import com.sheep.jiuyan.samllsheep.BuildConfig;
|
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
|
import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
|
+import com.sheep.jiuyan.samllsheep.utils.G;
|
|
|
import com.sheep.jiuyan.samllsheep.utils.SpUtils;
|
|
|
+import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
|
|
|
|
|
|
import org.xutils.ex.DbException;
|
|
|
|
|
|
@@ -58,12 +61,15 @@ public class PhoneAct extends BaseActivity implements PhoneContract.View {
|
|
|
|
|
|
@Inject
|
|
|
PhonePresenter phonePresenter;
|
|
|
+ @BindView(R.id.phone_tip_tv)
|
|
|
+ TextView phoneTipTv;
|
|
|
|
|
|
private SelfCountDownTimer selfCountDownTimer;
|
|
|
private boolean canGetCaptchaPhone = true;
|
|
|
|
|
|
private String etPhone;
|
|
|
private String etCode;
|
|
|
+ private boolean showNotice = false;//false:手机登录,true:绑定手机
|
|
|
|
|
|
@Override
|
|
|
protected int getLayoutId() {
|
|
|
@@ -73,11 +79,16 @@ public class PhoneAct extends BaseActivity implements PhoneContract.View {
|
|
|
@Override
|
|
|
public void initView() {
|
|
|
activity = this;
|
|
|
+ showNotice = getIntent().getBooleanExtra("show_notice", false);
|
|
|
+ TitleBarUtils
|
|
|
+ .getInstance()
|
|
|
+ .setTitle(this, "手机号登录")
|
|
|
+ .setTitleFinish(this);
|
|
|
DaggerPhoneComponent.builder()
|
|
|
.netComponent(SheepApp.get(this).getNetComponent())
|
|
|
.phoneModule(new PhoneModule(this))
|
|
|
.build()
|
|
|
- .inject(this);
|
|
|
+ .inject(this);
|
|
|
// testData();
|
|
|
}
|
|
|
|
|
|
@@ -106,6 +117,13 @@ public class PhoneAct extends BaseActivity implements PhoneContract.View {
|
|
|
|
|
|
@Override
|
|
|
public void initData() {
|
|
|
+ if (!showNotice) {
|
|
|
+ phoneTipTv.setVisibility(View.GONE);
|
|
|
+ phoneTipTv.setVisibility(View.GONE);
|
|
|
+ } else {
|
|
|
+ phoneTipTv.setVisibility(View.VISIBLE);
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -113,9 +131,9 @@ public class PhoneAct extends BaseActivity implements PhoneContract.View {
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
super.onCreate(savedInstanceState);
|
|
|
// TODO: add setContentView(...) invocation
|
|
|
-
|
|
|
- phoneEtAccount.setText("17628083502");
|
|
|
- phoneEtCode.setText("123456");
|
|
|
+ ButterKnife.bind(this);
|
|
|
+// phoneEtAccount.setText("17628083502");
|
|
|
+// phoneEtCode.setText("123456");
|
|
|
}
|
|
|
|
|
|
@OnClick({R.id.phone_et_account, R.id.phone_et_code, R.id.phone_btn_code, R.id.phone_sure_tv})
|
|
|
@@ -130,6 +148,10 @@ public class PhoneAct extends BaseActivity implements PhoneContract.View {
|
|
|
getCaptcha();
|
|
|
break;
|
|
|
case R.id.phone_sure_tv:
|
|
|
+ if(BuildConfig.DEBUG){
|
|
|
+ goMain();
|
|
|
+ return;
|
|
|
+ }
|
|
|
etPhone = phoneEtAccount.getText().toString().trim();
|
|
|
etCode = phoneEtCode.getText().toString().trim();
|
|
|
loginByPhoneGaptcha();
|
|
|
@@ -200,25 +222,26 @@ public class PhoneAct extends BaseActivity implements PhoneContract.View {
|
|
|
@Override
|
|
|
public void returnLogindata(Object o) {
|
|
|
hideProgress();
|
|
|
- if(o == null){
|
|
|
+ hideProgress();
|
|
|
+ if (o == null) {
|
|
|
return;
|
|
|
}
|
|
|
BaseMessage baseMessage = (BaseMessage) o;
|
|
|
// JSONObject a = JSON.parseObject(o.toString());
|
|
|
- Log.e("------data",baseMessage.getData()+"");
|
|
|
-
|
|
|
- LoginEntity loginEty = FastJsonUtils.toBean( JSONObject.toJSONString(baseMessage.getData()),LoginEntity.class);
|
|
|
+ Log.e("------data", baseMessage.getData() + "");
|
|
|
+ LoginEntity loginEty = JSONObject.parseObject(JSONObject.toJSONString(baseMessage.getData()), LoginEntity.class);
|
|
|
SpUtils.login(activity, loginEty.getToken());
|
|
|
try {
|
|
|
MyDbManager.getInstance().saveOrUpdateUser(loginEty.getUser());
|
|
|
UserEntity userEntity = MyDbManager.getInstance().dbFindUser();
|
|
|
- Log.e("------userEntity",userEntity.getNickname()+"|"+userEntity.getMobile()+"");
|
|
|
- showToast(userEntity.getNickname()+"|"+userEntity.getMobile());
|
|
|
+ Log.e("------userEntity", userEntity.getNickname() + "|" + userEntity.getMobile() + "");
|
|
|
+ G.showToast(userEntity.getNickname() + "|" + userEntity.getMobile());
|
|
|
} catch (DbException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
|
|
|
- Jump2View.getInstance().goPersonnalCenterView(activity, null);
|
|
|
+ Jump2View.getInstance().goHomePageView(activity, null);
|
|
|
+ ActivityManager.getInstance().endActivity(LoginAct.class);
|
|
|
finish();
|
|
|
Log.e("---login_-", o.toString());
|
|
|
}
|
|
|
@@ -226,7 +249,17 @@ public class PhoneAct extends BaseActivity implements PhoneContract.View {
|
|
|
@Override
|
|
|
public void loginFail(ApiException o) {
|
|
|
hideProgress();
|
|
|
- showToast(o.getMessage());
|
|
|
+ G.showToast("登录失败" + "");
|
|
|
+// testData();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void goMain() {
|
|
|
+ // TODO: 2018/3/22 测试界面,过后删除s
|
|
|
+ SpUtils.login(getApplicationContext(), "12@1c421522bb7e44d3cd6a8d59a54df182");
|
|
|
+// startActivity(new Intent(this, ActMain.class));
|
|
|
+ Jump2View.getInstance().goHomePageView(this, null);
|
|
|
+ ActivityManager.getInstance().endActivity(LoginAct.class);
|
|
|
+ finish();
|
|
|
}
|
|
|
|
|
|
|