调整了餐盘在不同设备提示
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.sw.platecabinet.viewmodel
|
||||
|
||||
import com.sw.inbound.utils.DateTimeUtils
|
||||
import com.sw.plate.utils.ToastUtils
|
||||
import com.sw.platecabinet.GlobalData
|
||||
import com.sw.platecabinet.GlobalData.globalEquipmentCode
|
||||
@@ -43,7 +44,7 @@ class SettingViewModel : BaseViewModel() {
|
||||
EquipmentParam(appVersion = GlobalData.appVersion, equipmentCode = equipmentCode)
|
||||
val response = repository.getEquipmentList(param)
|
||||
if (parseResponse(response)) {
|
||||
_equipmentList.value = response.data?.plus(response.data) ?: emptyList()
|
||||
_equipmentList.value = response.data ?: emptyList()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -94,6 +95,13 @@ class SettingViewModel : BaseViewModel() {
|
||||
)
|
||||
val response = repository.bindEquipment(bindParam)
|
||||
if (parseResponse(response)) {
|
||||
val userInfo = response.data
|
||||
userInfo?.let {
|
||||
if (it.isOtherEquipment()) {
|
||||
ToastUtils.showToast("餐盘已在${it.equipmentName}绑定")
|
||||
return@launchWithLoading
|
||||
}
|
||||
}
|
||||
_bindStateChange.value = true to ErrorInfo()
|
||||
} else {
|
||||
_bindStateChange.value = true to ErrorInfo(response.code, response.msg.toString())
|
||||
@@ -132,15 +140,20 @@ class SettingViewModel : BaseViewModel() {
|
||||
)
|
||||
val response = repository.findByPlateNumber(bindParam)
|
||||
if (response.code == 200) {
|
||||
if (response.data?.isOtherEquipment() == true) {
|
||||
ToastUtils.showToast("")
|
||||
return@launchWithLoading
|
||||
val userInfo = response.data
|
||||
userInfo?.let {
|
||||
if (it.isOtherEquipment()) {
|
||||
ToastUtils.showToast("餐盘已在${it.equipmentName}绑定")
|
||||
return@launchWithLoading
|
||||
}
|
||||
}
|
||||
|
||||
_currentUserInfo.value = response.data
|
||||
} else {
|
||||
_currentUserInfo.value = EquipmentUserInfo(
|
||||
plateNumber = plateNumber,
|
||||
equipmentCode = equipmentCode
|
||||
equipmentCode = equipmentCode,
|
||||
updateTime = DateTimeUtils.getDateTimeString()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.sw.platecabinet.GlobalKey
|
||||
import com.sw.platecabinet.model.request.LoginParam
|
||||
import com.sw.platecabinet.model.response.EquipmentUserInfo
|
||||
import com.sw.platecabinet.model.response.UserFaceModel
|
||||
import com.sw.platecabinet.utils.ThreadUtils
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import timber.log.Timber
|
||||
@@ -63,7 +64,8 @@ class UserViewModel : BaseViewModel() {
|
||||
/**
|
||||
* 激活人脸识别引擎
|
||||
*/
|
||||
private fun activeEngine() {
|
||||
fun activeEngine() {
|
||||
Timber.d("activeEngine")
|
||||
var appId = "Hkz1rBk6PZXbS8KwKr67K2eZtsz8bRoMHLg64bUdgCZj"
|
||||
var sdkKey = "AabXs3sHM8UhhE7oCGf4LVMLrdkGb1nJNksbjjTdVt7k"
|
||||
var activeKey = "085F-118G-Q391-53YL"
|
||||
@@ -75,23 +77,27 @@ class UserViewModel : BaseViewModel() {
|
||||
object : FaceApi.ActiveCallback {
|
||||
override fun onSuccess(activeCode: Int) {
|
||||
Timber.d("activeEngine activeCode = $activeCode")
|
||||
when (activeCode) {
|
||||
ErrorInfo.MOK -> {
|
||||
ToastUtils.showToast("激活引擎成功")
|
||||
}
|
||||
ThreadUtils.launch {
|
||||
when (activeCode) {
|
||||
ErrorInfo.MOK -> {
|
||||
ToastUtils.showToast("激活引擎成功")
|
||||
}
|
||||
|
||||
ErrorInfo.MERR_ASF_ALREADY_ACTIVATED -> {
|
||||
ToastUtils.showToast("引擎已激活,无需再次激活")
|
||||
}
|
||||
ErrorInfo.MERR_ASF_ALREADY_ACTIVATED -> {
|
||||
// ToastUtils.showToast("引擎已激活,无需再次激活")
|
||||
}
|
||||
|
||||
else -> {
|
||||
ToastUtils.showToast("激活引擎失败($activeCode)")
|
||||
else -> {
|
||||
ToastUtils.showToast("激活引擎失败($activeCode)")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFail(e: Exception?) {
|
||||
ToastUtils.showToast("激活引擎异常,${e?.message}")
|
||||
ThreadUtils.launch {
|
||||
ToastUtils.showToast("激活引擎异常,${e?.message}")
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user