$.ajaxSetup({
		global: false,
		type: 'post',
		dataType: "JSON",
		data: {
			os: 'WEB',
			cid: 'web_gw',
			lang: 2,
			uid: url_get_params().uid,
			token: url_get_params().token
		}
})


function getTime(time){
	var timezone = 8; //目标时区时间,东八区
	var offset_GMT = new Date(time*1000).getTimezoneOffset(); // 本地时间和格林威治的时间差,单位为分钟
	var nowDate = new Date(time*1000).getTime(); // 本地时间距 1970 年 1 月 1 日午夜(GMT 时间)之间的毫秒数
	var data = new Date(nowDate + offset_GMT * 60 * 1000 + timezone * 60 * 60 * 1000);

	
	var month = data.getMonth()+1;
	var day = data.getDate();
	var hour = data.getHours();
	var minute = data.getMinutes();
	var sec = data.getSeconds();
	
	return add0(month)+'-'+add0(day)+' '+add0(hour)+':'+add0(minute)+':'+add0(sec);
}

//時間加0
function add0(m) {
	return m < 10 ? '0' + m + "" : m + ""
}

//获取url参数
function url_get_params() {
	var url = location.href;
	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;
}

function close() {
	var obj = {
		"cid": 14,
		"reqCode": new Date().getTime(),
		"data": {
			"msg": '關閉半屏網頁',
		}
	}
	var obj2 = JSON.stringify(obj);
	appCollaboration(obj2);
}

function getRule(time,unit){
	var str = '';
	str += '<div class="clearfix">';
	str += '		<p>1.</p>';
	str += '		<p>活動所有時間以服務器時間為準(東八區)</p>';
	str += '</div>';
	str += '<div class="clearfix">';
	str += '		<p>2.</p>';
	str += '		<p>榜單統計截止時間:'+time+'</p>';
	str += '</div>';
	str += '<div class="clearfix">';
	str += '		<p>3.</p>';
	str += '		<p>抽獎獎勵實時發放,禮物發放至背包,座駕發放至座駕倉庫</p>';
	str += '</div>';
	str += '<div class="clearfix">';
	str += '		<p>4.</p>';
	str += '		<p>活動獎勵'+unit+'不屬於直播'+unit+'收益,需在'+unit+'提現頁面查看詳細</p>';
	str += '</div>';
	str += '<div class="clearfix">';
	str += '		<p>5.</p>';
	str += '		<p>為保證活動公平性,活動期間由於不可抗力因素、網絡、作弊等非平台原因導致活動出現異常,平台有權採取活動調整、暫停等措施</p>';
	str += '</div>';
	str += '<div class="clearfix">';
	str += '		<p>6.</p>';
	str += '		<p>活動最終解釋權歸平台所有與Apple Inc無關</p>';
	str += '</div>';
	
	return str;
}

function getRule2(time,unit){
	var str = '';
	str += '<p>1.活動所有時間以服務器時間為準(東八區)<p>';
	str += '<p>2.榜單統計截止時間:'+time+'<p>';
	str += '<p>3.抽獎獎勵實時發放,禮物發放至背包,座駕發放至座駕倉庫<p>';
	str += '<p>4.活動獎勵'+unit+'不屬於直播'+unit+'收益,需在'+unit+'提現頁面查看詳細<p>';
	str += '<p>5.為保證活動公平性,活動期間由於不可抗力因素、網絡、作弊等非平台原因導致活動出現異常,平台有權採取活動調整、暫停等措施<p>';
	str += '<p>6.活動最終解釋權歸平台所有與Apple Inc無關<p>';
	
	return str;
}
function appCollaboration(msg) {
	var sUserAgent = navigator.userAgent.toLowerCase();
	var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
	var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
	var bIsMidp = sUserAgent.match(/midp/i) == "midp";
	var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
	var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
	var bIsAndroid = sUserAgent.match(/android/i) == "android";
	var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
	var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
	if(!(bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM)) {} else if(bIsAndroid) {
		window.yazhai.appCollaboration(msg);
	} else if(bIsIphoneOs || bIsIpad) {
		window.webkit.messageHandlers.appCollaboration.postMessage(msg);
	}
}
//客户端回调结果
function appCallback(msg) {
	console.log(msg);
}

/**
 * 根据传入的appname马甲包名返回对应马甲包的资源对象
 * @param  appname 马甲包名
 * @returns resourceObj 
 */
function handleVestApp  (appname)  {
    const staticUrl = "https://app.ixiulive.com/static/app/img/vestBag";
    let resourceObj;
    if (
        appname == "face.peach.live.video.chat.tangoo" ||
        appname == "online.live.video.chat.mt.lite" ||
        appname == "com.peach.live.mico.tangoo"
    ) {
        /* 蜜桃直播或蜜桃lite */
        resourceObj = {
            btnTextColor: "#fff",
            fireColor: "#DD59F1",
            bgColor: "#feacd2", // 邀请有奖主页面背景色·
            langBgColor: "#fff",
            textColor: "#F658A1", // 默认主题文字颜色
            themeColor: "#F658A1", // 主题色
            bgImg: staticUrl + "/nectarina/invite_bg.jpg",
            bgEnImg: staticUrl + "/nectarina/invite_bg_en.jpg",
            hasBuyIcon: staticUrl + "/nectarina/has_buy_icon.png",
            iconBigFire: staticUrl + "/nectarina/icon_bigFire.png",
            dewImg: staticUrl + "/nectarina/icon_dew.png",
            fireImg: staticUrl + "/nectarina/icon_fire.png",
            gewImg: staticUrl + "/nectarina/icon_gew.png",
            inviteBg: staticUrl + "/nectarina/invite_bg.png",
            inviteBgEn: staticUrl + "/nectarina/invite_bg_en.png",
            lastImg: staticUrl + "/nectarina/last.png",
            loadLogo: staticUrl + "/nectarina/load_logo.png",
            logo: staticUrl + "/nectarina/logo.png",
            noData: staticUrl + "/nectarina/no_data.png",
            step1: staticUrl + "/nectarina/step1.png",
            step1En: staticUrl + "/nectarina/step1_en.png",
            step2: staticUrl + "/nectarina/step2.png",
            step2En: staticUrl + "/nectarina/step2_en.png",
            step3: staticUrl + "/nectarina/step3.png",
            step3En: staticUrl + "/nectarina/step3_en.png",
            vipImg: staticUrl + "/nectarina/vip.png",
            svipImg: staticUrl + "/nectarina/svip.png",
            vipBg1Cn: staticUrl + "/nectarina/vip_bg1_cn.png",
            vipBg1En: staticUrl + "/nectarina/vip_bg1_en.png",
            vipBg2Cn: staticUrl + "/nectarina/vip_bg2_cn.png",
            vipBg2En: staticUrl + "/nectarina/vip_bg2_en.png",
            noLogo: staticUrl + "/nectarina/no_data.png",
            caseBg1: staticUrl + "/nectarina/case_bg1.png",
            caseBg2: staticUrl + "/nectarina/case_bg2.png",
            headLogo: staticUrl + "/nectarina/head_logo.png",
            iconCorrect: staticUrl + "/nectarina/icon_correct.png",
            checkColorBg: staticUrl + "/nectarina/check_color_bg.png",
            multipleGew: staticUrl + "/nectarina/multipleGew.png",
            iconBox: staticUrl + "/nectarina/icon_box.png",
            rewardHeadChImg: staticUrl + "/nectarina/reward_head.png",
            rewardHeadENImg: staticUrl + "/nectarina/reward_head_en.png",
            rewaRdrulesCh1Img: staticUrl + "/nectarina/rewaRdrules-ch1.png",
            rewaRdrulesCh2Img: staticUrl + "/nectarina/rewaRdrules-ch2.png",
            rewaRdrulesEn1Img: staticUrl + "/nectarina/rewaRdrules-en1.png",
            rewaRdrulesEn2Img: staticUrl + "/nectarina/rewaRdrules-en2.png",
            rewardBgColor: '#fcdbea',// 直播奖励页面背景色
            rewardIcon: staticUrl + "/nectarina/reward-icon.png",
            gewBigImg:staticUrl + "/nectarina/icon_bigGew.png",
            iconSmallGew:staticUrl + "/nectarina/icon_smallGew.png",
        };
    } else if (
        appname == "among.chameet.bigoo.Live.video.chat" ||
        appname == "com.nine.one.lite.android"
    ) {
        /* 秘密直播或秘密lite */
        resourceObj = {
            btnTextColor: "#fff",
            fireColor: "#EE348B",
            bgColor: "#fc8b98",
            langBgColor: "#fff",
            textColor: "#FD4F62",
            themeColor: "#FD4F62", // 主题色
            bgImg: staticUrl + "/secret/invite_bg.jpg",
            bgEnImg: staticUrl + "/secret/invite_bg_en.jpg",
            hasBuyIcon: staticUrl + "/secret/has_buy_icon.png",
            iconBigFire: staticUrl + "/secret/icon_bigFire.png",
            dewImg: staticUrl + "/secret/icon_dew.png",
            fireImg: staticUrl + "/secret/icon_fire.png",
            gewImg: staticUrl + "/secret/icon_gew.png",
            inviteBg: staticUrl + "/secret/invite_bg.png",
            inviteBgEn: staticUrl + "/secret/invite_bg_en.png",
            lastImg: staticUrl + "/secret/last.png",
            loadLogo: staticUrl + "/secret/load_logo.png",
            logo: staticUrl + "/secret/logo.png",
            noData: staticUrl + "/secret/no_data.png",
            step1: staticUrl + "/secret/step1.png",
            step1En: staticUrl + "/secret/step1_en.png",
            step2: staticUrl + "/secret/step2.png",
            step2En: staticUrl + "/secret/step2_en.png",
            step3: staticUrl + "/secret/step3.png",
            step3En: staticUrl + "/secret/step3_en.png",
            vipImg: staticUrl + "/secret/vip.png",
            svipImg: staticUrl + "/secret/svip.png",
            vipBg1Cn: staticUrl + "/secret/vip_bg1_cn.png",
            vipBg1En: staticUrl + "/secret/vip_bg1_en.png",
            vipBg2Cn: staticUrl + "/secret/vip_bg2_cn.png",
            vipBg2En: staticUrl + "/secret/vip_bg2_en.png",
            noLogo: staticUrl + "/secret/no_data.png",
            caseBg1: staticUrl + "/secret/case_bg1.png",
            caseBg2: staticUrl + "/secret/case_bg2.png",
            headLogo: staticUrl + "/secret/head_logo.png",
            iconCorrect: staticUrl + "/secret/icon_correct.png",
            checkColorBg: staticUrl + "/secret/check_color_bg.png",
            multipleGew: staticUrl + "/secret/multipleGew.png",
            iconBox: staticUrl + "/secret/icon_box.png",
            rewardHeadChImg: staticUrl + "/secret/reward_head.png",
            rewardHeadENImg: staticUrl + "/secret/reward_head_en.png",
            rewaRdrulesCh1Img: staticUrl + "/secret/rewaRdrules-ch1.png",
            rewaRdrulesCh2Img: staticUrl + "/secret/rewaRdrules-ch2.png",
            rewaRdrulesEn1Img: staticUrl + "/secret/rewaRdrules-en1.png",
            rewaRdrulesEn2Img: staticUrl + "/secret/rewaRdrules-en2.png",
            rewardBgColor: '#fee4e7',// 直播奖励页面背景色
            rewardIcon: staticUrl + "/secret/reward-icon.png",
            gewBigImg:staticUrl + "/secret/icon_bigGew.png",
            iconSmallGew:staticUrl + "/secret/icon_smallGew.png",
        };
    } else if (appname == "chat.video.live.bigoo.micoo") {
        /* 悦色*/
        resourceObj = {
            btnTextColor: "#fff",
            fireColor: "#FEA718",
            bgColor: "#fcd88a",
            langBgColor: "#fff",
            textColor: "F7CA6A",
            themeColor: "#F7CA6A", // 主题色
            bgImg: staticUrl + "/candle/invite_bg.jpg",
            bgEnImg: staticUrl + "/candle/invite_bg_en.jpg",
            hasBuyIcon: staticUrl + "/candle/has_buy_icon.png",
            iconBigFire: staticUrl + "/candle/icon_bigFire.png",
            dewImg: staticUrl + "/candle/icon_dew.png",
            fireImg: staticUrl + "/candle/icon_fire.png",
            gewImg: staticUrl + "/candle/icon_gew.png",
            inviteBg: staticUrl + "/candle/invite_bg.png",
            inviteBgEn: staticUrl + "/candle/invite_bg_en.png",
            lastImg: staticUrl + "/candle/last.png",
            loadLogo: staticUrl + "/candle/load_logo.png",
            logo: staticUrl + "/candle/logo.png",
            noData: staticUrl + "/candle/no_data.png",
            step1: staticUrl + "/candle/step1.png",
            step1En: staticUrl + "/candle/step1_en.png",
            step2: staticUrl + "/candle/step2.png",
            step2En: staticUrl + "/candle/step2_en.png",
            step3: staticUrl + "/candle/step3.png",
            step3En: staticUrl + "/candle/step3_en.png",
            vipImg: staticUrl + "/candle/vip.png",
            svipImg: staticUrl + "/candle/svip.png",
            vipBg1Cn: staticUrl + "/candle/vip_bg1_cn.png",
            vipBg1En: staticUrl + "/candle/vip_bg1_en.png",
            vipBg2Cn: staticUrl + "/candle/vip_bg2_cn.png",
            vipBg2En: staticUrl + "/candle/vip_bg2_en.png",
            noLogo: staticUrl + "/candle/no_data.png",
            caseBg1: staticUrl + "/candle/case_bg1.png",
            caseBg2: staticUrl + "/candle/case_bg2.png",
            headLogo: staticUrl + "/candle/head_logo.png",
            iconCorrect: staticUrl + "/candle/icon_correct.png",
            checkColorBg: staticUrl + "/candle/check_color_bg.png",
            multipleGew: staticUrl + "/candle/multipleGew.png",
            iconBox: staticUrl + "/candle/icon_box.png",
            rewardHeadChImg: staticUrl + "/candle/reward_head.png",
            rewardHeadENImg: staticUrl + "/candle/reward_head_en.png",
            rewaRdrulesCh1Img: staticUrl + "/candle/rewaRdrules-ch1.png",
            rewaRdrulesCh2Img: staticUrl + "/candle/rewaRdrules-ch2.png",
            rewaRdrulesEn1Img: staticUrl + "/candle/rewaRdrules-en1.png",
            rewaRdrulesEn2Img: staticUrl + "/candle/rewaRdrules-en2.png",
            rewardBgColor: '#e3ffff',
            rewardIcon: staticUrl + "/candle/reward-icon.png",
            gewBigImg:staticUrl + "/candle/icon_bigGew.png",
            iconSmallGew:staticUrl + "/candle/icon_smallGew.png",
        };
    } else if (appname == "com.chat.langlive.face.ins") {
        /* 烛光*/
        resourceObj = {
            btnTextColor: "#fff",
            fireColor: "#FD58A7",
            bgColor: "#fec2ff",
            langBgColor: "#fff",
            textColor: "#E74EE7",
            themeColor: "#E74EE7", // 主题色
            bgImg: staticUrl + "/joyColor/invite_bg.jpg",
            bgEnImg: staticUrl + "/joyColor/invite_bg_en.jpg",
            hasBuyIcon: staticUrl + "/joyColor/has_buy_icon.png",
            iconBigFire: staticUrl + "/joyColor/icon_bigFire.png",
            dewImg: staticUrl + "/joyColor/icon_dew.png",
            fireImg: staticUrl + "/joyColor/icon_fire.png",
            gewImg: staticUrl + "/joyColor/icon_gew.png",
            inviteBg: staticUrl + "/joyColor/invite_bg.png",
            inviteBgEn: staticUrl + "/joyColor/invite_bg_en.png",
            lastImg: staticUrl + "/joyColor/last.png",
            loadLogo: staticUrl + "/joyColor/load_logo.png",
            logo: staticUrl + "/joyColor/logo.png",
            noData: staticUrl + "/joyColor/no_data.png",
            step1: staticUrl + "/joyColor/step1.png",
            step1En: staticUrl + "/joyColor/step1_en.png",
            step2: staticUrl + "/joyColor/step2.png",
            step2En: staticUrl + "/joyColor/step2_en.png",
            step3: staticUrl + "/joyColor/step3.png",
            step3En: staticUrl + "/joyColor/step3_en.png",
            vipImg: staticUrl + "/joyColor/vip.png",
            svipImg: staticUrl + "/joyColor/svip.png",
            vipBg1Cn: staticUrl + "/joyColor/vip_bg1_cn.png",
            vipBg1En: staticUrl + "/joyColor/vip_bg1_en.png",
            vipBg2Cn: staticUrl + "/joyColor/vip_bg2_cn.png",
            vipBg2En: staticUrl + "/joyColor/vip_bg2_en.png",
            noLogo: staticUrl + "/joyColor/no_data.png",
            caseBg1: staticUrl + "/joyColor/case_bg1.png",
            caseBg2: staticUrl + "/joyColor/case_bg2.png",
            headLogo: staticUrl + "/joyColor/head_logo.png",
            iconCorrect: staticUrl + "/joyColor/icon_correct.png",
            checkColorBg: staticUrl + "/joyColor/check_color_bg.png",
            multipleGew: staticUrl + "/joyColor/multipleGew.png",
            iconBox: staticUrl + "/joyColor/icon_box.png",
            rewardHeadChImg: staticUrl + "/joyColor/reward_head.png",
            rewardHeadENImg: staticUrl + "/joyColor/reward_head_en.png",
            rewaRdrulesCh1Img: staticUrl + "/joyColor/rewaRdrules-ch1.png",
            rewaRdrulesCh2Img: staticUrl + "/joyColor/rewaRdrules-ch2.png",
            rewaRdrulesEn1Img: staticUrl + "/joyColor/rewaRdrules-en1.png",
            rewaRdrulesEn2Img: staticUrl + "/joyColor/rewaRdrules-en2.png",
            rewardBgColor: '#fee0fe',
            rewardIcon: staticUrl + "/joyColor/reward-icon.png",
            gewBigImg:staticUrl + "/joyColor/icon_bigGew.png",
            iconSmallGew:staticUrl + "/joyColor/icon_smallGew.png",
        };
    } else {
        resourceObj = {
            // 默认是fusi和firefly
            btnTextColor: "#000",
            fireColor: "#00be6b",
            bgColor: "#01d9e0",
            langBgColor: "#95EAF9",
            textColor: "#01D9E0",
            themeColor: "#01d9e0", // 主题色
            bgImg: staticUrl + "/fusi/invite_bg.jpg",
            bgEnImg: staticUrl + "/fusi/invite_bg_en.jpg",
            hasBuyIcon: staticUrl + "/fusi/has_buy_icon.png",
            iconBigFire: staticUrl + "/fusi/icon_bigFire.png",
            dewImg: staticUrl + "/fusi/icon_dew.png",
            fireImg: staticUrl + "/fusi/icon_fire.png",
            gewImg: staticUrl + "/fusi/icon_gew.png",
            inviteBg: staticUrl + "/fusi/invite_bg.png",
            inviteBgEn: staticUrl + "/fusi/invite_bg_en.png",
            lastImg: staticUrl + "/fusi/last.png",
            loadLogo: staticUrl + "/fusi/load_logo.png",
            logo: staticUrl + "/fusi/logo.png",
            noData: staticUrl + "/fusi/no_data.png",
            step1: staticUrl + "/fusi/step1.png",
            step1En: staticUrl + "/fusi/step1_en.png",
            step2: staticUrl + "/fusi/step2.png",
            step2En: staticUrl + "/fusi/step2_en.png",
            step3: staticUrl + "/fusi/step3.png",
            step3En: staticUrl + "/fusi/step3_en.png",
            vipImg: staticUrl + "/fusi/vip.png",
            svipImg: staticUrl + "/fusi/svip.png",
            vipBg1Cn: staticUrl + "/fusi/vip_bg1_cn.png",
            vipBg1En: staticUrl + "/fusi/vip_bg1_en.png",
            vipBg2Cn: staticUrl + "/fusi/vip_bg2_cn.png",
            vipBg2En: staticUrl + "/fusi/vip_bg2_en.png",
            noLogo: staticUrl + "/fusi/no_data.png",
            caseBg1: staticUrl + "/fusi/case_bg1.png",
            caseBg2: staticUrl + "/fusi/case_bg2.png",
            headLogo: staticUrl + "/fusi/head_logo.png",
            iconCorrect: staticUrl + "/fusi/icon_correct.png",
            checkColorBg: staticUrl + "/fusi/check_color_bg.png",
            multipleGew: staticUrl + "/fusi/multipleGew.png",
            iconBox: staticUrl + "/fusi/icon_box.png",
            rewardHeadChImg: staticUrl + "/fusi/reward_head.png",
            rewardHeadENImg: staticUrl + "/fusi/reward_head_en.png",
            rewaRdrulesCh1Img: staticUrl + "/fusi/rewaRdrules-ch1.jpg",
            rewaRdrulesCh2Img: staticUrl + "/fusi/rewaRdrules-ch2.jpg",
            rewaRdrulesEn1Img: staticUrl + "/fusi/rewaRdrules-en1.jpg",
            rewaRdrulesEn2Img: staticUrl + "/fusi/rewaRdrules-en2.jpg",
            rewardBgColor: '#e3ffff',
            rewardIcon: staticUrl + "/fusi/reward-icon.png",
            gewBigImg:staticUrl + "/fusi/icon_bigGew.png",
            iconSmallGew:staticUrl + "/fusi/icon_smallGew.png",
        };
    }
    return resourceObj;
}