Commit 86b7d40d authored by yinjiacheng's avatar yinjiacheng

fix SHQBD-213 SHQBD-175 SHQBD-159 商户管理中心加下拉刷新功能,同步生活号认证状态变化

parent c81f1f49
...@@ -24,14 +24,14 @@ open class YdBaseApplication : Application() { ...@@ -24,14 +24,14 @@ open class YdBaseApplication : Application() {
private fun initSmartRefreshLayout() { private fun initSmartRefreshLayout() {
//设置全局的Header构建器 //设置全局的Header构建器
SmartRefreshLayout.setDefaultRefreshHeaderCreator { context, layout -> SmartRefreshLayout.setDefaultRefreshHeaderCreator { context, layout ->
layout.setPrimaryColorsId(R.color.white)//全局设置主题颜色 layout.setPrimaryColorsId(android.R.color.transparent)//全局设置主题颜色
ClassicsHeader(context) //指定为经典Header,默认是 贝塞尔雷达Header ClassicsHeader(context) //指定为经典Header,默认是 贝塞尔雷达Header
} }
//设置全局的Footer构建器 //设置全局的Footer构建器
SmartRefreshLayout.setDefaultRefreshFooterCreator { context, layout -> SmartRefreshLayout.setDefaultRefreshFooterCreator { context, layout ->
layout.setEnableLoadMoreWhenContentNotFull(true) //内容不满一页时候启用加载更多 layout.setEnableLoadMoreWhenContentNotFull(true) //内容不满一页时候启用加载更多
val footer = ClassicsFooter(context) val footer = ClassicsFooter(context)
footer.setBackgroundResource(R.color.white) footer.setBackgroundResource(android.R.color.transparent)
footer.setDrawableSize(20f) footer.setDrawableSize(20f)
footer.spinnerStyle = SpinnerStyle.FixedBehind //设置为固定在背后模式 footer.spinnerStyle = SpinnerStyle.FixedBehind //设置为固定在背后模式
footer //指定为经典Footer,默认是 BallPulseFooter footer //指定为经典Footer,默认是 BallPulseFooter
......
...@@ -4,6 +4,8 @@ import android.os.Bundle ...@@ -4,6 +4,8 @@ import android.os.Bundle
import android.view.View import android.view.View
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import com.scwang.smart.refresh.layout.api.RefreshLayout
import com.scwang.smart.refresh.layout.listener.OnRefreshListener
import com.yidian.common.XEventConfig import com.yidian.common.XEventConfig
import com.yidian.common.XRouterPathConstants import com.yidian.common.XRouterPathConstants
import com.yidian.common.base.BaseActivity import com.yidian.common.base.BaseActivity
...@@ -41,10 +43,10 @@ import org.greenrobot.eventbus.ThreadMode ...@@ -41,10 +43,10 @@ import org.greenrobot.eventbus.ThreadMode
* description: 商户管理中心 * description: 商户管理中心
*/ */
class MerchantCenterActivity : BaseActivity<ActivityMerchantCenterBinding>(), class MerchantCenterActivity : BaseActivity<ActivityMerchantCenterBinding>(),
IGetConfigListCallback, IGetLifeAccountListCallback, MerchantSwitchDialog.OnMerchantSwitchCallback, IGetConfigListCallback, MerchantSwitchDialog.OnMerchantSwitchCallback,
LifeAccountLabelView.OnLifeAccountLabelCallback, IGetLifeAccountInfoByIdCallback, LifeAccountLabelView.OnLifeAccountLabelCallback, IGetLifeAccountInfoByIdCallback,
MerchantCenterBottomHintDialog.OnMerchantCenterBottomHintCallback, IAuthMerchantCheckCallback, MerchantCenterBottomHintDialog.OnMerchantCenterBottomHintCallback, IAuthMerchantCheckCallback,
MerchantServiceFunctionAdapter.OnItemClickListener, CommonTopBarView.OnCommonTopBarActionCallback { MerchantServiceFunctionAdapter.OnItemClickListener, CommonTopBarView.OnCommonTopBarActionCallback, OnRefreshListener {
companion object { companion object {
// 传递的生活号信息 // 传递的生活号信息
...@@ -61,6 +63,11 @@ class MerchantCenterActivity : BaseActivity<ActivityMerchantCenterBinding>(), ...@@ -61,6 +63,11 @@ class MerchantCenterActivity : BaseActivity<ActivityMerchantCenterBinding>(),
*/ */
private lateinit var curLifeAccount: LifeAccountItemBean.Response private lateinit var curLifeAccount: LifeAccountItemBean.Response
/**
* 当前配置数据
*/
private lateinit var curConfigData: GetConfigListBean.Response
/** /**
* 功能-页面表 * 功能-页面表
*/ */
...@@ -99,27 +106,46 @@ class MerchantCenterActivity : BaseActivity<ActivityMerchantCenterBinding>(), ...@@ -99,27 +106,46 @@ class MerchantCenterActivity : BaseActivity<ActivityMerchantCenterBinding>(),
private fun initListener() { private fun initListener() {
viewBind.lvLifeAccountLabel.setOnLifeAccountLabelCallback(this) viewBind.lvLifeAccountLabel.setOnLifeAccountLabelCallback(this)
// 设置下拉刷新监听
viewBind.rlRefresh.setOnRefreshListener(this)
// 禁用上拉加载更多
viewBind.rlRefresh.setEnableLoadMore(false)
} }
private fun initData() { private fun initData() {
val params = intent.getSerializableExtra(XRouterPathConstants.ParamsKey)?.let { val params = intent.getSerializableExtra(XRouterPathConstants.ParamsKey)?.let { it as HashMap<*, *> }
it as HashMap<*, *> // 切换主体入口是否展示判断
}
// 切换主体入口判断
viewBind.bvTopBar.setActionVisibility(params?.get(EXTRA_IS_MULTI)?.let { it as Boolean } ?: false) viewBind.bvTopBar.setActionVisibility(params?.get(EXTRA_IS_MULTI)?.let { it as Boolean } ?: false)
curLifeAccount = curLifeAccount = params?.get(EXTRA_LIFE_ACCOUNT_INFO)?.let { it as LifeAccountItemBean.Response } ?: return
params?.get(EXTRA_LIFE_ACCOUNT_INFO)?.let { it as LifeAccountItemBean.Response } // 设置标签
?: return
// 设置当前生活号信息
viewBind.lvLifeAccountLabel.setLifeAccountData(curLifeAccount) viewBind.lvLifeAccountLabel.setLifeAccountData(curLifeAccount)
// 展示底部浮窗
showMerchantCenterBottomHint(curLifeAccount)
// 请求功能入口配置清单 // 请求功能入口配置清单
ApiService.getConfigList(this) ApiService.getConfigList(this)
}
/**
* 刷新商户管理中心相关数据
*/
private fun refreshMerchantCenterData(data: LifeAccountItemBean.Response) {
// 设置标签
viewBind.lvLifeAccountLabel.setLifeAccountData(data)
// 展示底部浮窗
showMerchantCenterBottomHint(data)
// 生成当前生活号状态下的功能集
if (this::curConfigData.isInitialized) generateFunctionPermissionMap(curConfigData, data.tag.tag_key)
}
// 判断是否提示认证升级或提示认证驳回 /**
if (curLifeAccount.life_account_type == Constant.TYPE_LIFE_ACCOUNT_PERSONAL * 展示商户管理中心底部浮窗
&& curLifeAccount.life_account_auth_status == Constant.STATUS_AUTH_NOT * 判断是否提示认证升级或提示认证驳回
&& curLifeAccount.enterprise_audit_status == 0 * @param data 当前生活号数据
*/
private fun showMerchantCenterBottomHint(data: LifeAccountItemBean.Response) {
if (data.life_account_type == Constant.TYPE_LIFE_ACCOUNT_PERSONAL
&& data.life_account_auth_status == Constant.STATUS_AUTH_NOT
&& data.enterprise_audit_status == 0
) { ) {
// 当前是个人未认证生活号 提示认证升级 // 当前是个人未认证生活号 提示认证升级
MerchantCenterBottomHintDialog( MerchantCenterBottomHintDialog(
...@@ -127,7 +153,7 @@ class MerchantCenterActivity : BaseActivity<ActivityMerchantCenterBinding>(), ...@@ -127,7 +153,7 @@ class MerchantCenterActivity : BaseActivity<ActivityMerchantCenterBinding>(),
MerchantCenterBottomHintDialog.TYPE_AUTH_UPGRADE, this MerchantCenterBottomHintDialog.TYPE_AUTH_UPGRADE, this
).show() ).show()
} }
if (curLifeAccount.enterprise_audit_status == Constant.STATUS_AUDIT_REJECT) { if (data.enterprise_audit_status == Constant.STATUS_AUDIT_REJECT) {
// 当前企业认证驳回 提示修改 // 当前企业认证驳回 提示修改
MerchantCenterBottomHintDialog( MerchantCenterBottomHintDialog(
this, this,
...@@ -167,6 +193,8 @@ class MerchantCenterActivity : BaseActivity<ActivityMerchantCenterBinding>(), ...@@ -167,6 +193,8 @@ class MerchantCenterActivity : BaseActivity<ActivityMerchantCenterBinding>(),
* todo 优化逻辑 * todo 优化逻辑
*/ */
private fun generateFunctionPermissionMap(data: GetConfigListBean.Response, tagKey: Int) { private fun generateFunctionPermissionMap(data: GetConfigListBean.Response, tagKey: Int) {
if (data.merchant_manager_center.items.isEmpty()) return
functionPermissionList.clear()
when (tagKey) { when (tagKey) {
Constant.LIFE_ACCOUNT_TAG_COMMON_ENTERPRISE_AUTH -> { Constant.LIFE_ACCOUNT_TAG_COMMON_ENTERPRISE_AUTH -> {
// 普通企业认证 // 普通企业认证
...@@ -243,6 +271,7 @@ class MerchantCenterActivity : BaseActivity<ActivityMerchantCenterBinding>(), ...@@ -243,6 +271,7 @@ class MerchantCenterActivity : BaseActivity<ActivityMerchantCenterBinding>(),
override fun getConfigListSuccess(result: GetConfigListBean.Response?) { override fun getConfigListSuccess(result: GetConfigListBean.Response?) {
result?.let { result?.let {
curConfigData = it
generateFunctionPageMap(it) generateFunctionPageMap(it)
generateFunctionPermissionMap(it, curLifeAccount.tag.tag_key) generateFunctionPermissionMap(it, curLifeAccount.tag.tag_key)
filterMerchantServiceData(it) filterMerchantServiceData(it)
...@@ -258,16 +287,6 @@ class MerchantCenterActivity : BaseActivity<ActivityMerchantCenterBinding>(), ...@@ -258,16 +287,6 @@ class MerchantCenterActivity : BaseActivity<ActivityMerchantCenterBinding>(),
} }
override fun getLifeAccountListSuccess(result: ArrayList<LifeAccountItemBean.Response>?) {
// 生活号列表请求成功 弹出切换主体弹窗
result?.let { MerchantSwitchDialog(this, curLifeAccount.life_account_id, it, this).show() }
}
override fun getLifeAccountListFailure(message: String?) {
}
override fun onLifeAccountSelect(data: LifeAccountItemBean.Response) { override fun onLifeAccountSelect(data: LifeAccountItemBean.Response) {
// 用户切换主体 更新当前生活号信息 // 用户切换主体 更新当前生活号信息
curLifeAccount = data curLifeAccount = data
...@@ -423,7 +442,18 @@ class MerchantCenterActivity : BaseActivity<ActivityMerchantCenterBinding>(), ...@@ -423,7 +442,18 @@ class MerchantCenterActivity : BaseActivity<ActivityMerchantCenterBinding>(),
override fun onDoAction() { override fun onDoAction() {
// 切换主体 请求生活号列表接口 // 切换主体 请求生活号列表接口
ApiService.getLifeAccountList(this) ApiService.getLifeAccountList(object : IGetLifeAccountListCallback {
override fun getLifeAccountListSuccess(result: ArrayList<LifeAccountItemBean.Response>?) {
// 生活号列表请求成功 弹出切换主体弹窗
result?.let {
MerchantSwitchDialog(this@MerchantCenterActivity, curLifeAccount.life_account_id, it, this@MerchantCenterActivity).show()
}
}
override fun getLifeAccountListFailure(message: String?) {
}
})
} }
@Subscribe(sticky = false, threadMode = ThreadMode.MAIN) @Subscribe(sticky = false, threadMode = ThreadMode.MAIN)
...@@ -436,4 +466,26 @@ class MerchantCenterActivity : BaseActivity<ActivityMerchantCenterBinding>(), ...@@ -436,4 +466,26 @@ class MerchantCenterActivity : BaseActivity<ActivityMerchantCenterBinding>(),
} }
} }
} }
override fun onRefresh(refreshLayout: RefreshLayout) {
// 刷新数据
ApiService.getLifeAccountList(object : IGetLifeAccountListCallback {
override fun getLifeAccountListSuccess(result: ArrayList<LifeAccountItemBean.Response>?) {
// 刷新成功
refreshLayout.finishRefresh(true)
result?.forEach {
if (curLifeAccount.life_account_id == it.life_account_id) {
curLifeAccount = it
// 刷新数据
refreshMerchantCenterData(it)
}
}
}
override fun getLifeAccountListFailure(message: String?) {
// 刷新失败
refreshLayout.finishRefresh(false)
}
})
}
} }
...@@ -14,12 +14,23 @@ ...@@ -14,12 +14,23 @@
app:CommonTopBarView_title_text="@string/management_center" app:CommonTopBarView_title_text="@string/management_center"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<com.scwang.smart.refresh.layout.SmartRefreshLayout
android:id="@+id/rl_refresh"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/bv_top_bar">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.yidian.shenghuoquan.newscontent.widget.LifeAccountLabelView <com.yidian.shenghuoquan.newscontent.widget.LifeAccountLabelView
android:id="@+id/lv_life_account_label" android:id="@+id/lv_life_account_label"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/bv_top_bar" /> app:layout_constraintTop_toTopOf="parent" />
<com.yidian.shenghuoquan.newscontent.widget.MerchantAssetView <com.yidian.shenghuoquan.newscontent.widget.MerchantAssetView
android:id="@+id/av_merchant_asset" android:id="@+id/av_merchant_asset"
...@@ -40,4 +51,8 @@ ...@@ -40,4 +51,8 @@
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/av_merchant_asset" /> app:layout_constraintTop_toBottomOf="@id/av_merchant_asset" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.scwang.smart.refresh.layout.SmartRefreshLayout>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment