package com.cooleshow.usercenter.presenter

import com.cooleshow.base.ext.excute
import com.cooleshow.base.presenter.BasePresenter
import com.cooleshow.base.rx.BaseSubscriber
import com.cooleshow.usercenter.data.protocol.UserInfo
import com.cooleshow.usercenter.presenter.view.LoginView
import com.cooleshow.usercenter.service.UserService
import javax.inject.Inject


/*
    登录界面 Presenter
 */
class LoginPresenter @Inject constructor() : BasePresenter<LoginView>() {

    @Inject
    lateinit var userService: UserService

    /*
        登录
     */
    fun login(mobile: String, pwd: String, pushId: String) {
        if (!checkNetWork()) {
            return
        }
        mView.showLoading()
        userService.login(mobile, pwd, pushId).excute(object : BaseSubscriber<UserInfo>(mView) {
            override fun onNext(t: UserInfo) {
                mView.onLoginResult(t)
            }
        }, lifecycleProvider)
    }

}