|
|
@@ -45,6 +45,7 @@ import com.sheep.gamegroup.util.LogUtil;
|
|
|
import com.sheep.gamegroup.util.MainTab;
|
|
|
import com.sheep.gamegroup.util.QQUtil;
|
|
|
import com.sheep.gamegroup.util.SMSUtil;
|
|
|
+import com.sheep.gamegroup.util.StringUtils;
|
|
|
import com.sheep.gamegroup.util.SysAppUtil;
|
|
|
import com.sheep.gamegroup.util.ViewUtil;
|
|
|
import com.sheep.gamegroup.util.share.ShareLinkConfig;
|
|
|
@@ -647,6 +648,21 @@ public class KFZSJs {
|
|
|
@Override
|
|
|
public void onResult(SHARE_MEDIA share_media) {
|
|
|
iWeb.loadJs("handleShare(0)");
|
|
|
+
|
|
|
+ Uri uri = Uri.parse(iWeb.getWebUrl());
|
|
|
+ String host = uri.getHost();
|
|
|
+ String cookies = CookieManager.getInstance().getCookie(host);
|
|
|
+ Map<String, String> cookieMap = StringUtils.string2Map(cookies, ";", "=");
|
|
|
+
|
|
|
+ submitH5GameRecord(
|
|
|
+ 3,
|
|
|
+ cookieMap.get("openid"),
|
|
|
+ cookieMap.get("nickname"),
|
|
|
+ iWeb.getWebTitle(),
|
|
|
+ iWeb.getWebUrl(),
|
|
|
+ "wx".equals(cookieMap.get("account_type")) ? 1 : 2,
|
|
|
+ type
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -673,16 +689,12 @@ public class KFZSJs {
|
|
|
|
|
|
@Override
|
|
|
public void onComplete(SHARE_MEDIA share_media, int i, Map<String, String> map) {
|
|
|
- Uri uri = Uri.parse(iWeb.getWebUrl());
|
|
|
- String host = uri.getHost();
|
|
|
- CookieManager cookieManager = CookieManager.getInstance();
|
|
|
Map<String, String> params = new HashMap<>();
|
|
|
params.put("access_token", map.get("access_token"));
|
|
|
params.put("openid", map.get("openid"));
|
|
|
params.put("account_type", type);
|
|
|
params.put("app_id", "wx".equals(type) ? Config.WX_AUTH_APP_ID : Config.QQ_APP_ID);
|
|
|
- iWeb.setCookies(host, params);
|
|
|
- iWeb.loadJs("handleLogin(1)");
|
|
|
+ loadThirdPartUserInfo(type, params);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -697,4 +709,69 @@ public class KFZSJs {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+ private void loadThirdPartUserInfo(String platform, Map<String, String> cookies) {
|
|
|
+ UMShareAPI.get(SheepApp.getInstance()).getPlatformInfo(activity, "wx".equals(platform) ? SHARE_MEDIA.WEIXIN : SHARE_MEDIA.QQ,
|
|
|
+ new UMAuthListener() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onStart(SHARE_MEDIA share_media) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onComplete(SHARE_MEDIA share_media, int i, Map<String, String> map) {
|
|
|
+ cookies.put("nickname", map.get("screen_name"));
|
|
|
+ Uri uri = Uri.parse(iWeb.getWebUrl());
|
|
|
+ String host = uri.getHost();
|
|
|
+ iWeb.setCookies(host, cookies);
|
|
|
+ iWeb.loadJs("handleLogin(1)");
|
|
|
+
|
|
|
+ submitH5GameRecord(
|
|
|
+ 2,
|
|
|
+ cookies.get("openid"),
|
|
|
+ map.get("screen_name"),
|
|
|
+ iWeb.getWebTitle(),
|
|
|
+ iWeb.getWebUrl(),
|
|
|
+ "wx".equals(platform) ? 1 : 2,
|
|
|
+ -1
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onError(SHARE_MEDIA share_media, int i, Throwable throwable) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onCancel(SHARE_MEDIA share_media, int i) {
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void submitH5GameRecord(int type, String openId, String nickname, String gameName, String gameUrl, int accountPlatform, int actionPlatform) {
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
+ json.put("openid", openId);
|
|
|
+ json.put("nickname", nickname);
|
|
|
+ json.put("type", type);
|
|
|
+ json.put("game_name", gameName);
|
|
|
+ json.put("game_url", gameUrl);
|
|
|
+ json.put("account_platform", accountPlatform);
|
|
|
+ json.put("action_platform", actionPlatform);
|
|
|
+ SheepApp.getInstance().getNetComponent().getApiService().recordH5GameAction(json)
|
|
|
+ .subscribeOn(Schedulers.io())
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
+ .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
|
|
|
+ @Override
|
|
|
+ public void onError(BaseMessage baseMessage) {
|
|
|
+ LogUtil.logE(baseMessage != null ? baseMessage.getErrorMsg() + "" : "api错误");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onNext(BaseMessage baseMessage) {
|
|
|
+ LogUtil.logI("记录完成");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|