|
|
@@ -4,11 +4,19 @@ import android.content.Intent;
|
|
|
import android.os.Bundle;
|
|
|
import android.util.Log;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.sheep.gamegroup.event.WXLoginAuthEvent;
|
|
|
+import com.sheep.gamegroup.util.ApiJSONUtil;
|
|
|
+import com.sheep.gamegroup.util.Jump2View;
|
|
|
+import com.sheep.gamegroup.util.LogUtil;
|
|
|
+import com.sheep.gamegroup.util.QQUtil;
|
|
|
import com.sheep.jiuyan.samllsheep.Config;
|
|
|
+import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
|
import com.tencent.mm.opensdk.modelbase.BaseReq;
|
|
|
import com.tencent.mm.opensdk.modelbase.BaseResp;
|
|
|
+import com.tencent.mm.opensdk.modelbiz.WXLaunchMiniProgram;
|
|
|
import com.tencent.mm.opensdk.modelmsg.SendAuth;
|
|
|
+import com.tencent.mm.opensdk.modelpay.PayResp;
|
|
|
import com.tencent.mm.opensdk.openapi.IWXAPI;
|
|
|
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
|
|
|
import com.umeng.socialize.weixin.view.WXCallbackActivity;
|
|
|
@@ -20,39 +28,75 @@ public class WXEntryActivity extends WXCallbackActivity {//implements IWXAPIEven
|
|
|
@Override
|
|
|
public void onCreate(Bundle bundle) {
|
|
|
super.onCreate(bundle);
|
|
|
+ Log.i("WXEntryActivity", "-------------------------------: onCreate");
|
|
|
IWXAPI wxapi = WXAPIFactory.createWXAPI(this, Config.WX_AUTH_APP_ID, true);
|
|
|
wxapi.registerApp(Config.WX_AUTH_APP_ID);
|
|
|
wxapi.handleIntent(getIntent(), this);
|
|
|
+ Log.i("WXEntryActivity", "-------------------------------: onCreate finish");
|
|
|
finish();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onNewIntent(Intent newIntent) {
|
|
|
+ Log.i("WXEntryActivity", "-------------------------------: onNewIntent");
|
|
|
IWXAPI wxapi = WXAPIFactory.createWXAPI(this, Config.WX_AUTH_APP_ID, true);
|
|
|
wxapi.registerApp(Config.WX_AUTH_APP_ID);
|
|
|
wxapi.handleIntent(getIntent(), this);
|
|
|
+ Log.i("WXEntryActivity", "-------------------------------: onNewIntent");
|
|
|
finish();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onReq(BaseReq baseReq) {
|
|
|
- if(!(baseReq instanceof SendAuth.Req)){
|
|
|
+ Log.i("WXEntryActivity", "-------------------------------: onReq");
|
|
|
+ Log.i("WXEntryActivity", "-------------------------------: " + baseReq.getClass().getSimpleName());
|
|
|
+ if (!(baseReq instanceof SendAuth.Req)) {
|
|
|
super.onReq(baseReq);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onResp(BaseResp resp) {
|
|
|
+ Log.i("WXEntryActivity", "-------------------------------: onResp");
|
|
|
if (resp instanceof SendAuth.Resp) {
|
|
|
if (resp.errCode == BaseResp.ErrCode.ERR_OK) {
|
|
|
String code = ((SendAuth.Resp) resp).code;
|
|
|
EventBus.getDefault().post(new WXLoginAuthEvent(code));
|
|
|
- } else{
|
|
|
+ } else {
|
|
|
EventBus.getDefault().post(new WXLoginAuthEvent(null));
|
|
|
}
|
|
|
+ } else if (resp instanceof WXLaunchMiniProgram.Resp) {
|
|
|
+ WXLaunchMiniProgram.Resp miniResp = (WXLaunchMiniProgram.Resp) resp;
|
|
|
+ Log.i("WXEntryActivity", "-------------------------------: " + miniResp.extMsg);
|
|
|
+ MiniPayResult result = MiniPayResult.parse(miniResp.extMsg);
|
|
|
+ String code;
|
|
|
+ if ("success".equals(result.payResult)) {
|
|
|
+ ApiJSONUtil.missionExecute(4);
|
|
|
+ code = "9000";
|
|
|
+ } else {
|
|
|
+ code = "9001";
|
|
|
+ }
|
|
|
+ String frompackage = QQUtil.getWxPayFrom(SheepApp.getInstance(), result.prepayId);
|
|
|
+ String outorderno = QQUtil.getWxPayOrderNo(SheepApp.getInstance(), result.prepayId);
|
|
|
+ int fromorient = QQUtil.getWxPayOrient(SheepApp.getInstance(), result.prepayId);
|
|
|
+ QQUtil.removeWxPayFrom(this, result.prepayId);
|
|
|
+ QQUtil.removeWxPayOrderNo(this, result.prepayId);
|
|
|
+ QQUtil.removeWxPayOrient(this, result.prepayId);
|
|
|
+ Jump2View.getInstance().goRechargeResult(SheepApp.getInstance(), code, frompackage, fromorient, outorderno);
|
|
|
} else {
|
|
|
super.onResp(resp);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public static class MiniPayResult {
|
|
|
+ String payResult;
|
|
|
+ String prepayId;
|
|
|
+ String errorMsg;
|
|
|
+
|
|
|
+ public static MiniPayResult parse(String text) {
|
|
|
+ MiniPayResult result = JSONObject.parseObject(text, MiniPayResult.class);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|