Commit d9b511e1 authored by yinjiacheng's avatar yinjiacheng

update 用户登录后和app启动流程

parent a20795e8
......@@ -6,8 +6,7 @@ import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.yidian.common.cardutils.adapter.OnItemClickListener
import com.yidian.shenghuoquan.newscontent.R
import com.yidian.shenghuoquan.newscontent.bean.LifeAccountIdentityBean
import com.yidian.shenghuoquan.newscontent.http.httpbean.AccountItemBean
import com.yidian.shenghuoquan.newscontent.http.httpbean.LifeAccountItemBean
import kotlinx.android.synthetic.main.item_life_account_identity.view.*
/**
......@@ -18,8 +17,8 @@ import kotlinx.android.synthetic.main.item_life_account_identity.view.*
class LifeAccountIdentityAdapter :
RecyclerView.Adapter<LifeAccountIdentityAdapter.LifeAccountIdentityViewHolder>() {
private val mData: ArrayList<AccountItemBean.Response> by lazy { ArrayList<AccountItemBean.Response>() }
private lateinit var mListener: OnItemClickListener<AccountItemBean.Response>
private val mData: ArrayList<LifeAccountItemBean.Response> by lazy { ArrayList() }
private lateinit var mListener: OnItemClickListener<LifeAccountItemBean.Response>
private var mLastSelectItem: View? = null
override fun onCreateViewHolder(
......@@ -35,9 +34,9 @@ class LifeAccountIdentityAdapter :
override fun onBindViewHolder(holder: LifeAccountIdentityViewHolder, position: Int) {
val data = mData[position]
holder.itemView.tv_life_account.text = data.life_account_name
if(data.role_type == 1){
if (data.role_type == 1) {
holder.itemView.tv_life_identity.text = "超级管理员"
}else{
} else {
holder.itemView.tv_life_identity.text = "普通管理员"
}
......@@ -56,15 +55,15 @@ class LifeAccountIdentityAdapter :
/**
* 更新数据
*/
fun updateData(data: List<AccountItemBean.Response>) {
data.let {
fun updateData(data: List<LifeAccountItemBean.Response>?) {
data?.let {
mData.clear()
mData.addAll(it)
notifyDataSetChanged()
}
}
fun setOnItemClickListener(listener: OnItemClickListener<AccountItemBean.Response>) {
fun setOnItemClickListener(listener: OnItemClickListener<LifeAccountItemBean.Response>) {
mListener = listener
}
......
......@@ -71,20 +71,20 @@ class ApiService {
})
}
// 获取生活号列表
fun getAccountList(apiCallback: IMobileLoginCallback) {
// 106 获取生活号列表接口
fun getLifeAccountList(apiCallback: IGetLifeAccountListCallback) {
val timeStamp = System.currentTimeMillis()
val publicParamsMap = HttpParamsUtils.getPublicParamsMap(timeStamp)
ServiceFactory.getInstance().createService(CommonService::class.java)
.getAccountList(publicParamsMap)
.compose(TransformUtil.defaultSchedulers())
.subscribe(object : HttpResultSubscriber<ArrayList<AccountItemBean>?>() {
override fun onSuccess(result: HttpResult<ArrayList<AccountItemBean>?>?) {
apiCallback.getAccountListCallBack(result)
.subscribe(object : HttpResultSubscriber<ArrayList<LifeAccountItemBean.Response>?>() {
override fun onSuccess(result: HttpResult<ArrayList<LifeAccountItemBean.Response>?>?) {
apiCallback.getLifeAccountListSuccess(result?.result)
}
override fun onFailer(result: HttpResult<ArrayList<AccountItemBean>?>?) {
override fun onFailer(result: HttpResult<ArrayList<LifeAccountItemBean.Response>?>?) {
apiCallback.getLifeAccountListFailure(result?.reason)
}
})
}
......
package com.yidian.shenghuoquan.newscontent.http.callback
import com.yidian.shenghuoquan.newscontent.http.httpbean.LifeAccountItemBean
/**
* author: yinjiacheng
* date: 6/12/21 1:24 AM
* description: API /merchant/auth/account_list
*/
interface IGetLifeAccountListCallback {
fun getLifeAccountListSuccess(result: ArrayList<LifeAccountItemBean.Response>?)
fun getLifeAccountListFailure(message: String?)
}
\ No newline at end of file
......@@ -5,5 +5,4 @@ import com.yidian.common.http.HttpResult
interface IMobileLoginCallback {
fun sendSmsCodeCallBack(t: HttpResult<Any?>?)
fun mobileLoginCallBack(t: HttpResult<MobileLoginBean.Response?>?)
fun getAccountListCallBack(t: HttpResult<ArrayList<AccountItemBean>?>?)
}
\ No newline at end of file
package com.yidian.shenghuoquan.newscontent.http.httpbean
class AccountItemBean(var response: Response) {
import java.io.Serializable
class LifeAccountItemBean(var response: Response) {
data class Response(
var create_time: String?,
var enterprise_audit_status: Int?,
......@@ -10,5 +12,5 @@ class AccountItemBean(var response: Response) {
var life_account_status: Int?,
var life_account_type: Int?,
var role_type: Int?
)
) : Serializable
}
\ No newline at end of file
package com.yidian.shenghuoquan.newscontent.ui
import android.Manifest
import android.content.Intent
import android.os.Bundle
import com.orhanobut.hawk.Hawk
import com.tbruyelle.rxpermissions3.RxPermissions
......@@ -11,10 +10,15 @@ import com.yidian.common.XRouterPathConstants.Companion.FLASH
import com.yidian.common.base.BaseActivity
import com.yidian.shenghuoquan.newscontent.R
import com.yidian.shenghuoquan.newscontent.databinding.ActivityFlashBinding
import com.yidian.shenghuoquan.newscontent.http.ApiService
import com.yidian.shenghuoquan.newscontent.http.callback.IGetLifeAccountListCallback
import com.yidian.shenghuoquan.newscontent.http.httpbean.LifeAccountItemBean
import com.yidian.shenghuoquan.newscontent.ui.auth.LifeAccountIdentityActivity
import com.yidian.shenghuoquan.newscontent.ui.center.MerchantCenterActivity
import com.yidian.utils.ToastUtil
import com.yidian.xpage.XPageManager
class FlashActivity: BaseActivity<ActivityFlashBinding>() {
class FlashActivity : BaseActivity<ActivityFlashBinding>(), IGetLifeAccountListCallback {
override fun createViewBinding(): ActivityFlashBinding {
return ActivityFlashBinding.inflate(layoutInflater)
......@@ -30,48 +34,65 @@ class FlashActivity: BaseActivity<ActivityFlashBinding>() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
viewBind.clRoot.postDelayed({
XPageManager.push(XRouterPathConstants.LOGIN_LIFE_CIRCLE, null)
finish()
}, 2000)
getPermissions()
}
override fun onPostCreate(savedInstanceState: Bundle?) {
super.onPostCreate(savedInstanceState)
// launcher()
}
private fun launcher(){
val isAgree = Hawk.get<Boolean>(HawkConfig.ProtocolIsAgree, false)
if(isAgree){
private fun launcher() {
val isAgree = Hawk.get(HawkConfig.ProtocolIsAgree, true)
if (isAgree) {
val loginStatus = Hawk.get(HawkConfig.LoginStatus, false)
if(loginStatus){
//跳转管理页
}else{
viewBind.clRoot.postDelayed({
XPageManager.push(XRouterPathConstants.LOGIN_LIFE_CIRCLE, null)
finish()
}, 2000)
if (loginStatus) {
// 已登录 请求生活号列表
ApiService.getLifeAccountList(this)
} else {
// 未登录 跳转登录
XPageManager.push(XRouterPathConstants.LOGIN_LIFE_CIRCLE, null)
finish()
}
}else{
//调起协议dialog
} else {
// TODO: 6/12/21 协议dialog
}
}
private fun getPermissions() {
val rxPermissions = RxPermissions(this)
rxPermissions.request(
RxPermissions(this).request(
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.CAMERA
)
.subscribe {
if (it) {
XPageManager.push(XRouterPathConstants.LOGIN_LIFE_CIRCLE, null)
// startActivity(Intent(this@FlashActivity, TempListActivity::class.java))
finish()
launcher()
} else {
ToastUtil.showToast(this, "请在设置里同意读取存储卡权限")
ToastUtil.showToast(this, "请在设置里同意相关权限")
}
}
}
}
\ No newline at end of file
override fun getLifeAccountListSuccess(result: ArrayList<LifeAccountItemBean.Response>?) {
when (result?.size) {
0 -> {
// 无生活号 进入认证流程
XPageManager.push(XRouterPathConstants.LIFE_ACCOUNT_AUTH, null)
}
1 -> {
// 关联一个生活号 进入商户管理中心
XPageManager.push(
XRouterPathConstants.MERCHANT_CENTER,
hashMapOf(Pair(MerchantCenterActivity.EXTRA_LIFE_ACCOUNT_INFO, result[0]))
)
}
else -> {
// 关联多个生活号 进入身份选择
XPageManager.push(
XRouterPathConstants.LIFE_ACCOUNT_IDENTITY,
hashMapOf(Pair(LifeAccountIdentityActivity.EXTRA_LIFE_ACCOUNT_LIST, result))
)
}
}
finish()
}
override fun getLifeAccountListFailure(message: String?) {
}
}
package com.yidian.shenghuoquan.newscontent.ui
import android.os.Bundle
import android.view.View
import com.orhanobut.hawk.Hawk
import com.yidian.common.HawkConfig
import com.yidian.common.XRouterPathConstants
......@@ -12,10 +11,12 @@ import com.yidian.common.widget.EditTextInputCallback
import com.yidian.common.widget.PhoneNumberTextWatcher
import com.yidian.shenghuoquan.newscontent.databinding.ActivityLoginBinding
import com.yidian.shenghuoquan.newscontent.http.ApiService
import com.yidian.shenghuoquan.newscontent.http.httpbean.AccountItemBean
import com.yidian.shenghuoquan.newscontent.http.callback.IGetLifeAccountListCallback
import com.yidian.shenghuoquan.newscontent.http.httpbean.IMobileLoginCallback
import com.yidian.shenghuoquan.newscontent.http.httpbean.LifeAccountItemBean
import com.yidian.shenghuoquan.newscontent.http.httpbean.MobileLoginBean
import com.yidian.shenghuoquan.newscontent.personnel.bean.AccountAdmin
import com.yidian.shenghuoquan.newscontent.ui.auth.LifeAccountIdentityActivity
import com.yidian.shenghuoquan.newscontent.ui.center.MerchantCenterActivity
import com.yidian.shenghuoquan.newscontent.utils.CountDownTimerUtils
import com.yidian.shenghuoquan.newscontent.utils.TextWatcherAdapter
import com.yidian.utils.ToastUtil
......@@ -26,7 +27,8 @@ import com.yidian.xpage.XPageManager
* Date: 2021/5/26 16:05 PM
* Describe:短信登陆页面
*/
class LoginLifeCircleActivity : BaseActivity<ActivityLoginBinding>() {
class LoginLifeCircleActivity : BaseActivity<ActivityLoginBinding>(), IGetLifeAccountListCallback,
IMobileLoginCallback {
private lateinit var mCountDownTimerUtils: CountDownTimerUtils
private var mobileFinish = false
private var codeFinish = false
......@@ -58,7 +60,7 @@ class LoginLifeCircleActivity : BaseActivity<ActivityLoginBinding>() {
if (mobile.length == 11) {
val paramsMap = HashMap<String, String?>()
paramsMap["mobile"] = mobile
ApiService.sendMsgCode(loginImpl, paramsMap)
ApiService.sendMsgCode(this, paramsMap)
} else {
ToastUtil.showToast(this, "请输入11位手机号")
}
......@@ -94,7 +96,7 @@ class LoginLifeCircleActivity : BaseActivity<ActivityLoginBinding>() {
val paramsMap = HashMap<String, String?>()
paramsMap["mobile"] = mobile
paramsMap["code"] = code
ApiService.mobileLogin(loginImpl, paramsMap)
ApiService.mobileLogin(this, paramsMap)
}
viewBind.cbProtocol.setOnCheckedChangeListener { buttonView, isChecked ->
......@@ -108,7 +110,6 @@ class LoginLifeCircleActivity : BaseActivity<ActivityLoginBinding>() {
viewBind.tvPrivacy.setOnClickListener {
ToastUtil.showToast(this, "隐私政策")
XPageManager.push(XRouterPathConstants.LIFE_ACCOUNT_IDENTITY, null)
}
}
......@@ -130,59 +131,53 @@ class LoginLifeCircleActivity : BaseActivity<ActivityLoginBinding>() {
}
}
private fun getAccountList() {
ApiService.getAccountList(loginImpl)
override fun onDestroy() {
super.onDestroy()
mCountDownTimerUtils.cancel()
}
private val loginImpl = object : IMobileLoginCallback {
override fun sendSmsCodeCallBack(t: HttpResult<Any?>?) {
if (t?.code == 0) {
mCountDownTimerUtils.start()
override fun getLifeAccountListSuccess(result: ArrayList<LifeAccountItemBean.Response>?) {
when (result?.size) {
0 -> {
// 无生活号 进入认证流程
XPageManager.push(XRouterPathConstants.LIFE_ACCOUNT_AUTH, null)
}
1 -> {
// 关联一个生活号 进入商户管理中心
XPageManager.push(
XRouterPathConstants.MERCHANT_CENTER,
hashMapOf(Pair(MerchantCenterActivity.EXTRA_LIFE_ACCOUNT_INFO, result[0]))
)
}
else -> {
// 关联多个生活号 进入身份选择
XPageManager.push(
XRouterPathConstants.LIFE_ACCOUNT_IDENTITY,
hashMapOf(Pair(LifeAccountIdentityActivity.EXTRA_LIFE_ACCOUNT_LIST, result))
)
}
}
finish()
}
override fun mobileLoginCallBack(t: HttpResult<MobileLoginBean.Response?>?) {
val loginResponse = t?.result
Hawk.put(HawkConfig.LoginStatus, true)
Hawk.put(HawkConfig.UserId, loginResponse?.user_id)
Hawk.put(HawkConfig.Mobile, loginResponse?.mobile)
Hawk.put(HawkConfig.Nickname, loginResponse?.nick_name)
Hawk.put(HawkConfig.Avatar, loginResponse?.avatar)
getAccountList()
}
override fun getLifeAccountListFailure(message: String?) {
override fun getAccountListCallBack(t: HttpResult<ArrayList<AccountItemBean>?>?) {
val accountList = t?.result
if (accountList != null) {
when (accountList.size) {
0 -> {//没有身份
XPageManager.push(XRouterPathConstants.LIFE_ACCOUNT_AUTH, null)
}
1 -> {//一个身份
val paramsMap = HashMap<String, Any?>()
paramsMap["accountList"] = accountList
}
else -> {//多个身份
val paramsMap = HashMap<String, Any?>()
paramsMap["accountList"] = accountList
XPageManager.push(XRouterPathConstants.LIFE_ACCOUNT_IDENTITY, paramsMap)
}
}
}
}
}
override fun onDestroy() {
super.onDestroy()
mCountDownTimerUtils.cancel()
override fun sendSmsCodeCallBack(t: HttpResult<Any?>?) {
if (t?.code == 0) {
mCountDownTimerUtils.start()
}
}
// todo 测试人员管理的入口,后续删除
fun testPersonalManagement(view: View) {
// XPageManager.push(XRouterPathConstants.PERSONAL_MY_STAFF, null)
val hashMap = HashMap<String, Any?>()
hashMap["managerInfo"] = AccountAdmin(nickName = "电视机厂你的烦恼", mobile = "19936635225", roleList = mutableListOf("胸大", "熊二"))
XPageManager.push(XRouterPathConstants.PERSONAL_MANAGER_INFO, hashMap)
override fun mobileLoginCallBack(t: HttpResult<MobileLoginBean.Response?>?) {
val loginResponse = t?.result
Hawk.put(HawkConfig.LoginStatus, true)
Hawk.put(HawkConfig.UserId, loginResponse?.user_id)
Hawk.put(HawkConfig.Mobile, loginResponse?.mobile)
Hawk.put(HawkConfig.Nickname, loginResponse?.nick_name)
Hawk.put(HawkConfig.Avatar, loginResponse?.avatar)
ApiService.getLifeAccountList(this)
}
}
......@@ -4,14 +4,13 @@ import android.os.Bundle
import android.view.View
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.yidian.common.XRouterPathConstants
import com.yidian.common.base.BaseActivity
import com.yidian.common.cardutils.adapter.OnItemClickListener
import com.yidian.shenghuoquan.newscontent.adapter.LifeAccountIdentityAdapter
import com.yidian.shenghuoquan.newscontent.databinding.ActivityLifeAccountIdentityBinding
import com.yidian.shenghuoquan.newscontent.http.httpbean.AccountItemBean
import com.yidian.shenghuoquan.newscontent.http.httpbean.LifeAccountItemBean
import com.yidian.shenghuoquan.newscontent.ui.center.MerchantCenterActivity
import com.yidian.xpage.XPageManager
/**
......@@ -19,10 +18,21 @@ import com.yidian.xpage.XPageManager
* date: 5/19/21 4:47 PM
* description: 生活号身份选择
*/
class LifeAccountIdentityActivity : BaseActivity<ActivityLifeAccountIdentityBinding>(), OnItemClickListener<AccountItemBean.Response> {
private var accountMap: HashMap<String, Any?>? = null
class LifeAccountIdentityActivity : BaseActivity<ActivityLifeAccountIdentityBinding>(),
OnItemClickListener<LifeAccountItemBean.Response> {
private var lastSelectedIndex = -1
/**
* 当前选择的生活号
*/
private lateinit var curSelectedItem: LifeAccountItemBean.Response
companion object {
// 传递的生活号列表
const val EXTRA_LIFE_ACCOUNT_LIST = "lifeAccountList"
}
override fun createViewBinding(): ActivityLifeAccountIdentityBinding {
return ActivityLifeAccountIdentityBinding.inflate(layoutInflater)
}
......@@ -42,52 +52,49 @@ class LifeAccountIdentityActivity : BaseActivity<ActivityLifeAccountIdentityBind
viewBind.rvLifeAccountIdentity.layoutManager =
LinearLayoutManager(this, RecyclerView.VERTICAL, false)
viewBind.rvLifeAccountIdentity.adapter = LifeAccountIdentityAdapter()
(viewBind.rvLifeAccountIdentity.adapter as LifeAccountIdentityAdapter).setOnItemClickListener(this)
(viewBind.rvLifeAccountIdentity.adapter as LifeAccountIdentityAdapter).setOnItemClickListener(
this
)
setLoginButtonStatus(false)
}
private fun initData() {
val paramsMap = intent?.getSerializableExtra(XRouterPathConstants.ParamsKey)
if (paramsMap != null) {
paramsMap as HashMap<String, Any?>
val accountList = paramsMap["accountList"] as List<AccountItemBean.Response>
val data: List<AccountItemBean.Response> =
listOf(
AccountItemBean.Response(null, 20, 2, 666, "一点资讯生活圈", 1, 2, 1),
AccountItemBean.Response(null, 10, 1, 777, "简网科技生活号", 2, 1, 2),
AccountItemBean.Response(null, 20, 2, 888, "一点资讯生活圈", 1, 2, 2),
AccountItemBean.Response(null, 10, 1, 999, "简网科技生活号", 2, 1, 2)
)
(viewBind.rvLifeAccountIdentity.adapter as LifeAccountIdentityAdapter).updateData(data)
val data = intent.getSerializableExtra(XRouterPathConstants.ParamsKey)?.let { params ->
(params as HashMap<*, *>)[EXTRA_LIFE_ACCOUNT_LIST]?.let {
it as List<LifeAccountItemBean.Response>
}
}
(viewBind.rvLifeAccountIdentity.adapter as LifeAccountIdentityAdapter).updateData(data)
}
private fun onClickListener(){
private fun onClickListener() {
viewBind.back.setOnClickListener {
XPageManager.pop(null)
}
viewBind.tvEnterLifeAccount.setOnClickListener {
if(accountMap != null){
// XPageManager.push(XRouterPathConstants.NEWS_CONTENT, accountMap)
}
// 进入商户管理中心页
XPageManager.push(
XRouterPathConstants.MERCHANT_CENTER,
hashMapOf(Pair(MerchantCenterActivity.EXTRA_LIFE_ACCOUNT_INFO, curSelectedItem))
)
finish()
}
}
override fun onClick(view: View?, position: Int, item: AccountItemBean.Response?) {
if(position != lastSelectedIndex){
override fun onClick(view: View?, position: Int, item: LifeAccountItemBean.Response?) {
if (item == null) return
if (position != lastSelectedIndex) {
setLoginButtonStatus(true)
val itemJson = Gson().toJson(item)
accountMap = Gson().fromJson<HashMap<String, Any?>>(itemJson, object: TypeToken<HashMap<String, Any?>>(){}.type)
curSelectedItem = item
lastSelectedIndex = position
}
}
private fun setLoginButtonStatus(flag: Boolean){
if(flag){
private fun setLoginButtonStatus(flag: Boolean) {
if (flag) {
viewBind.tvEnterLifeAccount.alpha = 1.0f
viewBind.tvEnterLifeAccount.isEnabled = true
}else{
} else {
viewBind.tvEnterLifeAccount.alpha = 0.32f
viewBind.tvEnterLifeAccount.isEnabled = false
}
......
......@@ -18,6 +18,12 @@ import com.yidian.shenghuoquan.newscontent.widget.LifeAccountLabelView
* description: 商户管理中心
*/
class MerchantCenterActivity : BaseActivity<ActivityMerchantCenterBinding>() {
companion object {
// 传递的生活号信息
const val EXTRA_LIFE_ACCOUNT_INFO = "lifeAccountInfo"
}
override fun createViewBinding(): ActivityMerchantCenterBinding {
return ActivityMerchantCenterBinding.inflate(layoutInflater)
}
......
......@@ -8,7 +8,7 @@ import com.yidian.common.base.BaseActivity
import com.yidian.shenghuoquan.newscontent.R
import com.yidian.shenghuoquan.newscontent.constant.Constant
import com.yidian.shenghuoquan.newscontent.databinding.ActivityMerchantInfoBinding
import com.yidian.shenghuoquan.newscontent.http.httpbean.AccountItemBean
import com.yidian.shenghuoquan.newscontent.http.httpbean.LifeAccountItemBean
import com.yidian.shenghuoquan.newscontent.widget.MerchantInfoView
/**
......@@ -50,7 +50,7 @@ class MerchantInfoActivity : BaseActivity<ActivityMerchantInfoBinding>(), View.O
val lifeAccountInfo =
intent.getSerializableExtra(XRouterPathConstants.ParamsKey)?.let { params ->
(params as HashMap<*, *>)[EXTRA_LIFE_ACCOUNT_INFO]?.let {
it as AccountItemBean.Response
it as LifeAccountItemBean.Response
}
}
// 生活号名称
......
......@@ -158,13 +158,4 @@
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="30dp"
android:text="测试人员管理"
android:onClick="testPersonalManagement"
android:textColor="@color/black"
android:textSize="18sp" />
</LinearLayout>
\ 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