package com.fq.channel.sdk;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;

import com.fq.channel.sdk.base.utils.FqLog;
import com.tencent.mm.opensdk.modelbase.BaseResp;
import com.tencent.mm.opensdk.modelmsg.SendAuth;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.IWXAPIEventHandler;
import com.tencent.mm.opensdk.utils.Log;
import com.tencent.ysdk.module.user.impl.wx.YSDKWXEntryActivity;

public class WXCallBackActivity  extends YSDKWXEntryActivity implements IWXAPIEventHandler {

    private static final String TAG = "WXEntryActivity";
    private IWXAPI api;
    private String a,b,c;

    private Class lauanchClass ;


    public void onResp(BaseResp var1) {
//        super.onResp(var1);

        Bundle var2 = this.getIntent().getExtras();
        this.a = var2.getString("platformId");
        this.b = var2.getString("_wxobject_message_ext");
        this.c = var2.getString("_wxapi_add_card_to_wx_card_list");

        FqLog.d(TAG, "onResp");
        Log.d("YSDK_USER_WX", "onResp");

        Intent var6 = new Intent();

//        var6.setFlags(268435456);
//        var6.addFlags(536870912);
        var6.putExtra("wx_callback", "onResp");
        var6.putExtra("wx_errCode", var1.errCode);
        var6.putExtra("wx_errStr", var1.errStr);
        var6.putExtra("wx_transaction", var1.transaction);
        var6.putExtra("wx_openId", var1.openId);
        var6.putExtra("platformId", this.a);
        FqLog.i("YSDK_USER_WX", "transaction: " + var1.transaction);
        if(var1 instanceof SendAuth.Resp) {
            SendAuth.Resp var7 = (SendAuth.Resp)var1;
            FqLog.i("YSDK_USER_WX", "code: " + var7.code);
            var6.putExtra("wx_code", var7.code);
            var6.putExtra("country", var7.country);
            var6.putExtra("lang", var7.lang);
        }

        if(var1 instanceof com.tencent.mm.opensdk.modelmsg.SendMessageToWX.Resp && !TextUtils.isEmpty(var1.transaction) && var1.transaction.startsWith("WXShare")) {
            FqLog.i("YSDK_USER_WX", "code: " + var1.errCode);
            var6.putExtra("wx_share_err_code", var1.errCode);
        }

        if("wechatAddCardToWXCardPackage".equals(var1.transaction)) {
            var6.putExtra("_wxapi_add_card_to_wx_card_list", this.c);
        }

            new SdkPluginYsdk().onNewIntent(var6);
            this.finish();
    }

}
