admin
2021-07-06 abce02c7a61820f5d580f87364d542e817be429c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
package com.tejia.lijin.app.util;
 
import android.app.Activity;
import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.util.Log;
import android.webkit.WebChromeClient;
import android.webkit.WebViewClient;
 
import com.alibaba.baichuan.android.trade.AlibcTrade;
import com.alibaba.baichuan.android.trade.model.AlibcShowParams;
import com.alibaba.baichuan.android.trade.model.OpenType;
import com.alibaba.baichuan.android.trade.page.AlibcDetailPage;
import com.alibaba.baichuan.trade.biz.AlibcConstants;
import com.alibaba.baichuan.trade.biz.core.taoke.AlibcTaokeParams;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.kepler.jd.Listener.OpenAppAction;
import com.kepler.jd.login.KeplerApiManager;
import com.kepler.jd.sdk.bean.KeplerAttachParameter;
import com.tejia.lijin.app.entity.common.GoodsConvertLinkJumpLink;
import com.tejia.lijin.app.entity.common.WXXCXJumpInfo;
import com.wpc.library.util.common.StringUtils;
import com.tejia.lijin.app.BuXinConstant;
import com.tejia.lijin.app.callBack.MiDuoTradeCallback;
import com.tejia.lijin.app.entity.JumpDetail;
import com.tejia.lijin.app.entity.eventbus.HomeTabChangeEvent;
import com.tejia.lijin.app.ui.invite.ShareBrowserActivity;
import com.tejia.lijin.app.ui.main.MainActivity;
import com.tejia.lijin.app.util.baichuan.AlibcTradeUtil;
import com.tejia.lijin.app.util.user.LoginAndInviteStatusUtil;
import com.tejia.lijin.app.util.user.UserUtil;
 
import org.json.JSONException;
 
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
 
import de.greenrobot.event.EventBus;
 
import static android.content.Context.MODE_PRIVATE;
//                          _ooOoo_
//                         o8888888o
//                         88" . "88
//                         (| ^_^ |)
//                         O\  =  /O
//                      ____/`---'\____
//                    .'  \\|     |//  `.
//                   /  \\|||  :  |||//  \
//                  /  _||||| -:- |||||-  \
//                  |   | \\\  -  /// |   |
//                  | \_|  ''\---/''  |   |
//                  \  .-\__  `-`  ___/-. /
//                ___`. .'  /--.--\  `. . ___
//              ."" '<  `.___\_<|>_/___.'  >'"".
//            | | :  `- \`.;`\ _ /`;.`/ - ` : | |
//            \  \ `-.   \_ __\ /__ _/   .-` /  /
//      ========`-.____`-.___\_____/___.-`____.-'========
//                           `=---='
//      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//         佛祖保佑       永无BUG     永不修改
//
//         十年生死两茫茫 ,写程序,到天亮。
//             千行代码 ,Bug何处藏 ?
//         纵使上线又怎样 ,朝令改 ,夕断肠。
//
//         领导每天新想法 ,日日改 ,夜夜忙。
//             相顾无言 ,唯有泪千行。
//         每晚灯火阑珊处 ,夜难寐 ,加班狂。
// ************************************************************************************************
 
public class JumpActivityUtil {
 
    public static void jumpActivity(Context mContext,
                                    JumpDetail jumpDetail, JSONObject params) {
        Intent intent = null;
        org.json.JSONObject object = null;
        try {
            intent = new Intent(mContext, Class.forName(JumpActivityUtil.filterActivityName(jumpDetail.getActivity())));
            if (params != null)
                object = new org.json.JSONObject(params);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        if (object != null) {
            @SuppressWarnings("unchecked")
            Iterator<String> its = object.keys();
            while (its.hasNext()) {
                String key = its.next();
                String value = object.optString(key);
                intent.putExtra(key, value);
            }
        }
        mContext.startActivity(intent);
    }
 
    public static void jumpBaiChuan(Activity mActivity, String tbClientInfo, String url, String auctionId, AlibcShowParams alibcShowParams) {
        AlibcTaokeParams alibcTaokeParams = null;
        Map<String, String> exParams = new HashMap<>();
        exParams.put(AlibcConstants.ISV_CODE, "appisvcode");
        exParams.put("alibaba", "阿里巴巴");//自定义参数部分,可任意增删改
 
        if (!StringUtils.isEmpty(tbClientInfo)) {
            alibcTaokeParams = new AlibcTaokeParams("", "", "");
            alibcTaokeParams.setPid(BuXinConstant.BAICHUAN_PID);
            org.json.JSONObject object = null;
            try {
                object = new org.json.JSONObject(tbClientInfo);
            } catch (JSONException e) {
 
            }
            String pid = object.optString("pid");
            String appKey = object.optString("appKey");
            String adZoneId = object.optString("adZoneId");
            alibcTaokeParams.setPid(pid);
            alibcTaokeParams.setAdzoneid(adZoneId);
            alibcTaokeParams.pid = pid;
            alibcTaokeParams.adzoneid = adZoneId;
            alibcTaokeParams.extraParams = new HashMap<>();
            alibcTaokeParams.extraParams.put("taokeAppkey", appKey);
        } else {
            alibcTaokeParams = new AlibcTaokeParams("", "", "");
            alibcTaokeParams.setPid(BuXinConstant.BAICHUAN_PID);
            alibcTaokeParams.setAdzoneid(BuXinConstant.BAICHUAN_ADZONE_ID);
            alibcTaokeParams.pid = BuXinConstant.BAICHUAN_PID;
            alibcTaokeParams.adzoneid = BuXinConstant.BAICHUAN_ADZONE_ID;
            alibcTaokeParams.extraParams = new HashMap<>();
            alibcTaokeParams.extraParams.put("taokeAppkey", BuXinConstant.TAO_BAO_KE_KEY);
        }
 
        if (!StringUtils.isEmpty(url)) {
//            AlibcPage basePage = new AlibcPage(url);
//            AlibcTrade.show(mActivity, basePage, alibcShowParams, alibcTaokeParams, exParams, new MiDuoTradeCallback(""));
//            AlibcTrade.openByUrl(mActivity, "webDetail",
//                    url, null, new WebViewClient(), new WebChromeClient(),
//                    alibcShowParams, alibcTaokeParams, null, new MiDuoTradeCallback(""));
//
            AlibcTradeUtil.openByUrl(mActivity,
                    url, null, new WebViewClient(), new WebChromeClient(),
                    alibcShowParams, alibcTaokeParams, null);
 
        } else {
            AlibcDetailPage basePage = new AlibcDetailPage(auctionId);
//            AlibcTrade.show(mActivity, basePage, alibcShowParams, alibcTaokeParams, exParams, new MiDuoTradeCallback(""));
            AlibcTrade.openByBizCode(mActivity, basePage, null,
                    new WebViewClient(), new WebChromeClient(), "nativeDetail", alibcShowParams,
                    alibcTaokeParams, null, new MiDuoTradeCallback(""));
        }
    }
 
    /**
     * 跳转
     *
     * @param context
     * @param detail
     * @param params
     */
    public static void jumpPage(final Activity context, JumpDetail detail, JSONObject params) {
        if (context == null)
            return;
        if (detail == null)
            return;
        //判断是否需要登录
        if (detail.isNeedLogin()) {
            SharedPreferences sp = context.getSharedPreferences("user", MODE_PRIVATE);
            if (!sp.getBoolean("isLogin", false)) {
                UserUtil.jumpLogin(context);
                return;
            } else {
                //判断是否有登录未激活的情况
                if (!LoginAndInviteStatusUtil.acessNext(context, UserUtil.getUid(context), true)) {
                    return;
                }
            }
        }
 
        String type = detail.getType();
        switch (type) {
            case "wxxcx":
                if (params == null)
                    return;
                String userName = params.getString("userName");
                String path = params.getString("path");
                WXUtil.jumpWXXCX(context, userName, path);
                break;
 
            case "baichuan":
                if (params == null)
                    return;
                String url = params.getString("url");
                if (StringUtils.isEmpty(url))
                    return;
                //跳转百川
                AlibcShowParams alibcShowParams = new AlibcShowParams();
                alibcShowParams.setOpenType(OpenType.Auto);
                JumpActivityUtil.jumpBaiChuan(context, null, url, "", alibcShowParams);
                break;
 
            case "tbauth"://淘宝授权
                if (params == null)
                    return;
                String authLink = params.getString("url");
                if (StringUtils.isEmpty(authLink))
                    return;
                AlibcTradeUtil.openAuthLink(context, authLink);
                break;
            case "jd":
                if (params == null)
                    return;
                String jdUrl = params.getString("url");
                if (StringUtils.isEmpty(jdUrl))
                    return;
 
                KeplerApiManager.getWebViewService().openAppWebViewPage(context, jdUrl, new KeplerAttachParameter(), new OpenAppAction() {
                    @Override
                    public void onStatus(final int status, final String url) {
                        context.runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                if (status == OpenAppAction.OpenAppAction_result_APP) {
                                    //呼京东成功
                                    Log.e("mResult", "呼京东成功");
                                } else if (status == OpenAppAction.OpenAppAction_start) {
                                    //开始状态未必一定执行,
                                    Log.e("mResult", "开始呼起京东");
                                } else {
                                    //唤起京东失败
                                    Log.e("mResult", "唤起京东失败" + status);
                                    Intent intent = new Intent(context, ShareBrowserActivity.class);
                                    intent.putExtra("url", url);
                                    context.startActivity(intent);
                                }
                            }
                        });
                    }
                });
                break;
            case "home":
                //跳转首页
                ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
                String activityName = am.getRunningTasks(1).get(0).topActivity.getClassName();
                if (activityName.equalsIgnoreCase(MainActivity.class.getName())) {//当前activity
                    Integer tab = null;
                    Integer subTab = null;
                    try {
                        tab = params.getInteger("tab");
                    } catch (Exception e) {
                    }
                    try {
                        subTab = params.getInteger("subTab");
                    } catch (Exception e) {
                    }
                    EventBus.getDefault().post(new HomeTabChangeEvent(tab, subTab));
                }
                break;
 
            case "kefu"://跳转美洽客服
                String from = null;
                if (params != null)
                    from = params.getString("from");
                if (from == null)
                    from = "";
                KeFuUtil.jumpKeFu(context, from);
                break;
            case "thirdPlatform": {
                //三方平台
                if (params == null)
                    return;
                int sourceType = params.getInteger("sourceType");
                GoodsConvertLinkJumpLink link = new Gson().fromJson(params.toJSONString(), GoodsConvertLinkJumpLink.class);
                link.setNativeJumpLink(link.getJumpLink());
                link.set_native(true);
                switch (sourceType) {
                    case Constant.GOODS_TYPE_TB:
                        GoodsBuyJumpUtil.jumpTB(context, null, link.getJumpLink(), null, null, null);
                        break;
                    case Constant.GOODS_TYPE_JD:
                        GoodsBuyJumpUtil.jumpJD(context, link, null, null);
                        break;
                    case Constant.GOODS_TYPE_PDD:
                        GoodsBuyJumpUtil.jumpPDD(context, link, null);
                        break;
                    case Constant.GOODS_TYPE_VIP:
                        GoodsBuyJumpUtil.jumpVIPShop(context, link, null);
                        break;
                    case Constant.GOODS_TYPE_SUNING:
                        GoodsBuyJumpUtil.jumpSuning(context, link, null);
                        break;
                }
            }
            break;
            default: {
                try {
                    Intent intent = new Intent(context, Class.forName(JumpActivityUtil.filterActivityName(detail.getActivity())));
                    if (params != null)
                        for (Iterator<String> keys = params.keySet().iterator(); keys.hasNext(); ) {
                            String key = keys.next();
                            intent.putExtra(key, params.getString(key));
                        }
                    context.startActivity(intent);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            break;
        }
 
 
    }
 
 
    public static String filterActivityName(String activity) {
        if (activity == null)
            return null;
        return activity.replace("com.yeshi.ec.rebate.myapplication", "com.tejia.lijin.app");
    }
 
}