package com.abbidot.tracker.wxapi

import android.content.Intent
import com.abbidot.baselibrary.util.LogUtil
import com.abbidot.tracker.R
import com.abbidot.tracker.constant.ConstantInt
import com.abbidot.tracker.constant.ConstantString
import com.abbidot.tracker.deprecated.ui.activity.profile.recharge.PaymentResultActivity
import com.hjq.toast.Toaster
import com.tencent.mm.opensdk.modelbase.BaseResp

/**
 *Created  by .yzq on 2022/7/11/011.
 * @link
 * @description:微信支付回调Activity
 */
class WXPayEntryActivity : WXBaseActivity() {

    override fun onWXResp(baseResp: BaseResp) {
        LogUtil.e("WXPayEntryActivity", "code=" + baseResp.errCode)
        when (baseResp.errCode) {
            BaseResp.ErrCode.ERR_OK -> {
                Toaster.show(R.string.txt_pay_success)
                //支付成功
                LogUtil.e("WXPayEntryActivity", "支付成功")
                val intent = Intent(this, PaymentResultActivity::class.java)
                intent.putExtra(ConstantString.Type,  ConstantInt.Type1)
                startActivity(intent)
            }
            BaseResp.ErrCode.ERR_USER_CANCEL -> {
                Toaster.show(R.string.txt_cancel_pay)
                //取消支付
                LogUtil.e("WXPayEntryActivity", "取消支付")
            }
            else -> {
                Toaster.show(R.string.txt_pay_fail)
                //支付失败
                LogUtil.e("WXPayEntryActivity", "支付失败${baseResp.errStr}")
            }
        }
        finish()
    }

}