|
|
@@ -1,5 +1,18 @@
|
|
|
package com.webrain.dailypay.ui.mvp.presenter;
|
|
|
|
|
|
+import android.content.Intent;
|
|
|
+
|
|
|
+import com.webrain.baselibrary.AppConstant;
|
|
|
+import com.webrain.baselibrary.IntentConstant;
|
|
|
+import com.webrain.baselibrary.utils.ToastUtils;
|
|
|
+import com.webrain.dailypay.AppCacheManager;
|
|
|
+import com.webrain.dailypay.R;
|
|
|
+import com.webrain.dailypay.bean.CompanyBean;
|
|
|
+import com.webrain.dailypay.bean.UserBean;
|
|
|
+import com.webrain.dailypay.callback.MvpDataCallBack;
|
|
|
+import com.webrain.dailypay.ui.activity.identity.IdentityCompanyActivity;
|
|
|
+import com.webrain.dailypay.ui.activity.identity.IdentityRecruitersActivity;
|
|
|
+import com.webrain.dailypay.ui.activity.identity.IdentityResultActivity;
|
|
|
import com.webrain.dailypay.ui.base.BasePresenter;
|
|
|
import com.webrain.dailypay.ui.fragment.MeFragment;
|
|
|
import com.webrain.dailypay.ui.mvp.contacts.MeFragmentContacts;
|
|
|
@@ -12,4 +25,116 @@ public class MeFragmentPresenter extends BasePresenter<MeFragment> implements Me
|
|
|
super(view);
|
|
|
this.mMeFragmentModel = new MeFragmentModel(mvpReference.get().getContext());
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取用户数据
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void getUserBean() {
|
|
|
+ if (isViewAttach()) {
|
|
|
+ UserBean userBean = mMeFragmentModel.getUserBean();
|
|
|
+ if (userBean != null) {
|
|
|
+ mvpReference.get().onUserBean(userBean);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 从服务器获取用户信息
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void getHttpUserCompanyBean(final boolean isQueryUserState, final boolean isQueryCompanyState) {
|
|
|
+ if (isViewAttach())
|
|
|
+ mMeFragmentModel.getHttpUserCompanyBean(new MvpDataCallBack<Boolean>() {
|
|
|
+ @Override
|
|
|
+ public void onData(Boolean data) {
|
|
|
+ if (isViewAttach()) {
|
|
|
+ mvpReference.get().onUserBean(AppCacheManager.getInstance().getLoginModel());
|
|
|
+ mvpReference.get().onCompanyBean(AppCacheManager.getInstance().getCompanyModel());
|
|
|
+ if (isQueryUserState) {
|
|
|
+ if (AppCacheManager.getInstance().getLoginModel().getAuthenticationStatus() == AppConstant.APPROVE_SUCCESS) {//认证成功状态,提示认证成功
|
|
|
+ ToastUtils.show(mvpReference.get().getContext(), R.string.toast_yes_authentication);
|
|
|
+ } else if (AppCacheManager.getInstance().getLoginModel().getAuthenticationStatus() == AppConstant.APPROVE_NONE) {//未认证状态,去认证页
|
|
|
+ mvpReference.get().startActivity(new Intent(mvpReference.get().getContext(), IdentityRecruitersActivity.class));
|
|
|
+ } else {//认证失败,认证等待状态,去认证结果页
|
|
|
+ Intent intent = new Intent(mvpReference.get().getContext(), IdentityResultActivity.class);
|
|
|
+ intent.putExtra(IntentConstant.TYPE, AppConstant.APPROVE_PERSONAL);
|
|
|
+ mvpReference.get().startActivity(intent);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (isQueryCompanyState) {
|
|
|
+ if (AppCacheManager.getInstance().getCompanyModel() == null) {//无企业对象,去认证页
|
|
|
+ mvpReference.get().startActivity(new Intent(mvpReference.get().getContext(), IdentityCompanyActivity.class));
|
|
|
+ } else if (AppCacheManager.getInstance().getCompanyModel().getAuthenticationStatus() == AppConstant.APPROVE_SUCCESS) {//认证成功状态,提示认证成功
|
|
|
+ ToastUtils.show(mvpReference.get().getContext(), R.string.toast_yes_authentication);
|
|
|
+ } else if (AppCacheManager.getInstance().getCompanyModel().getAuthenticationStatus() == AppConstant.APPROVE_NONE) {//未认证状态,去认证页
|
|
|
+ mvpReference.get().startActivity(new Intent(mvpReference.get().getContext(), IdentityCompanyActivity.class));
|
|
|
+ } else {//认证失败,认证等待状态,去认证结果页
|
|
|
+ Intent intent = new Intent(mvpReference.get().getContext(), IdentityResultActivity.class);
|
|
|
+ intent.putExtra(IntentConstant.TYPE, AppConstant.APPROVE_COMPANY);
|
|
|
+ mvpReference.get().startActivity(intent);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, isQueryUserState, isQueryCompanyState);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取公司数据
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void getCompanyBean() {
|
|
|
+ if (isViewAttach()) {
|
|
|
+ CompanyBean companyBean = mMeFragmentModel.getCompanyBean();
|
|
|
+ if (companyBean != null) {
|
|
|
+ mvpReference.get().onCompanyBean(companyBean);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 去用户认证
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void goUserAuthentication() {
|
|
|
+ if (isViewAttach())
|
|
|
+ if (AppCacheManager.getInstance().isLogin()) {
|
|
|
+ if (AppCacheManager.getInstance().getLoginModel().getAuthenticationStatus() == AppConstant.APPROVE_SUCCESS)
|
|
|
+ ToastUtils.show(mvpReference.get().getContext(), R.string.toast_yes_authentication);
|
|
|
+ else if (AppCacheManager.getInstance().getLoginModel().getAuthenticationStatus() == AppConstant.APPROVE_NONE) //未认证状态,去认证页
|
|
|
+ mvpReference.get().startActivity(new Intent(mvpReference.get().getContext(), IdentityRecruitersActivity.class));
|
|
|
+ else //认证失败,认证等待状态,去请求刷新状态
|
|
|
+ getHttpUserCompanyBean(true, false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 去企业认证
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void goCompanyAuthentication() {
|
|
|
+ if (isViewAttach())
|
|
|
+ if (AppCacheManager.getInstance().getCompanyModel() == null)//无企业信息, 去认证
|
|
|
+ mvpReference.get().startActivity(new Intent(mvpReference.get().getContext(), IdentityCompanyActivity.class));
|
|
|
+ else if (AppCacheManager.getInstance().getLoginModel().getAuthenticationStatus() == AppConstant.APPROVE_SUCCESS)
|
|
|
+ ToastUtils.show(mvpReference.get().getContext(), R.string.toast_yes_authentication);
|
|
|
+ else if (AppCacheManager.getInstance().getCompanyModel().getAuthenticationStatus() == AppConstant.APPROVE_NONE) //未认证状态,去认证页
|
|
|
+ mvpReference.get().startActivity(new Intent(mvpReference.get().getContext(), IdentityCompanyActivity.class));
|
|
|
+ else //认证失败,认证等待状态,去请求刷新状态
|
|
|
+ getHttpUserCompanyBean(false, true);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 初始化
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void init() {
|
|
|
+ if (isViewAttach()) {
|
|
|
+ getUserBean();
|
|
|
+ getCompanyBean();
|
|
|
+ getHttpUserCompanyBean(false, false);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|