| | |
| | | package com.xw.yunwei.ui.user.mine.protocol |
| | | |
| | | import android.app.Application |
| | | import androidx.lifecycle.MutableLiveData |
| | | import com.xw.common.base.BaseViewModel |
| | | import com.xw.yunwei.model.AgreeInfo |
| | | import com.xw.yunwei.net.UserRepository |
| | | import org.koin.core.component.inject |
| | | import kotlin.getValue |
| | | |
| | | class ProtocolVM (application: Application) : BaseViewModel(application) { |
| | | class ProtocolVM(application: Application) : BaseViewModel(application) { |
| | | val userRepository: UserRepository by inject() |
| | | |
| | | fun getProtocol(type: Int, block: (String) -> Unit) { |
| | | launchRequest { |
| | | val data = userRepository.getProtocol(type) |
| | | runOnMainThread { block(data?.content ?: "") } |
| | | } |
| | | val protocols = MutableLiveData<List<AgreeInfo>>() |
| | | override fun onCreate() { |
| | | super.onCreate() |
| | | getAgreeConfig() |
| | | } |
| | | |
| | | /*获取协议配置 */ |
| | | fun getAgreeConfig() { |
| | | launchRequest { |
| | | userRepository.getAgreeConfig()?.also { |
| | | protocols.postValue(it) |
| | | } |
| | | } |
| | | } |
| | | } |