Sfoglia il codice sorgente

B端 报名失败弹窗

ZhangXinYu 6 anni fa
parent
commit
121f407675

+ 6 - 6
app/src/main/java/com/webrain/happywork/http/ApiCode.java

@@ -43,12 +43,12 @@ public class ApiCode {
         /*===========Response响应码================*/
         //HTTP请求成功状态码
         public static final int HTTP_SUCCESS = 0;
-//        //未绑定手机
-//        public static final int HTTP_NO_BINGDING_PHONE = 1014;
-//        //简历不存在
-//        public static final int HTTP_NO_RESUME = 1015;
-//        //存在多简历信息
-//        public static final int HTTP_DOUBLE_RESUME = 2009;
+        //您已经报名了其他需求,等其他需求确认完毕再来申请
+        public static final int HTTP_HAVE_APPLY_DEMAND_WAIT = 1023;
+        //您存在进行中的订单,无法报名
+        public static final int HTTP_HAVE_APPLY_DEMAND_GOING = 1024;
+        //您已经报名该需求
+        public static final int HTTP_APPLY_THIS_DEMAND = 1025;
 //        //AccessToken错误或已过期
 //        public static final int ACCESS_TOKEN_EXPIRED = 10001;
 //        //RefreshToken错误或已过期

+ 11 - 11
app/src/main/java/com/webrain/happywork/http/exception/ApiException.java

@@ -96,24 +96,24 @@ public class ApiException extends IOException {
     private static ApiException disposeHttpResponseException(HttpResponseException e) {
         ApiException ex = new ApiException(e, e.getErrorCode() + "");
         ex.errorMessage = e.getErrorMessage();
-//        if (e.getErrorCode() == ApiCode.Response.HTTP_NO_BINGDING_PHONE) {//未绑定 需要绑定手机号
-//            ex.isNeedShowError = false;
-//        } else if (e.getErrorCode() == ApiCode.Response.HTTP_NO_RESUME) {//简历不存在需要填写简历
-//            ex.isNeedShowError = false;
-//        } else if (e.getErrorCode() == ApiCode.Response.HTTP_DOUBLE_RESUME) {//存在多个简历需要删选
-//            ex.isNeedShowError = false;
-//        }
+        if (e.getErrorCode() == ApiCode.Response.HTTP_HAVE_APPLY_DEMAND_WAIT) {//未绑定 需要绑定手机号
+            ex.isNeedShowError = false;
+        } else if (e.getErrorCode() == ApiCode.Response.HTTP_HAVE_APPLY_DEMAND_GOING) {//简历不存在需要填写简历
+            ex.isNeedShowError = false;
+        } else if (e.getErrorCode() == ApiCode.Response.HTTP_APPLY_THIS_DEMAND) {//存在多个简历需要删选
+            ex.isNeedShowError = false;
+        }
         return ex;
     }
 
-    public String getErrorCode() {
-        return errorCode;
-    }
-
     public String getErrorMessage() {
         return errorMessage;
     }
 
+    public String getErrorCode() {
+        return errorCode;
+    }
+
     public void setErrorMessage(String message) {
         this.errorMessage = message;
     }

+ 18 - 2
app/src/main/java/com/webrain/happywork/ui/activity/DemandDetailActivity.java

@@ -14,6 +14,7 @@ import com.webrain.happywork.ui.base.BaseActivity;
 import com.webrain.happywork.ui.mvp.contacts.DemandDetailContacts;
 import com.webrain.happywork.ui.mvp.presenter.DemandDetailPresenter;
 import com.webrain.happywork.ui.widget.dialog.MineLightDialog;
+import com.webrain.happywork.ui.widget.dialog.SureDialog;
 
 import butterknife.BindView;
 import butterknife.OnClick;
@@ -39,11 +40,12 @@ public class DemandDetailActivity extends BaseActivity<DemandDetailPresenter> im
     TextView tvAcceptance;
     @BindView(R.id.btn_apply)
     Button btnApply;
-
-    MineLightDialog mineLightDialog;
     @BindView(R.id.tv_stage)
     TextView tvStage;
 
+    MineLightDialog mineLightDialog;
+    SureDialog mSureDialg;
+
     @Override
     public int getLayoutId() {
         return R.layout.activity_demand_detail;
@@ -112,6 +114,20 @@ public class DemandDetailActivity extends BaseActivity<DemandDetailPresenter> im
     }
 
     /**
+     * 错误信息弹窗
+     *
+     * @param errorMsg
+     */
+    @Override
+    public void onErrorDialog(String errorMsg) {
+        if (mSureDialg == null) {
+            mSureDialg = new SureDialog(mContext);
+        }
+        mSureDialg.initData(R.string.apply_fail, errorMsg, 0, R.string.sure, null);
+        mSureDialg.show();
+    }
+
+    /**
      * 请求网络出错
      */
     @Override

+ 2 - 0
app/src/main/java/com/webrain/happywork/ui/mvp/contacts/DemandDetailContacts.java

@@ -9,6 +9,8 @@ public class DemandDetailContacts {
     public interface IDemandDetailView extends IView {
         void onRequirementDetail(RequirementBean bean);
 
+        void onErrorDialog(String errorMsg);
+
         void onError();
     }
 

+ 9 - 0
app/src/main/java/com/webrain/happywork/ui/mvp/presenter/DemandDetailPresenter.java

@@ -3,6 +3,7 @@ package com.webrain.happywork.ui.mvp.presenter;
 
 import com.webrain.happywork.bean.RequirementBean;
 import com.webrain.happywork.callback.MvpDataCallBack;
+import com.webrain.happywork.http.ApiCode;
 import com.webrain.happywork.http.exception.ApiException;
 import com.webrain.happywork.ui.activity.DemandDetailActivity;
 import com.webrain.happywork.ui.base.BasePresenter;
@@ -43,6 +44,14 @@ public class DemandDetailPresenter extends BasePresenter<DemandDetailActivity> i
                     if (isViewAttach()) {
                     }
                 }
+
+                @Override
+                public void onError(ApiException exception) {
+                    super.onError(exception);
+                    if (exception.getErrorCode().equals(ApiCode.Response.HTTP_HAVE_APPLY_DEMAND_WAIT + "") || exception.getErrorCode().equals(ApiCode.Response.HTTP_HAVE_APPLY_DEMAND_GOING + "") || exception.getErrorCode().equals(ApiCode.Response.HTTP_APPLY_THIS_DEMAND + "")) {//未绑定 需要绑定手机号
+                        mvpReference.get().onErrorDialog(exception.getErrorMessage());
+                    }
+                }
             }, lightStr);
         }
     }

+ 34 - 0
app/src/main/java/com/webrain/happywork/ui/widget/dialog/SureDialog.java

@@ -2,6 +2,7 @@ package com.webrain.happywork.ui.widget.dialog;
 
 import android.app.Dialog;
 import android.content.Context;
+import android.text.TextUtils;
 import android.view.View;
 import android.widget.TextView;
 
@@ -44,6 +45,21 @@ public class SureDialog {
      * 初始化提示数据
      *
      * @param titleResId
+     * @param cancelResId
+     * @param sureResId
+     * @param onClickSureListener
+     * @return
+     */
+    public SureDialog initData(int titleResId, String contentId, int cancelResId, int sureResId, OnClickSureListener onClickSureListener) {
+        this.onClickSureListener = onClickSureListener;
+        mViewHolder.initData(titleResId, contentId, cancelResId, sureResId);
+        return this;
+    }
+
+    /**
+     * 初始化提示数据
+     *
+     * @param titleResId
      * @param sureResId
      * @param onClickSureListener
      * @return
@@ -123,6 +139,24 @@ public class SureDialog {
             tvSure.setText(mContext.getString(sureResId));
         }
 
+        public void initData(int titleResId, String contentResId, int cancelResId, int sureResId) {
+            tvTitle.setText(mContext.getString(titleResId));
+            if (TextUtils.isEmpty(contentResId)) {
+                tvContent.setVisibility(View.GONE);
+            } else {
+                tvContent.setVisibility(View.VISIBLE);
+                tvContent.setText(contentResId);
+            }
+            if (cancelResId == 0) {
+                vLine.setVisibility(View.GONE);
+                tvCancel.setVisibility(View.GONE);
+            } else {
+                vLine.setVisibility(View.VISIBLE);
+                tvCancel.setVisibility(View.VISIBLE);
+                tvCancel.setText(mContext.getString(cancelResId));
+            }
+            tvSure.setText(mContext.getString(sureResId));
+        }
 
     }
 

+ 7 - 5
app/src/main/res/layout/dialog_sure.xml

@@ -7,8 +7,9 @@
 
     <LinearLayout
         android:layout_width="322dp"
-        android:layout_height="162dp"
+        android:layout_height="wrap_content"
         android:background="@drawable/corners_gray_f5_5dp"
+        android:minHeight="162dp"
         android:orientation="vertical">
 
 
@@ -17,7 +18,8 @@
             android:layout_height="0dp"
             android:layout_weight="1"
             android:gravity="center"
-            android:orientation="vertical">
+            android:orientation="vertical"
+            android:padding="24dp">
 
             <TextView
                 android:id="@+id/tv_title"
@@ -33,11 +35,11 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_marginTop="12dp"
-                android:visibility="gone"
                 android:gravity="center"
-                android:singleLine="true"
+                android:lineSpacingExtra="5dp"
                 android:textColor="@color/text_gray_88"
-                android:textSize="@dimen/px48_16sp" />
+                android:textSize="@dimen/px48_16sp"
+                android:visibility="gone" />
         </LinearLayout>
 
         <View

+ 1 - 0
app/src/main/res/values/strings.xml

@@ -7,6 +7,7 @@
     <string name="cancel">取消</string>
     <string name="sure">确认</string>
     <string name="sure_apply">确认报名</string>
+    <string name="apply_fail">报名失败</string>
     <string name="is_logout">是否退出登录</string>
     <string name="business">行业</string>
     <string name="unit_price">单价</string>