package com.zswc.creativity.vmodel

import android.app.Activity
import android.app.Application
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import com.hwangjr.rxbus.RxBus
import com.zswc.creativity.config.ConfigRx
import com.zswc.creativity.utils.net.NetEngine
import com.ysnows.base.base.BRRepository
import com.ysnows.base.base.BRViewModel
import com.ysnows.base.net.IResp
import com.ysnows.base.utils.UiSwitch
import com.zswc.creativity.activity.MyInfoActivity
import com.zswc.creativity.activity.WithdrawActivity
import kotlinx.coroutines.launch

/**
 *Created by shihuiyun
 *on 2020/9/25
 */
class MyWalletVModel(application: Application) : BRViewModel<BRRepository>(application) {

    var status="0"//默认全部
    var money = MutableLiveData<String>()
    var all = MutableLiveData<Boolean>(true)
    var income = MutableLiveData<Boolean>(false)
    var pay = MutableLiveData<Boolean>(false)
    var withdrawal = MutableLiveData<Boolean>(false)


    fun toChose(type:Int){
        status=type.toString()
        when(type){
            0->{
                all.value=true
                income.value=false
                pay.value=false
                withdrawal.value=false
            }
            1->{
                all.value=false
                income.value=true
                pay.value=false
                withdrawal.value=false

            }
            2->{
                all.value=false
                income.value=false
                pay.value=true
                withdrawal.value=false

            }
            3->{
                all.value=false
                income.value=false
                pay.value=false
                withdrawal.value=true

            }

        }

        firstReq()

    }


//    fun toDetails(data_id:String){
//
//        UiSwitch.bundle(repository().context, ArticleDetailActivity::class.java, Bundle().apply {
//            putInt("type",-1)
//            putString("id",data_id)
//        })
//
//
//    }


    fun toBack(){
        (repository().context as Activity).finish()
    }

    fun toWithdrawal(){
        //提现
        toast("暂未开放")
       // UiSwitch.single(repository().context, WithdrawActivity::class.java)

    }

    fun toRecharge(){
        //充值 todo：
        toast("暂未开放")

    }



    override fun apiFunc(): suspend () -> IResp<*> {
        return { NetEngine.service.moneyLog(status,10,repository().page) }
    }


}
