Browse Source

修改注销账号部分逻辑和样式

Pq 8 tháng trước cách đây
mục cha
commit
e59a153d41

+ 7 - 0
BaseLibrary/src/main/java/com/cooleshow/base/widgets/dialog/CommonConfirmDialog2.java

@@ -123,6 +123,13 @@ public class CommonConfirmDialog2 extends BaseFullDialog {
         }
     }
 
+    public void setCancelBackground(Drawable background, int textColor) {
+        if (mTvCancel != null) {
+            mTvCancel.setBackground(background);
+            mTvCancel.setTextColor(getContext().getResources().getColor(textColor));
+        }
+    }
+
     public void setOnConfirmClickListener(View.OnClickListener listener) {
         if (mTvConfirm != null) {
             mTvConfirm.setOnClickListener(listener);

+ 1 - 1
BaseLibrary/src/main/res/drawable/shape_fe2451_point.xml

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
 <shape xmlns:android="http://schemas.android.com/apk/res/android"
     android:shape="oval">
-    <solid android:color="#FE2451"/>
+    <solid android:color="?attr/klx_main_color"/>
 </shape>

+ 2 - 0
BaseLibrary/src/main/res/values/colors.xml

@@ -212,4 +212,6 @@
     <color name="color_ff623a">#FF623A</color>
     <color name="color_f0af88">#F0AF88</color>
     <color name="color_fada9b">#fada9b</color>
+    <color name="color_1bb99b">#1BB99B</color>
+    <color name="color_f44541">#F44541</color>
 </resources>

+ 23 - 8
usercenter/src/main/java/com/cooleshow/usercenter/presenter/SignOutAccountPresenter.java

@@ -7,6 +7,7 @@ import com.cooleshow.base.common.BaseConstant;
 import com.cooleshow.base.data.net.ApiException;
 import com.cooleshow.base.presenter.BasePresenter;
 import com.cooleshow.base.rx.BaseObserver;
+import com.cooleshow.base.utils.ApiUtils;
 import com.cooleshow.base.utils.ErrorParse;
 import com.cooleshow.base.utils.RequestBodyUtil;
 import com.cooleshow.base.utils.ToastUtil;
@@ -27,13 +28,14 @@ import java.util.Map;
  * 类说明:
  */
 public class SignOutAccountPresenter extends BasePresenter<SignOutAccountContract.SignOutAccountView> implements SignOutAccountContract.Presenter {
+    public static final int SIGN_OUT_ERROR_CODE = 5201;
 
-    public void sendSmsCode(String mobile,String imgCode) {
+    public void sendSmsCode(String mobile, String imgCode) {
         getView().showLoading();
         if (BaseApplication.Companion.isTeacherClient()) {
-            sendVerifyCodeForTeacher(mobile,imgCode);
+            sendVerifyCodeForTeacher(mobile, imgCode);
         } else {
-            sendVerifyCodeForStu(mobile,imgCode);
+            sendVerifyCodeForStu(mobile, imgCode);
         }
     }
 
@@ -43,8 +45,8 @@ public class SignOutAccountPresenter extends BasePresenter<SignOutAccountContrac
      *
      * @param mobile
      */
-    private void sendVerifyCodeForStu(String mobile,String imgCode) {
-        addSubscribe(create(UserApi.class).sendSmsCodeForStu(mobile,imgCode, UserConstants.SEND_VERIFY_CODE_TYPE_LOGOFF), new BaseObserver<Object>(getView()) {
+    private void sendVerifyCodeForStu(String mobile, String imgCode) {
+        addSubscribe(create(UserApi.class).sendSmsCodeForStu(mobile, imgCode, UserConstants.SEND_VERIFY_CODE_TYPE_LOGOFF), new BaseObserver<Object>(getView()) {
             @Override
             protected void onSuccess(Object data) {
                 if (getView() != null) {
@@ -67,8 +69,8 @@ public class SignOutAccountPresenter extends BasePresenter<SignOutAccountContrac
      *
      * @param mobile
      */
-    private void sendVerifyCodeForTeacher(String mobile,String imgCode) {
-        addSubscribe(create(UserApi.class).sendSmsCode(mobile,imgCode, UserConstants.SEND_VERIFY_CODE_TYPE_LOGOFF), new BaseObserver<Object>(getView()) {
+    private void sendVerifyCodeForTeacher(String mobile, String imgCode) {
+        addSubscribe(create(UserApi.class).sendSmsCode(mobile, imgCode, UserConstants.SEND_VERIFY_CODE_TYPE_LOGOFF), new BaseObserver<Object>(getView()) {
             @Override
             protected void onSuccess(Object data) {
                 if (getView() != null) {
@@ -89,6 +91,7 @@ public class SignOutAccountPresenter extends BasePresenter<SignOutAccountContrac
 
     /**
      * 图片验证码验证
+     *
      * @param phone
      * @param imgCode
      */
@@ -110,7 +113,7 @@ public class SignOutAccountPresenter extends BasePresenter<SignOutAccountContrac
         });
     }
 
-    public void signOutAccount(String code){
+    public void signOutAccount(String code) {
         addSubscribe(create(UserApi.class).signOutAccount(code), new BaseObserver<Object>(getView()) {
             @Override
             protected void onSuccess(Object data) {
@@ -118,6 +121,18 @@ public class SignOutAccountPresenter extends BasePresenter<SignOutAccountContrac
                     getView().signOutAccountSuccess();
                 }
             }
+
+            @Override
+            public void onError(Throwable e) {
+                if (e instanceof ApiException) {
+                    ApiException api = (ApiException) e;
+                    if (api.getErrcode() == SIGN_OUT_ERROR_CODE) {
+                        getView().signOutAccountError(api.getErrmsg());
+                        return;
+                    }
+                }
+                super.onError(e);
+            }
         });
     }
 }

+ 2 - 0
usercenter/src/main/java/com/cooleshow/usercenter/presenter/contract/SignOutAccountContract.java

@@ -18,6 +18,8 @@ public interface SignOutAccountContract {
 
         void signOutAccountSuccess();
 
+        void signOutAccountError(String errmsg);
+
     }
     interface Presenter {
     }

+ 31 - 7
usercenter/src/main/java/com/cooleshow/usercenter/ui/activity/setting/SignOutAccountActivity.java

@@ -20,6 +20,7 @@ import com.cooleshow.base.utils.SizeUtils;
 import com.cooleshow.base.utils.ToastUtil;
 import com.cooleshow.base.utils.helper.QMUIStatusBarHelper;
 import com.cooleshow.base.widgets.dialog.CommonConfirmDialog;
+import com.cooleshow.base.widgets.dialog.CommonConfirmDialog2;
 import com.cooleshow.base.widgets.dialog.CommonDialog;
 import com.cooleshow.base.widgets.dialog.ImgVerifyCodeDialog;
 import com.cooleshow.usercenter.R;
@@ -28,6 +29,7 @@ import com.cooleshow.usercenter.databinding.AcSignOutAccountLayoutBinding;
 import com.cooleshow.usercenter.helper.UserHelper;
 import com.cooleshow.usercenter.presenter.SignOutAccountPresenter;
 import com.cooleshow.usercenter.presenter.contract.SignOutAccountContract;
+import com.cooleshow.usercenter.widget.SignOutFailTipDialog;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -49,7 +51,9 @@ public class SignOutAccountActivity extends BaseMVPActivity<AcSignOutAccountLayo
         @Override
         public void run() {
             countTimeValue--;
+
             viewBinding.tvSendVerifyCode.setText(countTimeValue + "s");
+            viewBinding.tvSendVerifyCode.setAlpha(0.6f);
             viewBinding.tvSendVerifyCode.setClickable(false);
             if (countTimeValue < 0) {
                 resetBt();
@@ -70,6 +74,8 @@ public class SignOutAccountActivity extends BaseMVPActivity<AcSignOutAccountLayo
     @Override
     protected void initView() {
         initMidTitleToolBar(viewBinding.toolbarInclude.toolbar, "注销账号");
+        boolean tenantAccount = UserHelper.isTenantAccount();
+        viewBinding.ivTip.setImageResource(tenantAccount ? R.drawable.icon_exclamation_mark_tip : R.drawable.icon_exclamation_mark_tip2);
     }
 
     @Override
@@ -124,15 +130,18 @@ public class SignOutAccountActivity extends BaseMVPActivity<AcSignOutAccountLayo
             ToastUtil.getInstance().showShort("请输入验证码");
             return;
         }
-        CommonDialog commonConfirmDialog = new CommonDialog(this);
+        CommonConfirmDialog2 commonConfirmDialog = new CommonConfirmDialog2(this);
         commonConfirmDialog.show();
-        int confirmTextColor = getResources().getColor(com.cooleshow.base.R.color.white);
-        commonConfirmDialog.setCancelTextBg("确定", confirmTextColor, StyleConfig.getCoverBtnStyle(this, com.cooleshow.base.R.drawable.sure_btn_bg));
-        commonConfirmDialog.setConfirmTextBg("取消", StyleConfig.getMainColor(this), StyleConfig.getBorderNoCoverBtnStyle(this, com.cooleshow.base.R.drawable.cancel_btn_bg));
-        commonConfirmDialog.getIvIcon().setBackground(StyleConfig.getCoverBtnStyle(this, com.cooleshow.base.R.drawable.btn_green_stu_line_shape));
+        int cancelTextColor = com.cooleshow.base.R.color.white;
+        int confirmTextColor = com.cooleshow.base.R.color.color_333333;
+        commonConfirmDialog.setCancelBackground(StyleConfig.getCoverBtnStyle(this, com.cooleshow.base.R.drawable.sure_btn_bg), cancelTextColor);
+        commonConfirmDialog.setConfirmBackground(com.cooleshow.base.R.drawable.shape_border_dbdbdb_1dp_22dp, confirmTextColor);
+        commonConfirmDialog.setCancelText("确认");
+        commonConfirmDialog.setConfirmText("取消");
+
 
-        commonConfirmDialog.setTitle("提示");
-        commonConfirmDialog.setContent("注销账号后您所有的留存信息将被清空且无法恢复,请谨慎操作");
+        commonConfirmDialog.setTitle("注销账号");
+        commonConfirmDialog.setContent("请确认是否要注销账号?");
         commonConfirmDialog.setOnConfirmClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
@@ -211,9 +220,24 @@ public class SignOutAccountActivity extends BaseMVPActivity<AcSignOutAccountLayo
                 .navigation();
     }
 
+    @Override
+    public void signOutAccountError(String errmsg) {
+        if(!checkActivityExist()){
+            return;
+        }
+        showErrorTipMsg(errmsg);
+    }
+
+    private void showErrorTipMsg(String errmsg) {
+        SignOutFailTipDialog dialog =new SignOutFailTipDialog(this);
+        dialog.show();
+        dialog.setContent(errmsg);
+    }
+
     private void resetBt() {
         viewBinding.tvSendVerifyCode.setClickable(true);
         viewBinding.tvSendVerifyCode.setText("获取验证码");
+        viewBinding.tvSendVerifyCode.setAlpha(1.0f);
     }
 
     @Override

+ 115 - 0
usercenter/src/main/java/com/cooleshow/usercenter/widget/SignOutFailTipDialog.java

@@ -0,0 +1,115 @@
+package com.cooleshow.usercenter.widget;
+
+import android.content.Context;
+import android.graphics.drawable.Drawable;
+import android.os.Bundle;
+import android.view.Gravity;
+import android.view.View;
+import android.view.Window;
+import android.view.WindowManager;
+import android.widget.TextView;
+
+import com.cooleshow.base.widgets.dialog.BaseFullDialog;
+import com.cooleshow.usercenter.R;
+
+import androidx.annotation.NonNull;
+
+/**
+ * Author by pq, Date on 2022/6/17.
+ */
+public class SignOutFailTipDialog extends BaseFullDialog {
+
+    private TextView mTvContent;
+    private TextView mTvContent2;
+    private TextView mTvConfirm;
+    private TextView mTvTitle;
+
+    private int width;
+    private int height;
+
+    public SignOutFailTipDialog(@NonNull Context context) {
+        super(context, com.cooleshow.base.R.style.BaseDialog);
+    }
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.dialog_sign_out_fail_layout);
+        Window window = getWindow();
+        WindowManager.LayoutParams lp = window.getAttributes();
+        lp.gravity = Gravity.CENTER;
+        lp.width = width != 0 ? width : WindowManager.LayoutParams.MATCH_PARENT;
+        lp.height = height != 0 ? height : WindowManager.LayoutParams.WRAP_CONTENT;
+        getWindow().setAttributes(lp);
+
+
+        mTvContent = findViewById(R.id.tv_content);
+        mTvContent2 = findViewById(R.id.tv_content2);
+        mTvConfirm = findViewById(R.id.tv_confirm);
+        mTvTitle = findViewById(R.id.tv_title);
+        mTvConfirm.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                dismiss();
+            }
+        });
+    }
+
+    public void setWidth(int width) {
+        this.width = width;
+    }
+
+    public void setHeight(int height) {
+        this.height = height;
+    }
+
+    /**
+     * 设置主文本
+     *
+     * @param text
+     */
+    public void setContent(String text) {
+        if (mTvContent2 != null) {
+            mTvContent2.setText(text);
+        }
+    }
+
+    public void setTitle(String title) {
+        if (mTvTitle != null) {
+            mTvTitle.setText(title);
+        }
+    }
+
+
+    /**
+     * 设置确认按钮text
+     *
+     * @param text
+     */
+    public void setConfirmText(String text) {
+        if (mTvConfirm != null) {
+            mTvConfirm.setText(text);
+        }
+    }
+
+    public void setConfirmBackground(int background, int textColor) {
+        if (mTvConfirm != null) {
+            mTvConfirm.setBackgroundResource(background);
+            mTvConfirm.setTextColor(getContext().getResources().getColor(textColor));
+        }
+    }
+
+    public void setConfirmBackground(Drawable background, int textColor) {
+        if (mTvConfirm != null) {
+            mTvConfirm.setBackground(background);
+            mTvConfirm.setTextColor(getContext().getResources().getColor(textColor));
+        }
+    }
+
+
+    public void setOnConfirmClickListener(View.OnClickListener listener) {
+        if (mTvConfirm != null) {
+            mTvConfirm.setOnClickListener(listener);
+        }
+    }
+}

BIN
usercenter/src/main/res/drawable-xhdpi/icon_exclamation_mark_tip2.png


BIN
usercenter/src/main/res/drawable-xxhdpi/icon_exclamation_mark_tip2.png


+ 1 - 1
usercenter/src/main/res/layout/ac_sign_out_account_layout.xml

@@ -85,7 +85,7 @@
                 android:paddingStart="20dp"
                 android:paddingEnd="20dp"
                 android:text="账号注销将会对您产生以下影响:"
-                android:textColor="@color/color_fe2451"
+                android:textColor="?attr/klx_main_color"
                 android:textStyle="bold"
                 app:layout_constraintLeft_toLeftOf="@+id/tv_tip"
                 app:layout_constraintRight_toRightOf="@+id/tv_tip"

+ 74 - 0
usercenter/src/main/res/layout/dialog_sign_out_fail_layout.xml

@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:layout_marginStart="30dp"
+    android:layout_marginEnd="30dp"
+    android:orientation="vertical">
+
+    <androidx.constraintlayout.widget.ConstraintLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:background="@drawable/shape_10dp_white"
+        android:paddingStart="20dp"
+        android:paddingEnd="20dp"
+        android:paddingBottom="20dp">
+
+
+        <TextView
+            android:id="@+id/tv_title"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center_horizontal"
+            android:paddingTop="20dp"
+            android:text="注销失败"
+            android:textColor="@color/color_333333"
+            android:textSize="@dimen/sp_18"
+            android:textStyle="bold"
+            app:layout_constraintLeft_toLeftOf="parent"
+            app:layout_constraintRight_toRightOf="parent"
+            app:layout_constraintTop_toTopOf="parent" />
+
+        <TextView
+            android:id="@+id/tv_content"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="20dp"
+            android:text="该账户需要处理以下事项后再进行注销:"
+            android:textColor="@color/color_f44541"
+            android:textSize="@dimen/sp_14"
+            app:layout_constraintLeft_toLeftOf="parent"
+            app:layout_constraintTop_toBottomOf="@+id/tv_title" />
+
+
+        <TextView
+            android:id="@+id/tv_content2"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:lineSpacingMultiplier="1.2"
+            android:paddingTop="2dp"
+            android:textColor="@color/color_666666"
+            android:textSize="@dimen/sp_16"
+            app:layout_constraintLeft_toLeftOf="parent"
+            app:layout_constraintRight_toRightOf="parent"
+            app:layout_constraintTop_toBottomOf="@+id/tv_content"
+            tools:text="1、账户存在未支付、未确认收货、售后处理中的订单 2、账户为机构群群主、需要转移群主或解散群聊 3、存在进行中的直播课、陪练课、琴房课,未下架的视频课 4、收入未结算/推广计划未入账" />
+
+        <TextView
+            android:id="@+id/tv_confirm"
+            android:layout_width="0dp"
+            android:layout_height="40dp"
+            android:layout_marginTop="25dp"
+            android:background="@drawable/shape_2dc7aa_to_2dc7aa_22dp"
+            android:gravity="center"
+            android:text="我知道了"
+            android:textColor="@color/white"
+            android:textSize="@dimen/sp_16"
+            app:layout_constraintLeft_toLeftOf="parent"
+            app:layout_constraintRight_toRightOf="parent"
+            app:layout_constraintTop_toBottomOf="@+id/tv_content2" />
+
+    </androidx.constraintlayout.widget.ConstraintLayout>
+</LinearLayout>