/**
 * Created by webshow on 2019/11/22.
 */
var bbb = location.href;
$ip = 'http://test.api.lvdou66.com:8036/';
$ws = 'ws://114.55.165.186:12308/ws?type=1';
$url ='http://test.ybact.ishuaji.cn/'
// if (bbb.indexOf("https://activity.ishuaji.cn/") > -1) {
//     $ip = "https://zhiboweb.ishuaji.cn/";
//     $ws='wss://zhiboweb.ishuaji.cn/yzsocket?type=1'
//     $url ='https://activity.ishuaji.cn/'
// }else if(bbb.indexOf("http://test.ybact.ishuaji.cn/") > -1){
//     $ip = 'http://test.api.lvdou66.com:8036/';
//     $ws = 'ws://114.55.165.186:12308/ws?type=1';
//     $url ='http://test.ybact.ishuaji.cn/'
// } else if(bbb.indexOf('http://192.168.0.124:9090') > -1){
// 	$ip = 'http://test.api.lvdou66.com:8036/';
//     $ws = 'ws://114.55.165.186:12308/ws?type=1';
//     $url ='http://test.ybact.ishuaji.cn/'
// }
// else{
//     $ip = 'http://test.api.lvdou66.com:8036/';
//     $ws = 'ws://114.55.165.186:12308/ws?type=-1';
//     $url ='http://test.ybact.ishuaji.cn/'
// }
var data = url_get_params(bbb)
if (sessionStorage.kkk == undefined) {
    sessionStorage.kkk = data.token; //t
    sessionStorage.bbb = data.uid; //u
    sessionStorage.version = data.appversion;
    sessionStorage.pkg=data.pkg
    if (data.roomID != undefined && data.roomID != 'undefined') {
        sessionStorage.roomId = data.roomID;
    } else {
        sessionStorage.roomId = data.roomId;
    }
    if(sessionStorage.roomId=='undefined')sessionStorage.roomId=0
}
sessionStorage.jump=data.jump
sessionStorage.isShowHalf=data.isShowHalf
function url_get_params(url_path) {
    var url = url_path;
    var theRequest = new Object();
    if (url.indexOf("?") != -1) {
        var str = url.substr(url.indexOf("?") + 1);
        strs = str.split("&");
        for (var i = 0; i < strs.length; i++) {
            theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
        }
    }
    return theRequest;
}
if (bbb.indexOf("file:///D") > -1) {
    sessionStorage.bbb = 23868834;
    sessionStorage.kkk = 'debug'
    sessionStorage.roomId=23870943
}

//ajax设置默认参数
$.ajaxSetup({
    global: false,
    type: 'get',
    data: {
        uid: sessionStorage.bbb,
        token: sessionStorage.kkk
    },
    dataType: "JSON"
})
//点击刷新
$(".ref").on("click", function () {
    sessionStorage.jump=undefined;
    window.location.reload()
})
function btnHref(e){
    var myJson = {
        "cid": 12,
        "reqCode": new Date().getTime(),
        "data": {
            "msg":'跳转页面',
            "jump": e,
        }
    }
    var obj=JSON.stringify(myJson);
    appCollaboration(obj)
}
//与客户端交互
function appCollaboration(msg) {
    var ua = window.navigator.userAgent.toLowerCase();
    try {
        if (/iphone|ipad|ipod/.test(ua)) {
            window.webkit.messageHandlers.appCollaboration.postMessage(msg);
        } else if (/android/.test(ua)) {
            window.yazhai.appCollaboration(msg);
        }
    } catch (e) {
    }
}
//处理时间倒计时的函数
function timeDeal(e){
    var endTime=e;
    var newTime=new Date().getTime();
    var Remain=Math.floor((endTime-newTime)/1000);
    // if(Remain<=0)window.location.reload();
    var day=Math.floor(Remain/86400);
    var hour=add0(Math.floor(Remain%86400/3600));
    if(hour>99)hour=99;
    var min=add0(Math.floor(Remain%3600/60));
    var sceond=add0(Math.floor(Remain%60));
    var timeArr=[day,hour,min,sceond];
    return timeArr;
}
function timeDeal2(e,time){
    var endTime=e;
    var newTime=time;
    var Remain=Math.floor((endTime-newTime)/1000);
    // if(Remain<=0)window.location.reload();
    var day=add0(Math.floor(Remain/86400));
    var hour=add0(Math.floor(Remain%86400/3600));
    if(hour>99)hour=99;
    var min=add0(Math.floor(Remain%3600/60));
    var sceond=add0(Math.floor(Remain%60));
    var timeArr=[day,hour,min,sceond];
    return timeArr;
}
//时间戳转具体 年月日时分秒
function timeGet(e){
    var time = new Date(Number(e));
    var y = time.getFullYear();
    var m = time.getMonth()+1;
    var d = time.getDate();
    var h = time.getHours();
    var mm = time.getMinutes();
    var s = time.getSeconds();
    var timeArr=[y,m,d,add0(h),add0(mm),s]
    return timeArr
}

//一位数前面加0
function add0(m) {
    return m < 10 ? '0' + m : m
}
//一万以上省略
function addw(e){
    if(e>=100000000){
        return Math.floor((e/100000000).toFixed(2)*10)/10+'亿';
    }
    else if(e>10000000){
        return Math.floor((e/10000))+'万'
    }
    else if(e>=10000){
        return Math.floor((e/10000)*10)/10+'万';
    }else{
        return Math.floor(e*100)/100;
    }
}
//跳转充值页面
function goReg(){
    if(sessionStorage.pkg=='qingliang'){
        var ua = window.navigator.userAgent.toLowerCase();
        if (/iphone|ipad|ipod/.test(ua)) {
            window.location.href='yazhai://_recharge';

        }else{
            window.location.href='http://web.yazhai.co/milkRecharge/index.html?uid='+sessionStorage.bbb+'&token='+sessionStorage.kkk+'&pkg=qingliang';
        }
    } else if(sessionStorage.pkg=='qiezi'){
        if (/iphone|ipad|ipod/.test(ua)) {
            window.location.href='yazhai://_recharge';

        }else{
            window.location.href='http://web.yazhai.co/guodongRecharge/index.html?uid='+sessionStorage.bbb+'&token='+sessionStorage.kkk+'&pkg=qingliang';
        }
    }
    else{
        window.location.href='http://web.yazhai.co/recharge/index.html?uid='+sessionStorage.bbb+'&token='+sessionStorage.kkk+'&pkg=yabo';
    }
}
function scrollTo(element,speed) {
    if(!speed){
        speed = 300;
    }
    if(!element){
        $("html,body").animate({scrollTop:0},speed);
    }else{
        if(element.length>0){
            $("html,body").animate({scrollTop:$(element).offset().top-200},speed);
        }
    }
}

    //var betEnd = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate(), new Date().getHours(), 59, 59).getTime();