餐盘柜优化-绑定临时用户

This commit is contained in:
mazengfei
2026-01-16 16:14:38 +08:00
parent 8337b3fabb
commit cf2d2db42f
10 changed files with 267 additions and 176 deletions
@@ -127,14 +127,14 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
item.plateNumber = plateNumber
item.faceId = null
item.updateTime = null
PlateUtils.open(this, item.equipmentBoxCode)
PlateUtils.open(this, item.equipmentBoxCode, true)
return
}
//放入餐盘,清除已有id和时间
item.plateNumber = plateNumber
item.faceId = null
item.updateTime = null
PlateUtils.open(this, item.equipmentBoxCode)
PlateUtils.open(this, item.equipmentBoxCode, true)
SpTool.savePlateData(MyApp.plateList!!)
}
@@ -266,22 +266,25 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
/**
* 显示等待提示框
*/
fun showWaitingDialog(tip: String?): Dialog? {
hideWaitingDialog()
val view = View.inflate(this, R.layout.dialog_waiting, null)
if (!TextUtils.isEmpty(tip)) (view.findViewById<View?>(R.id.tvTip) as TextView).setText(tip)
mDialogWaiting = CustomLoadingDialog(this, view, R.style.MyDialog)
mDialogWaiting!!.show()
mDialogWaiting!!.setCancelable(true)
return mDialogWaiting
fun showWaitingDialog(tip: String?) {
runOnUiThread {
hideWaitingDialog()
val view = View.inflate(this, R.layout.dialog_waiting, null)
if (!TextUtils.isEmpty(tip)) (view.findViewById<View?>(R.id.tvTip) as TextView).setText(tip)
mDialogWaiting = CustomLoadingDialog(this, view, R.style.MyDialog)
mDialogWaiting!!.show()
mDialogWaiting!!.setCancelable(true)
}
}
/**
* 隐藏等待提示框
*/
fun hideWaitingDialog() {
mDialogWaiting?.dismiss()
mDialogWaiting = null
runOnUiThread {
mDialogWaiting?.dismiss()
mDialogWaiting = null
}
}
protected abstract fun inflateViewBinding(): VB
@@ -295,40 +298,40 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
*/
protected open fun registerDataChange() {
Timber.d("registerDataChange")
lifecycleScope.launch {
viewModel.showLoading.collect {
Timber.d("registerDataChange 用户 showLoading = $it")
if (it) {
showWaitingDialog("")
} else {
hideWaitingDialog()
}
}
}
lifecycleScope.launch {
viewModel.currentUserInfo.collect {
if (it == null) return@collect
// it.showBalanceNotEnoughDialog = true
handleLoginSuccess(it, false)
}
}
lifecycleScope.launch {
settingViewModel.showLoading.collect {
Timber.d("registerDataChange 管理员 showLoading = $it")
if (it) {
showWaitingDialog("")
} else {
hideWaitingDialog()
}
}
}
lifecycleScope.launch {
settingViewModel.searchUserInfo.collect {
Timber.d("registerDataChange 管理员 currentUserInfo = $it")
if (it == null) return@collect
handleLoginSuccess(it, true)
}
}
// lifecycleScope.launch {
// viewModel.showLoading.collect {
// Timber.d("registerDataChange 用户 showLoading = $it")
// if (it) {
// showWaitingDialog("")
// } else {
// hideWaitingDialog()
// }
// }
// }
// lifecycleScope.launch {
// viewModel.currentUserInfo.collect {
// if (it == null) return@collect
//// it.showBalanceNotEnoughDialog = true
// handleLoginSuccess(it, false)
// }
// }
// lifecycleScope.launch {
// settingViewModel.showLoading.collect {
// Timber.d("registerDataChange 管理员 showLoading = $it")
// if (it) {
// showWaitingDialog("")
// } else {
// hideWaitingDialog()
// }
// }
// }
// lifecycleScope.launch {
// settingViewModel.searchUserInfo.collect {
// Timber.d("registerDataChange 管理员 currentUserInfo = $it")
// if (it == null) return@collect
// handleLoginSuccess(it, true)
// }
// }
// lifecycleScope.launch {
// settingViewModel.equipmentList.collect {
// loadEquipmentList(it)
@@ -336,22 +339,22 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
// }
}
private fun loadEquipmentList(items: List<EquipmentUserInfo>) {
if (items.isEmpty()) return
val unbindList = items.filter { !it.isBound() }
if (unbindList.isEmpty()) {
MainActivity.start(context = context, pageType = PageType.PLATE_CABINET_FULL)
} else {
val firstInfo = unbindList[0]
val currentUserInfo = settingViewModel.searchUserInfo.value
firstInfo.plateNumber = currentUserInfo?.plateNumber ?: ""
MainActivity.start(
context = context,
pageType = PageType.BIND_PLATE,
equipmentUserInfo = firstInfo
)
}
}
// private fun loadEquipmentList(items: List<EquipmentUserInfo>) {
// if (items.isEmpty()) return
// val unbindList = items.filter { !it.isBound() }
// if (unbindList.isEmpty()) {
// MainActivity.start(context = context, pageType = PageType.PLATE_CABINET_FULL)
// } else {
// val firstInfo = unbindList[0]
// val currentUserInfo = settingViewModel.searchUserInfo.value
// firstInfo.plateNumber = currentUserInfo?.plateNumber ?: ""
// MainActivity.start(
// context = context,
// pageType = PageType.BIND_PLATE,
// equipmentUserInfo = firstInfo
// )
// }
// }
/**
* 处理登录成功操作