package com.cheng.BoLe.wxapi

import com.example.base.common.RxBus
import com.tencent.mm.opensdk.constants.ConstantsAPI
import com.tencent.mm.opensdk.modelbase.BaseResp
import com.tencent.mm.opensdk.modelmsg.SendAuth
import com.umeng.socialize.weixin.view.WXCallbackActivity
import com.cheng.blzb.event.WxLoginEvent


class WXEntryActivity : WXCallbackActivity() {

    override fun onResp(resp: BaseResp?) {
        if (resp?.type == ConstantsAPI.COMMAND_SENDAUTH) {
            when (resp.errCode) {
                BaseResp.ErrCode.ERR_OK -> {
                    val authResp = resp as SendAuth.Resp
                    RxBus.defaultInstance.post(WxLoginEvent(authResp.code, authResp.state))
                }

                else -> RxBus.defaultInstance.post(WxLoginEvent("", ""))
            }
            finish()
        } else {
            finish()
        }
    }
}