第一次 识别并保存 之前参加过的项目

This commit is contained in:
renhaoting 2026-01-13 12:00:41 +08:00
parent e28606c7d8
commit 04b35f09a0
1 changed files with 15 additions and 0 deletions

View File

@ -102,6 +102,8 @@ class ZeroBuyViewModel : ViewModel() {
respObj?.user_id?.let { respObj?.user_id?.let {
if (userId <= 0) { if (userId <= 0) {
AccountManager.saveUserIdInfo(it) AccountManager.saveUserIdInfo(it)
saveHasJoinedZeroIds(it, respObj.current_purchases)
} }
} }
@ -116,5 +118,18 @@ class ZeroBuyViewModel : ViewModel() {
} }
} }
private fun saveHasJoinedZeroIds(userId: Int, currentPurchases: List<ZeroBuyItem>) {
val joinZeroBuyItemIds = SpUtil.instance().getList<Int>(SpUtil.KEY_ZEROBUY_JOINED_ACTIVITY_IDS).toMutableList()
currentPurchases.forEach { zero ->
zero.current_users?.let {
if (it.contains(userId) && !joinZeroBuyItemIds.contains(userId)) {
joinZeroBuyItemIds.add(zero.id)
}
}
}
SpUtil.instance().putList(SpUtil.KEY_ZEROBUY_JOINED_ACTIVITY_IDS, joinZeroBuyItemIds)
}
} }