From 05abf009943147ff970f45579ca85bab2b6a8b2e Mon Sep 17 00:00:00 2001 From: lyr Date: Thu, 17 Mar 2022 11:59:39 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=85=89=E7=8E=AF=E5=8A=A9=E6=89=8BV5?= =?UTF-8?q?.8.0=E3=80=91=E5=AE=9E=E5=90=8D=E8=AE=A4=E8=AF=81=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E7=AC=AC=E4=BA=94=E6=9C=9F=EF=BC=88=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E7=AB=AF=201=E3=80=814=EF=BC=89https://git.shanqu.cc/pm/halo-a?= =?UTF-8?q?pp-issues/-/issues/1750?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gh/common/dialog/CertificationDialog.kt | 11 +++++++-- .../retrofit/service/ApiService.java | 6 +++++ .../fragment/user/ManuallyRealNameFragment.kt | 14 ++++++++++- .../user/ManuallyRealNameViewModel.kt | 24 +++++++++++++++++++ .../fragment/user/RealNameInfoFragment.kt | 4 +++- .../fragment/user/RealNameInfoViewModel.kt | 22 +++++++++-------- .../layout/fragment_manually_real_name.xml | 2 ++ 7 files changed, 69 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/com/gh/common/dialog/CertificationDialog.kt b/app/src/main/java/com/gh/common/dialog/CertificationDialog.kt index c2eb189505..9fbe20eedd 100644 --- a/app/src/main/java/com/gh/common/dialog/CertificationDialog.kt +++ b/app/src/main/java/com/gh/common/dialog/CertificationDialog.kt @@ -129,10 +129,17 @@ class CertificationDialog(context: Context, private val authDialogEntity: AuthDi val currentActivity = AppManager.getInstance().currentActivity() ?: return AvoidOnResultManager.getInstance(currentActivity as AppCompatActivity) - .startForResult(ShellActivity.getIntent(context, ShellActivity.Type.REAL_NAME_INFO, null), object : Callback { + .startForResult( + ShellActivity.getIntent( + context, + ShellActivity.Type.REAL_NAME_INFO, + ).apply { + putExtra(EntranceUtils.KEY_GAME_ID, gameId) + }, object : Callback { override fun onActivityResult(resultCode: Int, data: Intent?) { if (resultCode == Activity.RESULT_OK && data != null) { - val isAuthSuccess = data.getBooleanExtra(UserInfoEditFragment.AUTH_SUCCESS, false) + val isAuthSuccess = + data.getBooleanExtra(UserInfoEditFragment.AUTH_SUCCESS, false) if (isAuthSuccess) { listener.onConfirm() dismiss() diff --git a/app/src/main/java/com/gh/gamecenter/retrofit/service/ApiService.java b/app/src/main/java/com/gh/gamecenter/retrofit/service/ApiService.java index ed0fe37a93..0c31d62b18 100644 --- a/app/src/main/java/com/gh/gamecenter/retrofit/service/ApiService.java +++ b/app/src/main/java/com/gh/gamecenter/retrofit/service/ApiService.java @@ -182,6 +182,12 @@ public interface ApiService { @POST("./certification:review") Single postCertificationReview(@Body RequestBody body); + /** + * 获取是否人工审核中 + */ + @GET("certification/review") + Single getCertificationReview(); + /** * 获取新闻详情 */ diff --git a/app/src/main/java/com/halo/assistant/fragment/user/ManuallyRealNameFragment.kt b/app/src/main/java/com/halo/assistant/fragment/user/ManuallyRealNameFragment.kt index d75ac64ea1..2f70834298 100644 --- a/app/src/main/java/com/halo/assistant/fragment/user/ManuallyRealNameFragment.kt +++ b/app/src/main/java/com/halo/assistant/fragment/user/ManuallyRealNameFragment.kt @@ -32,13 +32,25 @@ class ManuallyRealNameFragment : NormalFragment() { override fun getLayoutId(): Int = 0 override fun getInflatedLayout(): View = mBinding.root + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + mViewModel.getCertificationReview() + } + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) mBinding.toolbar.normalTitle.text = "人工审核" mBinding.toolbar.normalToolbar.setNavigationOnClickListener { requireActivity().finish() } - initView() + + mViewModel.reviewLiveData.observe(viewLifecycleOwner) { + if (it) { + showSuccessView() + } else { + initView() + } + } mViewModel.resultLiveData.observe(viewLifecycleOwner) { if (it) showSuccessView() diff --git a/app/src/main/java/com/halo/assistant/fragment/user/ManuallyRealNameViewModel.kt b/app/src/main/java/com/halo/assistant/fragment/user/ManuallyRealNameViewModel.kt index 95f9f059e7..163ad1a3f0 100644 --- a/app/src/main/java/com/halo/assistant/fragment/user/ManuallyRealNameViewModel.kt +++ b/app/src/main/java/com/halo/assistant/fragment/user/ManuallyRealNameViewModel.kt @@ -6,6 +6,7 @@ import androidx.lifecycle.AndroidViewModel import androidx.lifecycle.MutableLiveData import com.gh.common.util.ErrorHelper import com.gh.common.util.GsonUtils +import com.gh.common.util.tryWithDefaultCatch import com.gh.gamecenter.entity.IdCardEntity import com.gh.gamecenter.entity.UserInfoEntity import com.gh.gamecenter.retrofit.BiResponse @@ -16,6 +17,7 @@ import io.reactivex.schedulers.Schedulers import okhttp3.MediaType import okhttp3.RequestBody import okhttp3.ResponseBody +import org.json.JSONObject import retrofit2.HttpException class ManuallyRealNameViewModel(application: Application) : AndroidViewModel(application) { @@ -23,6 +25,28 @@ class ManuallyRealNameViewModel(application: Application) : AndroidViewModel(app var remoteImageUrl: String ?= null var resultLiveData = MutableLiveData() + var reviewLiveData = MutableLiveData() + + @SuppressLint("CheckResult") + fun getCertificationReview() { + RetrofitManager.getInstance().api.certificationReview + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(object : BiResponse() { + override fun onSuccess(data: ResponseBody) { + tryWithDefaultCatch { + val json = JSONObject(data.string()) + val review = json.getBoolean("review") + reviewLiveData.postValue(review) + } + } + + override fun onFailure(exception: Exception) { + super.onFailure(exception) + reviewLiveData.postValue(false) + } + }) + } @SuppressLint("CheckResult") fun postCertificationReview(idCardEntity: IdCardEntity) { diff --git a/app/src/main/java/com/halo/assistant/fragment/user/RealNameInfoFragment.kt b/app/src/main/java/com/halo/assistant/fragment/user/RealNameInfoFragment.kt index 226be626a9..89c9fde871 100644 --- a/app/src/main/java/com/halo/assistant/fragment/user/RealNameInfoFragment.kt +++ b/app/src/main/java/com/halo/assistant/fragment/user/RealNameInfoFragment.kt @@ -26,6 +26,7 @@ class RealNameInfoFragment : NormalFragment() { private var mIsForcedToCertificate: Boolean = false private val mViewModel: RealNameInfoViewModel by viewModels() private var mProgressDialog: Dialog? = null + private var mGameId = "" // 游戏id,下载游戏->弹窗实名提示->前往实名认证->传递游戏id private val mBinding: FragmentRealNameBinding by lazy { FragmentRealNameBinding.inflate( @@ -44,6 +45,7 @@ class RealNameInfoFragment : NormalFragment() { mHasBackdoor = arguments?.getBoolean(EntranceUtils.KEY_IS_FORCED_TO_CERTIFICATE_BUT_WITH_BACKDOOR) ?: false + mGameId = arguments?.getString(EntranceUtils.KEY_GAME_ID) ?: "" mBinding.toolbar.normalTitle.text = "实名认证" mBinding.toolbar.normalToolbar.setNavigationOnClickListener { requireActivity().finish() } @@ -238,7 +240,7 @@ class RealNameInfoFragment : NormalFragment() { val o = JSONObject() o.put("id", mBinding.idCardEt.text.toString()) o.put("name", mBinding.nameEt.text.toString()) - mViewModel.postCertification(o.toString(), mIsForcedToCertificate) + mViewModel.postCertification(o.toString(), mGameId, mIsForcedToCertificate) mProgressDialog = DialogHelper.getProgressDialog(requireContext(), "提交中") .apply { show() diff --git a/app/src/main/java/com/halo/assistant/fragment/user/RealNameInfoViewModel.kt b/app/src/main/java/com/halo/assistant/fragment/user/RealNameInfoViewModel.kt index 54c49645e2..bd2cf8c365 100644 --- a/app/src/main/java/com/halo/assistant/fragment/user/RealNameInfoViewModel.kt +++ b/app/src/main/java/com/halo/assistant/fragment/user/RealNameInfoViewModel.kt @@ -6,9 +6,9 @@ import android.text.TextUtils import androidx.lifecycle.AndroidViewModel import androidx.lifecycle.MutableLiveData import com.gh.common.constant.Constants +import com.gh.common.json.json import com.gh.common.util.* import com.gh.common.util.GsonUtils.fromJson -import com.gh.common.util.GsonUtils.toJson import com.gh.download.DownloadManager import com.gh.gamecenter.entity.IdCardEntity import com.gh.gamecenter.entity.UserInfoEntity @@ -19,8 +19,6 @@ import com.gh.gamecenter.user.UserRepository import com.halo.assistant.HaloApp import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.schedulers.Schedulers -import okhttp3.MediaType -import okhttp3.RequestBody import okhttp3.ResponseBody import org.json.JSONObject import retrofit2.HttpException @@ -47,14 +45,18 @@ class RealNameInfoViewModel(application: Application) : AndroidViewModel(applica } @SuppressLint("CheckResult") - fun postCertification(content: String, isForced: Boolean) { - val userInfoEntity = UserInfoEntity() + fun postCertification(content: String, gameId: String, isForced: Boolean) { val idCardEntity = fromJson(content, IdCardEntity::class.java) - userInfoEntity.idCard = idCardEntity - val body = RequestBody.create( - MediaType.parse("application/json"), toJson(userInfoEntity) - ) - RetrofitManager.getInstance().api.postCertification(body) + val json = json { + "id_card" to json { + "id" to idCardEntity.id + "name" to idCardEntity.name + } + if (gameId.isNotBlank()) { + "game_id" to gameId + } + } + RetrofitManager.getInstance().api.postCertification(json.toRequestBody()) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(object : BiResponse() { diff --git a/app/src/main/res/layout/fragment_manually_real_name.xml b/app/src/main/res/layout/fragment_manually_real_name.xml index 1e86d9e04e..484cc76b75 100644 --- a/app/src/main/res/layout/fragment_manually_real_name.xml +++ b/app/src/main/res/layout/fragment_manually_real_name.xml @@ -144,6 +144,8 @@ android:orientation="vertical" android:paddingTop="48dp" android:visibility="gone" + android:focusable="true" + android:clickable="true" app:layout_constraintBottom_toBottomOf="@id/submitBtn" app:layout_constraintTop_toTopOf="parent">