|
@@ -25,6 +25,7 @@ import com.swago.baseswago.model.live.game.GameListModel
|
|
|
import com.swago.baseswago.model.live.gift.GiftSendModel
|
|
|
import com.swago.baseswago.util.*
|
|
|
import com.swago.room.bean.UserRoomModel
|
|
|
+import com.swago.room.enum.RoomType
|
|
|
import com.swago.room.pk.PKStateManager
|
|
|
import okhttp3.MediaType.Companion.toMediaType
|
|
|
import okhttp3.RequestBody.Companion.toRequestBody
|
|
@@ -50,9 +51,18 @@ class RoomOtherVm(application: Application) : BaseViewModel(application) {
|
|
|
fun getRankList(roomId: String, rankType: Int, page: Int) {
|
|
|
requestData2 {
|
|
|
requestData {
|
|
|
- val data = ApiManager.roomApi.getRankList(roomId, rankType, page)
|
|
|
- rankListLiveData.value = data.list
|
|
|
- totalLiveData.value = data.total
|
|
|
+ SwagoRoomManager.iRoomInfo?.let {
|
|
|
+ if (it.getRoomType() == RoomType.HOUSE.type){
|
|
|
+ val data = ApiManager.roomApi.getHouseRankList(roomId, rankType, page)
|
|
|
+ rankListLiveData.value = data.list
|
|
|
+ totalLiveData.value = data.total
|
|
|
+ } else {
|
|
|
+ val data = ApiManager.roomApi.getRankList(roomId, rankType, page)
|
|
|
+ rankListLiveData.value = data.list
|
|
|
+ totalLiveData.value = data.total
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
requestError {
|
|
@@ -72,8 +82,15 @@ class RoomOtherVm(application: Application) : BaseViewModel(application) {
|
|
|
*/
|
|
|
fun getShareConfig() {
|
|
|
requestData {
|
|
|
- val data = ApiManager.roomApi.getShareConfig()
|
|
|
- shareConfigLiveData.value = data
|
|
|
+ SwagoRoomManager.iRoomInfo?.let {
|
|
|
+ if (it.getRoomType() == RoomType.HOUSE.type){
|
|
|
+ val data = ApiManager.roomApi.getHouseShareConfig()
|
|
|
+ shareConfigLiveData.value = data
|
|
|
+ } else {
|
|
|
+ val data = ApiManager.roomApi.getShareConfig()
|
|
|
+ shareConfigLiveData.value = data
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -88,8 +105,14 @@ class RoomOtherVm(application: Application) : BaseViewModel(application) {
|
|
|
LogUtil.d("加入房间", "红包")
|
|
|
requestData {
|
|
|
SwagoRoomManager.iRoomInfo?.let {
|
|
|
- redEnvelopeListLiveData.value =
|
|
|
- ApiManager.roomApi.getRedEnvelopeList(it.getRoomId())
|
|
|
+ if (it.getRoomType() == RoomType.HOUSE.type){
|
|
|
+ redEnvelopeListLiveData.value =
|
|
|
+ ApiManager.roomApi.getHouseRedEnvelopeList(it.getRoomId())
|
|
|
+ } else {
|
|
|
+ redEnvelopeListLiveData.value =
|
|
|
+ ApiManager.roomApi.getRedEnvelopeList(it.getRoomId())
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -109,9 +132,16 @@ class RoomOtherVm(application: Application) : BaseViewModel(application) {
|
|
|
requestData2(false) {
|
|
|
requestData {
|
|
|
SwagoRoomManager.iRoomInfo?.let {
|
|
|
- ApiManager.roomApi.sendRedEnvelope(it.getRoomId(), coins, count)
|
|
|
- sendSuccessLiveData.value = 200
|
|
|
- SwagoLoading.cancelLoadingDialog()
|
|
|
+ if (it.getRoomType() == RoomType.HOUSE.type){
|
|
|
+ ApiManager.roomApi.sendHouseRedEnvelope(it.getRoomId(), coins, count)
|
|
|
+ sendSuccessLiveData.value = 200
|
|
|
+ SwagoLoading.cancelLoadingDialog()
|
|
|
+ } else {
|
|
|
+ ApiManager.roomApi.sendRedEnvelope(it.getRoomId(), coins, count)
|
|
|
+ sendSuccessLiveData.value = 200
|
|
|
+ SwagoLoading.cancelLoadingDialog()
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -139,9 +169,16 @@ class RoomOtherVm(application: Application) : BaseViewModel(application) {
|
|
|
requestData2 {
|
|
|
requestData {
|
|
|
SwagoRoomManager.iRoomInfo?.let {
|
|
|
- val data = ApiManager.roomApi.getRedEnvelopeCoin(it.getRoomId(), redEnvelopeId)
|
|
|
- receiveRedEnvelopeResultLiveData.value = data.coin
|
|
|
- UserInfo.getUserInfo()?.user_coins = data.user_coin
|
|
|
+ if (it.getRoomType() == RoomType.HOUSE.type){
|
|
|
+ val data = ApiManager.roomApi.getHouseRedEnvelopeCoin(it.getRoomId(), redEnvelopeId)
|
|
|
+ receiveRedEnvelopeResultLiveData.value = data.coin
|
|
|
+ UserInfo.getUserInfo()?.user_coins = data.user_coin
|
|
|
+ } else {
|
|
|
+ val data = ApiManager.roomApi.getRedEnvelopeCoin(it.getRoomId(), redEnvelopeId)
|
|
|
+ receiveRedEnvelopeResultLiveData.value = data.coin
|
|
|
+ UserInfo.getUserInfo()?.user_coins = data.user_coin
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -188,7 +225,11 @@ class RoomOtherVm(application: Application) : BaseViewModel(application) {
|
|
|
fun sendDanMu(message: String) {
|
|
|
requestData {
|
|
|
SwagoRoomManager.iRoomInfo?.let {
|
|
|
- ApiManager.roomApi.sendDanMu(it.getRoomId(), message)
|
|
|
+ if (it.getRoomType() == RoomType.HOUSE.type){
|
|
|
+ ApiManager.roomApi.sendHouseDanMu(it.getRoomId(), message)
|
|
|
+ } else {
|
|
|
+ ApiManager.roomApi.sendDanMu(it.getRoomId(), message)
|
|
|
+ }
|
|
|
sendDanMuNum++
|
|
|
sendDanMuResultLiveData.value = sendDanMuNum
|
|
|
}
|
|
@@ -205,8 +246,17 @@ class RoomOtherVm(application: Application) : BaseViewModel(application) {
|
|
|
fun getRedReceivedList(package_id: String) {
|
|
|
requestData2 {
|
|
|
requestData {
|
|
|
- val data = ApiManager.roomApi.getRedReceivedList(package_id)
|
|
|
- redListLiveData.value = data.list
|
|
|
+ SwagoRoomManager.iRoomInfo?.let {
|
|
|
+ if (it.getRoomType() == RoomType.HOUSE.type){
|
|
|
+ val data = ApiManager.roomApi.getHouseRedReceivedList(package_id)
|
|
|
+ redListLiveData.value = data.list
|
|
|
+ } else {
|
|
|
+ val data = ApiManager.roomApi.getRedReceivedList(package_id)
|
|
|
+ redListLiveData.value = data.list
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
requestError {
|
|
|
redListLiveData.value = null
|
|
@@ -292,7 +342,12 @@ class RoomOtherVm(application: Application) : BaseViewModel(application) {
|
|
|
fun userDianZan() {
|
|
|
requestData {
|
|
|
SwagoRoomManager.iRoomInfo?.let {
|
|
|
- ApiManager.roomApi.userDianZan(it.getRoomId())
|
|
|
+ if (it.getRoomType() == RoomType.HOUSE.type){
|
|
|
+ ApiManager.roomApi.userHouseDianZan(it.getRoomId())
|
|
|
+ } else {
|
|
|
+ ApiManager.roomApi.userDianZan(it.getRoomId())
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -309,8 +364,14 @@ class RoomOtherVm(application: Application) : BaseViewModel(application) {
|
|
|
requestData2 {
|
|
|
requestData {
|
|
|
SwagoRoomManager.iRoomInfo?.let {
|
|
|
- fanClubUserModelLiveData.value =
|
|
|
- ApiManager.roomApi.getFanClubList(it.getRoomId(), page)
|
|
|
+ if (it.getRoomType() == RoomType.HOUSE.type){
|
|
|
+ fanClubUserModelLiveData.value =
|
|
|
+ ApiManager.roomApi.getHouseFanClubList(it.getRoomId(), page)
|
|
|
+ } else {
|
|
|
+ fanClubUserModelLiveData.value =
|
|
|
+ ApiManager.roomApi.getFanClubList(it.getRoomId(), page)
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
requestError {
|
|
@@ -334,7 +395,11 @@ class RoomOtherVm(application: Application) : BaseViewModel(application) {
|
|
|
requestData2 {
|
|
|
requestData {
|
|
|
SwagoRoomManager.iRoomInfo?.let {
|
|
|
- ApiManager.roomApi.joinFanClub(it.getRoomId())
|
|
|
+ if (it.getRoomType() == RoomType.HOUSE.type){
|
|
|
+ ApiManager.roomApi.joinHouseFanClub(it.getRoomId())
|
|
|
+ } else {
|
|
|
+ ApiManager.roomApi.joinFanClub(it.getRoomId())
|
|
|
+ }
|
|
|
SwagoLoading.cancelLoadingDialog()
|
|
|
(it as UserRoomModel).roomModel?.is_fans = 1
|
|
|
isFansLiveData.value = 1
|
|
@@ -393,6 +458,49 @@ class RoomOtherVm(application: Application) : BaseViewModel(application) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 送礼
|
|
|
+ */
|
|
|
+ val sendHouseResultLiveData by lazy {
|
|
|
+ MutableLiveData<GiftSendModel?>()
|
|
|
+ }
|
|
|
+
|
|
|
+ val sendHouseGiftCodeLiveData by lazy {
|
|
|
+ MutableLiveData<ErrorModel>()
|
|
|
+ }
|
|
|
+
|
|
|
+ fun sendHouseGift(
|
|
|
+ room_id: String,
|
|
|
+ gift_id: String,
|
|
|
+ gift_batch: Int,
|
|
|
+ gift_receive_id: String,
|
|
|
+ isCombo: Int = 0,
|
|
|
+ gift_num: Int = 1,
|
|
|
+ ) {
|
|
|
+ requestData2(false) {
|
|
|
+ requestData {
|
|
|
+ val data = ApiManager.roomApi.sendHouseGift(
|
|
|
+ room_id, gift_id, gift_batch, gift_receive_id, isCombo, gift_num,
|
|
|
+ PKStateManager.pkId
|
|
|
+ )
|
|
|
+ LogUtil.d("送礼", "接口调用成功--${System.currentTimeMillis()}")
|
|
|
+ sendHouseResultLiveData.value = data
|
|
|
+ UserInfo.getUserInfo()?.let {
|
|
|
+ if (data.user_coins.toLong() < it.user_coins.toLong()) {
|
|
|
+ it.user_coins = data.user_coins
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ requestError {
|
|
|
+ if (it is SwagoException) {
|
|
|
+ val errorModel = ErrorModel(it.code, it.message ?: "")
|
|
|
+ sendHouseGiftCodeLiveData.value = errorModel
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
val sendResultAudioLiveData by lazy {
|
|
|
MutableLiveData<AudioSendGiftModel?>()
|