package com.bc_chat.account.presenter

import com.bc_chat.account.contract.SendCodeContract
import com.bc_chat.account.task.SendVerfiyCodeTask
import com.google.gson.JsonObject
import com.zhaohaoting.framework.abs.presenter.BasePresenter
import com.zhaohaoting.framework.requset.NetWorkCallBack

/**
 * author：Created by zhaohaoting on 2019/3/5
 * email：526309416@qq.com
 * desc：发送验证码
 */
open class SendCodePresenter<VIEW : SendCodeContract.View> constructor(view: VIEW) : BasePresenter<VIEW>(view), SendCodeContract.Presenter {

    override fun senVerCode(mobilePhone: String?, type: Int) {
        taskHelper.execute<Any>(SendVerfiyCodeTask(mobilePhone, type), object : NetWorkCallBack<JsonObject>() {

            override fun onPreExecute(task: Any?) {
                view.showLoading(task)
            }

            override fun onPostExecuteSuccess(task: Any?, data: JsonObject?) {
                view.vercodeSendSuccess("发送成功")
                view.dismissLoading(task)
            }

            override fun onPostExecuteFailure(task: Any?, exception: Exception?) {
                super.onPostExecuteFailure(task, exception)
                view.vercodeSendFailure(exception)
                view.dismissLoading(task)
            }
        })
    }
}
