import Activity from 'android.app.Activity'; import IWXAPIEventHandler from 'com.tencent.mm.opensdk.openapi.IWXAPIEventHandler'; import BaseReq from 'com.tencent.mm.opensdk.modelbase.BaseReq'; import BaseResp from 'com.tencent.mm.opensdk.modelbase.BaseResp'; import ConstantsAPI from 'com.tencent.mm.opensdk.constants.ConstantsAPI'; import Bundle from 'android.os.Bundle' import WXAPIFactory from 'com.tencent.mm.opensdk.openapi.WXAPIFactory'; import {Wxpay} from './Wxpay'; import R from 'uts.sdk.modules.uniPaymentWxpay.R'; const defaultErrorCode : number = 700716 const errorCodeMap : Map = new Map([ [-1, 700711], [-2, 700713] ]) export class WXPayEntryActivity extends Activity implements IWXAPIEventHandler { constructor() { super() } override onCreate(savedInstanceState : Bundle | null) { super.onCreate(savedInstanceState) let api = WXAPIFactory.createWXAPI(this, ''); api.handleIntent(this.getIntent(), this); } override onResp(resp : BaseResp) : void { let options=Wxpay.mOptions console.log("mOptions",options) if (resp.getType() == ConstantsAPI.COMMAND_PAY_BY_WX) { if (resp.errCode == 0) { let res : RequestPaymentSuccess = { data: resp } options.success?.(res) options.complete?.(res) } else { let code = errorCodeMap[resp.errCode]; if (code == null) { code = defaultErrorCode } let err = new RequestPaymentFailImpl(code.toInt()); options.fail?.(err) options.complete?.(err) } } this.finish(); this.overridePendingTransition(0,R.anim.uni_wxpay_out_top); } override onReq(req : BaseReq) { this.finish(); } };