绑定解绑功能调试;其它优化
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.sw.platecabinet.viewmodel
|
||||
|
||||
import android.text.TextUtils
|
||||
import com.sw.inbound.utils.DateTimeUtils
|
||||
import com.sw.platecabinet.GlobalData
|
||||
import com.sw.platecabinet.GlobalData.globalEquipmentCode
|
||||
@@ -73,28 +74,36 @@ class SettingViewModel : BaseViewModel() {
|
||||
/**
|
||||
* 搜索会员信息列表
|
||||
*/
|
||||
fun getSearchMemberList(param: String, pageNum: Int = 1, pageSize: Int = 50) {
|
||||
fun getSearchMemberList(param:String, pageNum: Int = 1, pageSize: Int = 50) {
|
||||
if (TextUtils.isEmpty(param)) return
|
||||
currentPage = pageNum
|
||||
var name =""
|
||||
var phone =""
|
||||
val num = param.toIntOrNull()
|
||||
if (num != null) {
|
||||
phone = param
|
||||
} else {
|
||||
name = param
|
||||
}
|
||||
launch {
|
||||
val param = SearchParam(
|
||||
appVersion = GlobalData.appVersion,
|
||||
param = param,
|
||||
val searchParam = SearchParam(
|
||||
// appVersion = GlobalData.appVersion,
|
||||
name = name,
|
||||
phone = phone,
|
||||
pageNum = pageNum,
|
||||
pageSize = pageSize
|
||||
)
|
||||
isLoading = true
|
||||
val response = repository.searchUser(param)
|
||||
val response = repository.searchUser(searchParam)
|
||||
isLoading = false
|
||||
if (parseResponse(response)) {
|
||||
response.data?.let {
|
||||
canLoadMore = it.hasNextPage != false
|
||||
val newList = it.list ?: emptyList()
|
||||
response.data?.let { list ->
|
||||
if (pageNum == 1) {
|
||||
_searchMemberList.value = newList
|
||||
_searchMemberList.value = list
|
||||
} else {
|
||||
_searchMemberList.value = _searchMemberList.value.plus(newList)
|
||||
_searchMemberList.value = _searchMemberList.value.plus(list)
|
||||
}
|
||||
currentPage++
|
||||
if (list.size >= pageSize) currentPage++
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -149,7 +158,7 @@ class SettingViewModel : BaseViewModel() {
|
||||
// }
|
||||
// }
|
||||
|
||||
fun unbindPlate(id: Long, block:(Pair<Boolean?, ErrorInfo>)-> Unit) {
|
||||
fun unbindPlate(id: Long?, block:(Pair<Boolean?, ErrorInfo>)-> Unit) {
|
||||
block(null to ErrorInfo())
|
||||
launchWithLoading {
|
||||
val response = repository.plateUnbind(id)
|
||||
|
||||
@@ -66,26 +66,32 @@ class UserViewModel : BaseViewModel() {
|
||||
// 获取成功一次后缓存状态
|
||||
SPUtil.getInstance().put(GlobalKey.KEY_FIRST_RUN, true)
|
||||
val list: List<UserFaceModel> = response.data ?: emptyList()
|
||||
if (list.isEmpty()) {
|
||||
if (pageNo==1&&list.isEmpty()) {
|
||||
return@launchWithLoading
|
||||
}
|
||||
|
||||
SpTool.setLastFaceTimestamp(System.currentTimeMillis())
|
||||
val faceEntityList = list.map {
|
||||
FaceEntity(it.userId, null, Base64.decode(it.faceFeatureStr))
|
||||
}
|
||||
withContext(Dispatchers.Default) {
|
||||
faceApi.updateFaceData(pageNo, faceEntityList)
|
||||
if (list.size >= pageSize) {
|
||||
faceTimestamp = list.last().faceUpdateTimestamp?:0
|
||||
currentPageNo++
|
||||
getUserFaceCache(currentPageNo)
|
||||
return@withContext
|
||||
}
|
||||
if (list.isNotEmpty()) {
|
||||
faceTimestamp = list.last().faceUpdateTimestamp?:0
|
||||
}
|
||||
SpTool.setLastFaceTimestamp(faceTimestamp)
|
||||
//activeEngine()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var faceTimestamp = 0L
|
||||
|
||||
/**
|
||||
* 激活人脸识别引擎
|
||||
*/
|
||||
@@ -144,7 +150,7 @@ class UserViewModel : BaseViewModel() {
|
||||
fun getUserInfoById(memberId: String?, action:(EquipmentUserInfo?)->Unit={}) {
|
||||
_currentUserInfo.value = null
|
||||
launchWithLoading {
|
||||
val loginParam = LoginParam(memberId = memberId)
|
||||
val loginParam = LoginParam(faceId = memberId)
|
||||
val response = repository.equipmentBoxLogin(loginParam)
|
||||
if (parseResponse(response)) {
|
||||
_currentUserInfo.value = response.data
|
||||
|
||||
Reference in New Issue
Block a user