package com.quansu.heifengwuliu.vmodel

import androidx.lifecycle.MutableLiveData
import com.quansu.heifengwuliu.model.User
import com.quansu.heifengwuliu.repository.MineRepository
import com.ysnows.base.base.BViewModel
import com.ysnows.base.ccretrofit.CCRetrofit
import com.ysnows.base.route.IUpdate
import com.ysnows.base.utils.DialUtils

/**
 *Created by shihuiyun
 *on 2020/9/10
 */
open class MineVModel : BViewModel<MineRepository>() {
    val user: MutableLiveData<User> = MutableLiveData(User.get())


    override fun firstReq() {
        super.firstReq()
        repository().getUserInfo()
                .doOnNext {
                    user.value = it
                }
                .subscribe()
    }

    fun checkUpdates() {
        //检查更新
        CCRetrofit.instance()
                .create(IUpdate::class.java)
                .checkUpgrade(true)
                .subscribe()

    }

    fun callPhone() {
        DialUtils.dialPhone(view()?.context(), "19898989898")

    }

}
