package com.swago.home.official

import android.app.Application
import android.widget.Toast
import androidx.lifecycle.MutableLiveData
import com.swago.baseswago.inter.ApiManager
import com.swago.baseswago.model.home.OfficialMsgModel
import com.swago.baseswago.model.home.OfficialSumModel
import com.swago.baseswago.util.AppContext
import com.swago.baseswago.util.BaseViewModel

/**
 *@date 2021/11/20 14:10
 *description:
 */
class OfficialVm(application: Application) : BaseViewModel(application) {

    val listMsgLiveData by lazy {
        MutableLiveData<List<OfficialMsgModel.ListBean>?>()
    }


    fun getMsgList(page:Int){
        requestData2 {
            requestData {
                val data = ApiManager.homeApi.getOfficialMsg(page)
                listMsgLiveData.value = data.list
            }

            requestError {
                listMsgLiveData.value = null
            }
        }
    }



    val officialSumLiveData by lazy {
        MutableLiveData<OfficialSumModel>()
    }

    fun getMsgSum(){
        requestData {
            val data = ApiManager.homeApi.getOfficialSum()
            officialSumLiveData.value = data
        }
    }
}