封版羽声,作为最后的基础版
This commit is contained in:
@@ -8,6 +8,7 @@ import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.alipay.sdk.app.AuthTask;
|
||||
import com.blankj.utilcode.util.AppUtils;
|
||||
import com.blankj.utilcode.util.LogUtils;
|
||||
@@ -21,6 +22,7 @@ import com.qxcm.moduleutil.base.CommonAppContext;
|
||||
import com.qxcm.moduleutil.bean.UserBean;
|
||||
import com.qxcm.moduleutil.http.BaseObserver;
|
||||
import com.qxcm.moduleutil.presenter.BasePresenter;
|
||||
import com.qxcm.moduleutil.utils.ARouteConstants;
|
||||
import com.qxcm.moduleutil.utils.PreferencesUtils;
|
||||
import com.qxcm.moduleutil.utils.SpUtil;
|
||||
import com.tencent.mm.opensdk.modelmsg.SendAuth;
|
||||
@@ -40,16 +42,16 @@ public class LoginPresenter extends BasePresenter<LoginContacter.View> implement
|
||||
|
||||
@Override
|
||||
public void sendCode(String phoneNumber, int type) {
|
||||
api.sendCode(phoneNumber,"default", new BaseObserver<Object>() {
|
||||
api.sendCode(phoneNumber, "default", new BaseObserver<Object>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(Object o) {
|
||||
MvpRef.get().sendCodeSuccess1(o+"");
|
||||
MvpRef.get().sendCodeSuccess1(o + "");
|
||||
}
|
||||
|
||||
|
||||
@@ -58,14 +60,15 @@ public class LoginPresenter extends BasePresenter<LoginContacter.View> implement
|
||||
|
||||
/**
|
||||
* 登录
|
||||
* @param mobile 手机号
|
||||
*
|
||||
* @param mobile 手机号
|
||||
* @param password 密码
|
||||
* @param code 验证码
|
||||
* @param type 1:手机号登录 2:密码登录
|
||||
* @param code 验证码
|
||||
* @param type 1:手机号登录 2:密码登录
|
||||
*/
|
||||
@Override
|
||||
public void login(String mobile, String password, String code, int type) {
|
||||
if (type==1){
|
||||
if (type == 1) {
|
||||
api.login(mobile, code, new BaseObserver<List<UserBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
@@ -78,8 +81,8 @@ public class LoginPresenter extends BasePresenter<LoginContacter.View> implement
|
||||
}
|
||||
|
||||
});
|
||||
}else if (type==2){
|
||||
api.userLogin(mobile,password, new BaseObserver<List<UserBean>>(){
|
||||
} else if (type == 2) {
|
||||
api.userLogin(mobile, password, new BaseObserver<List<UserBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
@@ -97,13 +100,14 @@ public class LoginPresenter extends BasePresenter<LoginContacter.View> implement
|
||||
|
||||
/**
|
||||
* 支付宝登录
|
||||
*
|
||||
* @param auth_code
|
||||
* @param type type=1:微信登录;type=2:支付宝登录
|
||||
* @param type type=1:微信登录;type=2:支付宝登录
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void oauthLogin(String auth_code, int type) {
|
||||
api.authCode(auth_code,type, new BaseObserver<List<UserBean>>() {
|
||||
public void oauthLogin(String auth_code, int type) {
|
||||
api.authCode(auth_code, type, new BaseObserver<List<UserBean>>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
@@ -154,17 +158,18 @@ public class LoginPresenter extends BasePresenter<LoginContacter.View> implement
|
||||
public void detachView() {
|
||||
|
||||
}
|
||||
|
||||
public void loginSuccess(List<UserBean> userBean) {
|
||||
if (userBean==null) {
|
||||
if (userBean == null) {
|
||||
ToastUtils.showShort("登录失败请重试");
|
||||
return;
|
||||
}
|
||||
if (userBean.size()==1) {
|
||||
if (userBean.size() == 1) {
|
||||
|
||||
CommonAppContext.getInstance().setUser(userBean.get(0));
|
||||
if (userBean.get(0).getAuth()==1){
|
||||
if (userBean.get(0).getAuth() == 1) {
|
||||
SpUtil.setRealName(true);
|
||||
}else {
|
||||
} else {
|
||||
SpUtil.setRealName(false);
|
||||
}
|
||||
|
||||
@@ -188,9 +193,9 @@ public class LoginPresenter extends BasePresenter<LoginContacter.View> implement
|
||||
EventBus.getDefault().post(userBean.get(0));
|
||||
com.blankj.utilcode.util.ActivityUtils.startActivity(MainActivity.class);
|
||||
}
|
||||
}else {
|
||||
Intent intent=new Intent(com.blankj.utilcode.util.ActivityUtils.getTopActivity(), SwitchAccountsActivity.class);
|
||||
Bundle bundle=new Bundle();
|
||||
} else {
|
||||
Intent intent = new Intent(com.blankj.utilcode.util.ActivityUtils.getTopActivity(), SwitchAccountsActivity.class);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putSerializable("userBean", userBean.get(0));
|
||||
intent.putExtras(bundle);
|
||||
com.blankj.utilcode.util.ActivityUtils.startActivity(intent);
|
||||
@@ -200,6 +205,7 @@ public class LoginPresenter extends BasePresenter<LoginContacter.View> implement
|
||||
// EventBus.getDefault().post(new SplashFinishEvent());
|
||||
// AppLog.setUserUniqueID(userBean.getUser_id()); // 设置您自己的账号体系ID, 并保证其唯一性 !
|
||||
}
|
||||
|
||||
public void authorization(String type) {
|
||||
|
||||
if (type.equals("wx")) {
|
||||
@@ -212,7 +218,7 @@ public class LoginPresenter extends BasePresenter<LoginContacter.View> implement
|
||||
// req.scope = "snsapi_userinfo"; // 只能填 snsapi_userinfo
|
||||
// req.state = "wechat_sdk_demo_test";
|
||||
// api.sendReq(req);
|
||||
}else if (type.equals("zfb")){
|
||||
} else if (type.equals("zfb")) {
|
||||
// Map<String, String> result = authTask.authV2(authInfo, true);
|
||||
api.authorization(new BaseObserver<String>() {
|
||||
@Override
|
||||
@@ -228,14 +234,13 @@ public class LoginPresenter extends BasePresenter<LoginContacter.View> implement
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void ysxl() {
|
||||
// ARouter.getInstance().build(ARouters.H5).withString("url", Constant.URL.URL_USER_YSXY).withString("title", "隐私协议").navigation();
|
||||
ARouter.getInstance().build(ARouteConstants.H5).withString("url",CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl() + "/api/Page/page_show?id=4").withString("title", "隐私协议").navigation();
|
||||
}
|
||||
|
||||
public void yhxy() {
|
||||
// ARouter.getInstance().build(ARouters.H5).withString("url", Constant.URL.URL_USER_YHXY).withString("title", "用户协议").navigation();
|
||||
ARouter.getInstance().build(ARouteConstants.H5).withString("url", CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl() + "/api/Page/page_show?id=6").withString("title", "用户协议").navigation();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user