【光环助手V5.8.0】实名认证优化第五期(客户端 1、4)https://git.shanqu.cc/pm/halo-app-issues/-/issues/1750

This commit is contained in:
lyr
2022-03-17 11:59:39 +08:00
parent c8278f6364
commit 05abf00994
7 changed files with 69 additions and 14 deletions

View File

@ -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()

View File

@ -182,6 +182,12 @@ public interface ApiService {
@POST("./certification:review")
Single<ResponseBody> postCertificationReview(@Body RequestBody body);
/**
* 获取是否人工审核中
*/
@GET("certification/review")
Single<ResponseBody> getCertificationReview();
/**
* 获取新闻详情
*/

View File

@ -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()

View File

@ -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<Boolean>()
var reviewLiveData = MutableLiveData<Boolean>()
@SuppressLint("CheckResult")
fun getCertificationReview() {
RetrofitManager.getInstance().api.certificationReview
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : BiResponse<ResponseBody>() {
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) {

View File

@ -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()

View File

@ -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<ResponseBody?>() {

View File

@ -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">