From 0d0838d0e186706ca42cf58608d178da15b135cb Mon Sep 17 00:00:00 2001 From: maxinyu Date: Tue, 7 Jul 2026 16:19:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B3=A8=E9=94=80=E7=A1=AE=E5=AE=9A=E5=BC=B9?= =?UTF-8?q?=E7=AA=97=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../personal/CancelAccountActivity.kt | 54 +++++-------------- app/src/main/res/values-zh/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 3 files changed, 16 insertions(+), 40 deletions(-) diff --git a/app/src/main/java/com/ckkj/defense_device/personal/CancelAccountActivity.kt b/app/src/main/java/com/ckkj/defense_device/personal/CancelAccountActivity.kt index 387fb9d..38c7306 100644 --- a/app/src/main/java/com/ckkj/defense_device/personal/CancelAccountActivity.kt +++ b/app/src/main/java/com/ckkj/defense_device/personal/CancelAccountActivity.kt @@ -10,6 +10,8 @@ import com.ckkj.defense_device.databinding.CancelAccountActivityBinding import com.ckkj.defense_device.login.LoginActivity import com.ckkj.defense_device.utils.RetrofitNetwork import com.ckkj.defense_device.utils.UserinfoUtil +import com.ckkj.defense_device.view.CustomDialogFragment +import com.ckkj.defense_device.view.DefenseDialogs import com.gyf.immersionbar.ImmersionBar import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -81,19 +83,18 @@ class CancelAccountActivity : AppCompatActivity() { } binding.btnCancelAccount.setOnClickListener { - val verificationCode = binding.etVerificationCode.text.toString() - - if (verificationCode.isEmpty()) { - Toast.makeText(this, R.string.enter_verification_code_pls, Toast.LENGTH_SHORT).show() - return@setOnClickListener - } - - if (verificationCode.length != 6) { - Toast.makeText(this, R.string.verification_code_error, Toast.LENGTH_SHORT).show() - return@setOnClickListener - } - - cancelAccount(verificationCode) + DefenseDialogs.showDialog( + this, + config = CustomDialogFragment.Config( + title = getString(R.string.tip), + message = getString(R.string.confirm_cancel_account_user_account), + positiveText = getString(R.string.confirm), + negativeText = getString(R.string.cancel) + ), + onPositiveClick = { + Toast.makeText(this@CancelAccountActivity, getString(R.string.cancel_account), Toast.LENGTH_SHORT).show() + } + ) } } @@ -135,33 +136,6 @@ class CancelAccountActivity : AppCompatActivity() { }.start() } - private fun cancelAccount(verificationCode: String) { - binding.btnCancelAccount.isEnabled = false - - CoroutineScope(Dispatchers.IO).launch { - try { - val response = RetrofitNetwork.getNetworkService().logout() - withContext(Dispatchers.Main) { - binding.btnCancelAccount.isEnabled = true - if (response.code == 200) { - UserinfoUtil.clearUserInfo() - Toast.makeText(this@CancelAccountActivity, getString(R.string.cancel_account), Toast.LENGTH_SHORT).show() - val intent = Intent(this@CancelAccountActivity, LoginActivity::class.java) - intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK - startActivity(intent) - finish() - } else { - Toast.makeText(this@CancelAccountActivity, response.msg, Toast.LENGTH_SHORT).show() - } - } - } catch (e: Exception) { - withContext(Dispatchers.Main) { - binding.btnCancelAccount.isEnabled = true - Toast.makeText(this@CancelAccountActivity, R.string.network_error, Toast.LENGTH_SHORT).show() - } - } - } - } override fun onDestroy() { super.onDestroy() diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index d2cc5b8..059a0fe 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -510,5 +510,6 @@ 注销后无法恢复,请谨慎操作 当前账号 注销 + 确定注销该用户吗? \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 99464fe..378aa45 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -518,4 +518,5 @@ Account data cannot be restored after cancellation, please proceed with caution Current Account Cancel + Confirm Cancel Account User Account \ No newline at end of file