
import { sys } from "cc";
import { MainScene } from "./MainScene";

//192.168.1.15:7456
//?bundle&pay&pre&pay&test&1
//?bundle&guild&pre&createguild&
//?bundle&guild&pre&joinguild&match&111
class NavInfo{
    public scene: MainScene = null;

    public bundle = "share";
    public pre = "share";
    public is_test = false;
    public match_id = "";
    public user_id = "";

    public init(){
        let index = location.href.indexOf("?");
        if (index > -1) {
            let str = location.href.slice(index + 1);
            let strs = str.split("&");
            for(let i = 0; i < strs.length; i += 2){
                if(!strs[i+1])return;
                switch(strs[i]){
                    case "bundle":
                        this.bundle = strs[i + 1];
                        break;
                    case "pre":
                        this.pre = strs[i + 1];
                        break;
                    case "test":
                        this.is_test = strs[i+1] == "1";
                        break;
                    case "match":
                        this.match_id = strs[i+1];
                        break;
                    case "user":
                        this.user_id = strs[i+1];
                        break;
                }
            }
        }
    }
}

export const nav_info = new NavInfo();

export class Config{
    public static copy_prefix = "cocobaloot:";
    
    //跳转
    public static scheme_id = "cocobaloot";
    public static scheme_prefix = "";
    //下载
    public static download_ios_url = "https://apps.apple.com/sa/app/%D8%A8%D9%84%D9%88%D8%AA-%D8%A7%D9%84%D9%85%D8%A7%D8%B1%D8%AF/id6451100112";
    public static downlaod_google_url = `https://play.google.com/store/apps/details?id=chior.mideast.thirdd&referrer=website`;
    //充值
    public static url_product = "https://baloot.almarid77.com:8088/livepay/getProducts?H5Extra=666888";
    public static url_pay = "https://baloot.almarid77.com:8088/livepay/payOrder";
    public static url_product_test = "http://139.224.253.42:8089/livepay/getProducts?H5Extra=666888";
    public static url_pay_test = "http://139.224.253.42:8089/livepay/payOrder";

    public static init(){
        let prefix = sys.os == sys.OS.IOS ? "://?" : "://splash?";
        Config.scheme_prefix = Config.scheme_id + prefix;
    }
}