package com.zxhl.cms.utils;

import android.content.Intent;
import android.util.Log;

import com.zxhl.cms.AppContext;
import com.zxhl.cms.router.RounterApi;
import com.zxhl.cms.router.RounterBus;

/**
 * Created by gaoleichao on 2019/3/12
 */
public class JumpUtils {

    public static void activityJump(Intent intent) {
        try {
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "该版本暂不支持，请更新版本！");
        }
    }

    public static void loginJump() {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentLogin();
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "该版本暂不支持，请更新版本！");
        }
    }

    public static void videoClipsJump(int pos) {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivityVideoClips(pos + "");
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "该版本暂不支持，请更新版本！");
        }
    }

    public static void memberJump() {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivityMembers();
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "该版本暂不支持，请更新版本！");
        }
    }

    public static void payJump(String boxid, String needprice, String type) {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivityPay(boxid, needprice, type);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "该版本暂不支持，请更新版本！");
        }
    }

    public static void goodsDetailJump(String boxid) {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivityGoodsDetail(boxid);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "该版本暂不支持，请更新版本！");
        }
    }

    public static void lotteryBoxJump(String boxid, String type, String price) {
        try {
            if (boxid != null) {
                return;
            }
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivityLotteryBoxJump(boxid, type, price, "");
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "该版本暂不支持，请更新版本！");
        }
    }

    public static void lotteryBoxJump(String boxid, String type, String price, String depotIds) {
        try {
            if (boxid != null) {
                return;
            }
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivityLotteryBoxJump(boxid, type, price, depotIds);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "该版本暂不支持，请更新版本！");
        }
    }

    public static void lotteryReslutJump(String boxid, String type, String price, String depotIds) {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivityLotteryReslutJump(boxid, type, price, depotIds);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "该版本暂不支持，请更新版本！");
        }
    }

    public static void ReceiveAddressReslutJump(String isDefault) {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivityReceiveAddressJump(isDefault);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "该版本暂不支持，请更新版本！");
        }
    }

    public static void EditAddressReslutJump(String id, String username, String mobile, String address, String address2, String country, String city, String province, String defaultAddress) {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivityEditAddressJump(id, username, mobile, address, address2, province, city, country, defaultAddress);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "该版本暂不支持，请更新版本！");
        }
    }

    public static void OrderDetailJump() {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivityOrderDetail();
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "该版本暂不支持，请更新版本！");
        }
    }

    public static void OrderSuccessJump() {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivityOrderSuccess();
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "该版本暂不支持，请更新版本！");
        }
    }

    public static void ShipmentSuccessJump() {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivityShipmentSuccess();
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "该版本暂不支持，请更新版本！");
        }
    }

    public static void LogisticsJump() {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivityLogistics();
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "该版本暂不支持，请更新版本！");
        }
    }

    public static void MyOrderJump() {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivityMyOrder();
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "该版本暂不支持，请更新版本！");
        }
    }

    public static void MyMagicCoinJump() {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivityMyMagicCoin();
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "该版本暂不支持，请更新版本！");
        }
    }

    public static void WareHouseJump() {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivityWareHouse();
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "该版本暂不支持，请更新版本！");
        }
    }

    public static void SubmitJump() {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivitySubmit();
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "该版本暂不支持，请更新版本！");
        }
    }

    public static void ThirdPardLoginJump() {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivityThirdPartLogin();
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "该版本暂不支持，请更新版本！");
        }
    }

    public static void videoResultJump(String url) {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivityVideoResult(url);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "该版本暂不支持，请更新版本！");
        }
    }

    public static void webJump(String title, String url) {
        try {
            Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivityWeb(title, url);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            AppContext.get().startActivity(intent);
        } catch (Exception e) {
            Utils.showToast(AppContext.get(), "该版本暂不支持，请更新版本！");
        }
    }

}
