Files
eparty-h5/view/eparty/common/js/common2.js

1337 lines
54 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const productUrl = 'https://api.epartylive.com'; // 正式环境
const testUrl = 'http://beta.api.epartylive.com'; // 测试环境
function render(templateId, templateData, target) {
var html = template(templateId, templateData);
target.innerHTML += html;
}
var tranUrl = 'https://api.epartylive.com';
var rotateLeft = function (lValue, iShiftBits) {
return (lValue << iShiftBits) | (lValue >>> (32 - iShiftBits));
}
var addUnsigned = function (lX, lY) {
var lX4, lY4, lX8, lY8, lResult;
lX8 = (lX & 0x80000000);
lY8 = (lY & 0x80000000);
lX4 = (lX & 0x40000000);
lY4 = (lY & 0x40000000);
lResult = (lX & 0x3FFFFFFF) + (lY & 0x3FFFFFFF);
if (lX4 & lY4) return (lResult ^ 0x80000000 ^ lX8 ^ lY8);
if (lX4 | lY4) {
if (lResult & 0x40000000) return (lResult ^ 0xC0000000 ^ lX8 ^ lY8);
else return (lResult ^ 0x40000000 ^ lX8 ^ lY8);
} else {
return (lResult ^ lX8 ^ lY8);
}
}
var F = function (x, y, z) {
return (x & y) | ((~x) & z);
}
var G = function (x, y, z) {
return (x & z) | (y & (~z));
}
var H = function (x, y, z) {
return (x ^ y ^ z);
}
var I = function (x, y, z) {
return (y ^ (x | (~z)));
}
var FF = function (a, b, c, d, x, s, ac) {
a = addUnsigned(a, addUnsigned(addUnsigned(F(b, c, d), x), ac));
return addUnsigned(rotateLeft(a, s), b);
};
var GG = function (a, b, c, d, x, s, ac) {
a = addUnsigned(a, addUnsigned(addUnsigned(G(b, c, d), x), ac));
return addUnsigned(rotateLeft(a, s), b);
};
var HH = function (a, b, c, d, x, s, ac) {
a = addUnsigned(a, addUnsigned(addUnsigned(H(b, c, d), x), ac));
return addUnsigned(rotateLeft(a, s), b);
};
var II = function (a, b, c, d, x, s, ac) {
a = addUnsigned(a, addUnsigned(addUnsigned(I(b, c, d), x), ac));
return addUnsigned(rotateLeft(a, s), b);
};
var convertToWordArray = function (string) {
var lWordCount;
var lMessageLength = string.length;
var lNumberOfWordsTempOne = lMessageLength + 8;
var lNumberOfWordsTempTwo = (lNumberOfWordsTempOne - (lNumberOfWordsTempOne % 64)) / 64;
var lNumberOfWords = (lNumberOfWordsTempTwo + 1) * 16;
var lWordArray = Array(lNumberOfWords - 1);
var lBytePosition = 0;
var lByteCount = 0;
while (lByteCount < lMessageLength) {
lWordCount = (lByteCount - (lByteCount % 4)) / 4;
lBytePosition = (lByteCount % 4) * 8;
lWordArray[lWordCount] = (lWordArray[lWordCount] | (string.charCodeAt(lByteCount) << lBytePosition));
lByteCount++;
}
lWordCount = (lByteCount - (lByteCount % 4)) / 4;
lBytePosition = (lByteCount % 4) * 8;
lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80 << lBytePosition);
lWordArray[lNumberOfWords - 2] = lMessageLength << 3;
lWordArray[lNumberOfWords - 1] = lMessageLength >>> 29;
return lWordArray;
};
var wordToHex = function (lValue) {
var WordToHexValue = "", WordToHexValueTemp = "", lByte, lCount;
for (lCount = 0; lCount <= 3; lCount++) {
lByte = (lValue >>> (lCount * 8)) & 255;
WordToHexValueTemp = "0" + lByte.toString(16);
WordToHexValue = WordToHexValue + WordToHexValueTemp.substr(WordToHexValueTemp.length - 2, 2);
}
return WordToHexValue;
};
var uTF8Encode = function (string) {
string = string.replace(/\x0d\x0a/g, "\x0a");
var output = "";
for (var n = 0; n < string.length; n++) {
var c = string.charCodeAt(n);
if (c < 128) {
output += String.fromCharCode(c);
} else if ((c > 127) && (c < 2048)) {
output += String.fromCharCode((c >> 6) | 192);
output += String.fromCharCode((c & 63) | 128);
} else {
output += String.fromCharCode((c >> 12) | 224);
output += String.fromCharCode(((c >> 6) & 63) | 128);
output += String.fromCharCode((c & 63) | 128);
}
}
return output;
};
$.extend({
md5: function (string) {
var x = Array();
var k, AA, BB, CC, DD, a, b, c, d;
var S11 = 7, S12 = 12, S13 = 17, S14 = 22;
var S21 = 5, S22 = 9, S23 = 14, S24 = 20;
var S31 = 4, S32 = 11, S33 = 16, S34 = 23;
var S41 = 6, S42 = 10, S43 = 15, S44 = 21;
string = uTF8Encode(string);
x = convertToWordArray(string);
a = 0x67452301; b = 0xEFCDAB89; c = 0x98BADCFE; d = 0x10325476;
for (k = 0; k < x.length; k += 16) {
AA = a; BB = b; CC = c; DD = d;
a = FF(a, b, c, d, x[k + 0], S11, 0xD76AA478);
d = FF(d, a, b, c, x[k + 1], S12, 0xE8C7B756);
c = FF(c, d, a, b, x[k + 2], S13, 0x242070DB);
b = FF(b, c, d, a, x[k + 3], S14, 0xC1BDCEEE);
a = FF(a, b, c, d, x[k + 4], S11, 0xF57C0FAF);
d = FF(d, a, b, c, x[k + 5], S12, 0x4787C62A);
c = FF(c, d, a, b, x[k + 6], S13, 0xA8304613);
b = FF(b, c, d, a, x[k + 7], S14, 0xFD469501);
a = FF(a, b, c, d, x[k + 8], S11, 0x698098D8);
d = FF(d, a, b, c, x[k + 9], S12, 0x8B44F7AF);
c = FF(c, d, a, b, x[k + 10], S13, 0xFFFF5BB1);
b = FF(b, c, d, a, x[k + 11], S14, 0x895CD7BE);
a = FF(a, b, c, d, x[k + 12], S11, 0x6B901122);
d = FF(d, a, b, c, x[k + 13], S12, 0xFD987193);
c = FF(c, d, a, b, x[k + 14], S13, 0xA679438E);
b = FF(b, c, d, a, x[k + 15], S14, 0x49B40821);
a = GG(a, b, c, d, x[k + 1], S21, 0xF61E2562);
d = GG(d, a, b, c, x[k + 6], S22, 0xC040B340);
c = GG(c, d, a, b, x[k + 11], S23, 0x265E5A51);
b = GG(b, c, d, a, x[k + 0], S24, 0xE9B6C7AA);
a = GG(a, b, c, d, x[k + 5], S21, 0xD62F105D);
d = GG(d, a, b, c, x[k + 10], S22, 0x2441453);
c = GG(c, d, a, b, x[k + 15], S23, 0xD8A1E681);
b = GG(b, c, d, a, x[k + 4], S24, 0xE7D3FBC8);
a = GG(a, b, c, d, x[k + 9], S21, 0x21E1CDE6);
d = GG(d, a, b, c, x[k + 14], S22, 0xC33707D6);
c = GG(c, d, a, b, x[k + 3], S23, 0xF4D50D87);
b = GG(b, c, d, a, x[k + 8], S24, 0x455A14ED);
a = GG(a, b, c, d, x[k + 13], S21, 0xA9E3E905);
d = GG(d, a, b, c, x[k + 2], S22, 0xFCEFA3F8);
c = GG(c, d, a, b, x[k + 7], S23, 0x676F02D9);
b = GG(b, c, d, a, x[k + 12], S24, 0x8D2A4C8A);
a = HH(a, b, c, d, x[k + 5], S31, 0xFFFA3942);
d = HH(d, a, b, c, x[k + 8], S32, 0x8771F681);
c = HH(c, d, a, b, x[k + 11], S33, 0x6D9D6122);
b = HH(b, c, d, a, x[k + 14], S34, 0xFDE5380C);
a = HH(a, b, c, d, x[k + 1], S31, 0xA4BEEA44);
d = HH(d, a, b, c, x[k + 4], S32, 0x4BDECFA9);
c = HH(c, d, a, b, x[k + 7], S33, 0xF6BB4B60);
b = HH(b, c, d, a, x[k + 10], S34, 0xBEBFBC70);
a = HH(a, b, c, d, x[k + 13], S31, 0x289B7EC6);
d = HH(d, a, b, c, x[k + 0], S32, 0xEAA127FA);
c = HH(c, d, a, b, x[k + 3], S33, 0xD4EF3085);
b = HH(b, c, d, a, x[k + 6], S34, 0x4881D05);
a = HH(a, b, c, d, x[k + 9], S31, 0xD9D4D039);
d = HH(d, a, b, c, x[k + 12], S32, 0xE6DB99E5);
c = HH(c, d, a, b, x[k + 15], S33, 0x1FA27CF8);
b = HH(b, c, d, a, x[k + 2], S34, 0xC4AC5665);
a = II(a, b, c, d, x[k + 0], S41, 0xF4292244);
d = II(d, a, b, c, x[k + 7], S42, 0x432AFF97);
c = II(c, d, a, b, x[k + 14], S43, 0xAB9423A7);
b = II(b, c, d, a, x[k + 5], S44, 0xFC93A039);
a = II(a, b, c, d, x[k + 12], S41, 0x655B59C3);
d = II(d, a, b, c, x[k + 3], S42, 0x8F0CCC92);
c = II(c, d, a, b, x[k + 10], S43, 0xFFEFF47D);
b = II(b, c, d, a, x[k + 1], S44, 0x85845DD1);
a = II(a, b, c, d, x[k + 8], S41, 0x6FA87E4F);
d = II(d, a, b, c, x[k + 15], S42, 0xFE2CE6E0);
c = II(c, d, a, b, x[k + 6], S43, 0xA3014314);
b = II(b, c, d, a, x[k + 13], S44, 0x4E0811A1);
a = II(a, b, c, d, x[k + 4], S41, 0xF7537E82);
d = II(d, a, b, c, x[k + 11], S42, 0xBD3AF235);
c = II(c, d, a, b, x[k + 2], S43, 0x2AD7D2BB);
b = II(b, c, d, a, x[k + 9], S44, 0xEB86D391);
a = addUnsigned(a, AA);
b = addUnsigned(b, BB);
c = addUnsigned(c, CC);
d = addUnsigned(d, DD);
}
var tempValue = wordToHex(a) + wordToHex(b) + wordToHex(c) + wordToHex(d);
return tempValue.toLowerCase();
}
});
function dateFormat(date, fmt) {
date = new Date(date);
var o = {
'M+': date.getMonth() + 1,
'd+': date.getDate(),
'h+': date.getHours(),
'm+': date.getMinutes(),
's+': date.getSeconds()
};
// 补全0
function padLeftZero(str) {
return ('00' + str).substr(str.length);
}
// 年份
if (/(y+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
}
// 月日时分秒
for (var k in o) {
if (new RegExp('(' + k + ')').test(fmt)) {
var str = o[k] + '';
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? str : padLeftZero(str));
}
}
date = o = padLeftZero = null;
return fmt;
}
function convert(_url) {
var patt = /\d+/;
var num = _url.match(patt);
var rs = {};
rs.uid = num[0];
return rs;
}
// 传递分享信息给客户端,showUrl为分享的页面链接,为空时表示不分享
// function shareInfo () {
// var _url = 'https://api.kawayisound.xyz/modules/bonus/fight.html';
// var res = EnvCheck();
// if (res == 'test'){
// _url = 'http://apibeta.kawayisound.xyz/modules/bonus/fight.html';
// }
// var info = {
// title: '轻寻与你一起红',
// imgUrl: 'https://img.erbanyy.com/qingxunlogo-256.png',
// desc: '登录即送20红包每天还有分享红包邀请红包分成红包四重红包大礼等你来拿',
// showUrl: _url
// };
// return JSON.stringify(info);
// }
// 根据域名适配环境
function EnvCheck() {
if (window.location.href) {
if (window.location.pathname.match(/payAr/)) {
pubInfo['Accept-Language'] = "ar";
}
var _url = window.location.host;
var res = _url.match(/uat/);
var res1 = _url.match(/120.79.211.243/);
var res2 = _url.match(/192.168./)
var res3 = _url.match(/127.0/)
var res4 = _url.match(/beta/)
if (res || res1 || res2 || res3 || res4) {
return 'test';
} else {
return 'live';
}
}
}
// 根据域名判断 正式环境(含www)/测试环境(含beta), 并返回所需url前缀
// written by zxfxiong
function getUrlPrefix() {
console.log(window.location, '---------location')
const browser = checkVersion();
if (browser.app) {
console.log(window.location, '---------location')
if (window.location.hostname && window.location.protocol) {
let url = window.location.protocol + '//' + window.location.hostname
console.log(url, '-------url')
return url
} else {
if (!EnvCheck()) return undefined;
return EnvCheck() === 'live' ? productUrl : testUrl;
}
} else {
if (!EnvCheck()) return undefined;
return EnvCheck() === 'live' ? productUrl : testUrl;
}
}
// 根据域名判断是本地打开还是服务器打开
function locateJudge() {
if (window.location.href) {
var _url = window.location.href;
var res = _url.match(/test|localhost/);
if (res) {
return '/api';
} else {
return '';
}
}
}
// 获取地址栏参数
function getQueryString() {
var _url = location.search;
var theRequest = new Object();
if (_url.indexOf('?') != -1) {
var str = _url.substr(1);
strs = str.split('&');
for (var i in strs) {
theRequest[strs[i].split('=')[0]] = decodeURI(strs[i].split('=')[1]);
}
}
return theRequest;
}
// 判断浏览器内核,手机类型
function checkVersion() {
var u = navigator.userAgent,
app = navigator.appVersion;
return {
trident: u.indexOf('Trident') > -1, //IE内核
presto: u.indexOf('Presto') > -1, //opera内核
webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, //火狐内核
mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
android: u.indexOf('Android') > -1 || u.indexOf('Adr') > -1, //android终端
iPhone: u.indexOf('iPhone') > -1, //是否为iPhone或者QQHD浏览器
iPad: u.indexOf('iPad') > -1, //是否iPad
webApp: u.indexOf('Safari') > -1, //是否web应该程序没有头部与底部
weixin: u.indexOf('MicroMessenger') > -1, //是否微信
qq: u.match(/\sQQ/i) == " qq", //是否QQ
EParty: u.match('EParty'),
app: u.match('EParty') //是否在app内
};
}
// 图片预加载
function preloadImage(obj) {
console.log(obj)
var loadLength = 0,
newImages = [];
for (var i = 0; i < obj.imageArr.length; i++) {
newImages[i] = new Image();
newImages[i].src = obj.imageArr[i];
newImages[i].onload = newImages[i].onerror = function () {
loadLength++;
typeof obj.preloadPreFunc === 'function' && obj.preloadPreFunc(loadLength);
if (loadLength == obj.imageArr.length) {
typeof obj.doneFunc === 'function' && obj.doneFunc();
}
}
}
}
// 判断是否在App内
function isApp() {
var androidBol = false;
var osBol = false;
if (window.androidJsObj && typeof window.androidJsObj === 'object') {
androidBol = true;
}
if (window.webkit) {
console.log(window.webkit);
osBol = true;
}
return (androidBol || osBol);
}
function UrlSearch() {
var name, value;
var str = location.href;
var num = str.indexOf("?")
str = str.substr(num + 1);
var arr = str.split("&");
for (var i = 0; i < arr.length; i++) {
num = arr[i].indexOf("=");
if (num > 0) {
name = arr[i].substring(0, num);
value = arr[i].substr(num + 1);
this[name] = value;
}
}
return value;
}
function erbanMask(channel, tags, params) {
//此函数用于一般的轻寻底层面罩
var browser = checkVersion();
var env = EnvCheck();
// params = params? params:0;
var bol = $.isEmptyObject(params);
var keyId = "978cd79c98264f836450afda1228762e";
if (browser.ios) {
if (env == 'test') {
keyId = '33f560a83c9c40d465711c0038653ca0'
}
console.log('ios_linkedme_keyId:', keyId)
}
var jsonStr = '';
if (!bol) {
jsonStr = JSON.stringify(params);
}
if (!browser.app) {
$('#mask').css('display', 'flex');
var linkData = {
type: env,
channel: channel,
tags: tags,
// ios_custom_url: "https://itunes.apple.com/cn/app/id1252542069?mt=8",
params: jsonStr
};
linkedme.init(keyId, {
type: env
}, null);
linkedme.link(linkData, function (err, response) {
if (err) {
// 生成深度链接失败返回错误对象err
console.log('err:', err);
} else {
console.log(response);
$('#download a').attr("href", response.url);
$('.download a').attr('href', response.url);
}
}, false);
} else {
$('#mask').hide();
}
}
function wxConfig() {
var wxurl = encodeURIComponent(location.href.split('#')[0]);
var data = "url=" + wxurl;
console.log(data);
$.ajax({
type: 'GET',
url: '/wx/config',
data: data,
asyc: true,
success: function (data) {
if (data.code = 200) {
wx.config({
debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来若要查看传入的参数可以在pc端打开参数信息会通过log打出仅在pc端时才会打印。
appId: 'wx009d793f92c24eec', // 必填,公众号的唯一标识
timestamp: data.data.timestamp, // 必填,生成签名的时间戳
nonceStr: data.data.nonceStr, // 必填,生成签名的随机串
signature: data.data.signature, // 必填签名见附录1
jsApiList: data.data.jsApiList // 必填需要使用的JS接口列表所有JS接口列表见附录2
});
wx.error(function (res) {
console.log('config error,msg:' + res);
});
}
},
error: function (res) {
console.log('config error,msg:' + res);
}
})
}
function refreshWeb() {
window.location.href = window.location.href;
}
function shareInfo(urlMsg) {
if (urlMsg) {
var env = EnvCheck();
if (env == 'test') {
return 'http://apibeta.kawayisound.xyz/' + urlMsg;
} else {
return 'https://api.kawayisound.xyz/' + urlMsg;
}
}
}
function initNav(obj) {
if ($.isEmptyObject(obj)) {
return;
}
var browser = checkVersion();
console.log(browser);
if (browser.app) {
if (browser.ios) {
window.webkit.messageHandlers.initNav.postMessage(obj);
} else if (browser.android) {
var json = JSON.stringify(obj);
window.androidJsObj.initNav(json);
}
}
}
var tools = {
cookieUtils: {
set: function (key, val, time) {
var date = new Date();
var expiresDays = time;
date.setTime(date.getTime() + expiresDays * 24 * 3600 * 1000);
document.cookie = key + '=' + val + ';expires=' + date.toGMTString();
},
get: function (key) {
var getCookie = document.cookie.replace(/[ ]/g, "");
var arrCookie = getCookie.split(';');
var val;
for (var i = 0; i < arrCookie.length; i++) {
var arr = arrCookie[i].split('=');
if (key === arr[0]) {
val = arr[1];
break;
}
}
return val;
},
delete: function (key) {
var date = new Date();
date.setTime(date.getTime() - 10000);
document.cookie = key + "+v; expires =" + date.toGMTString();
}
},
nativeUtils: {
jumpAppointPage: function (type, val) {
// routerType 跳转名称
// routerVal 跳转需要传的参数
var browser = checkVersion();
var jumpObj = {};
jumpObj.routerType = routeTypeConstant[type];
if (val) {
jumpObj.routerVal = val;
}
if (browser.app) {
if (browser.ios) {
if (type.indexOf('_') > -1) {
window.webkit.messageHandlers.jumpAppointPage.postMessage(jumpObj);
} else {
if (val) {
window.webkit.messageHandlers.type.postMessage(val);
} else {
window.webkit.messageHandlers.type.postMessage(null);
}
}
} else if (browser.android) {
if (androidJsObj && typeof androidJsObj === 'object') {
if (type.indexOf('_') > -1) {
window.androidJsObj.jumpAppointPage(JSON.stringify(jumpObj));
} else {
if (val) {
window.androidJsObj.type(val);
} else {
window.androidJsObj.type();
}
}
}
}
}
},
getUid: function () {
var browser = checkVersion();
console.log(browser);
var val;
if (browser.app) {
if (browser.ios) {
val = tools.cookieUtils.get('uid');
} else if (browser.android) {
if (androidJsObj && typeof androidJsObj === 'object') {
val = parseInt(window.androidJsObj.getUid());
}
}
} else {
var locate = getQueryString();
if (!locate.uid && !locate.shareUid) {
val = 901189;
} else {
if (locate.shareUid) {
val = locate.shareUid;
} else {
val = locate.uid;
}
}
}
return val;
},
getTicket: function () {
var browser = checkVersion();
var val;
if (browser.app) {
if (browser.ios) {
val = window.webkit.messageHandlers.getTicket.postMessage(null);
} else if (browser.android) {
if (androidJsObj && typeof androidJsObj === 'object') {
val = window.androidJsObj.getTicket();
}
}
} else {
val = 'app外'
}
return val;
}
}
}
// 透明loading层
var $Loading = {
count: 0,
isFadeOut: false,
show: function () {
this.count++;
if ($('#loadingToast').length >= 1) {
if (this.isFadeOut) {
this.isFadeOut = false;
$('#loadingToast').stop(true).fadeTo(0, 1);
}
} else {
$('body').append('<div id="loadingToast" style="display: none; position: fixed; left: 0; top: 0; width: 100%; height: 100%; z-index: 9999;"></div>')
$('#loadingToast').fadeIn(100);
}
},
hide: function () {
this.count--;
if (this.count === 0) {
this.isFadeOut = true;
$('#loadingToast').fadeOut(200, function () {
$Loading.isFadeOut = false;
$(this).remove();
});
}
}
};
var requestBaseUrl = locateJudge();
// ajax
function request(type, option) {
return $.ajax({
type: type,
url: requestBaseUrl + option.url,
data: option.data,
headers: option.headers,
beforeSend: function (xhr) {
!option.isHideLoading && $Loading.show();
},
success: function (res, status, xhr) {
!option.isHideLoading && $Loading.hide();
typeof option.success === 'function' && option.success(res, status, xhr);
},
error: function (xhr, status, error) {
!option.isHideLoading && $Loading.hide();
typeof option.error === 'function' && option.error(xhr, status, error);
}
})
}
// ajax get
function getJSON(option) {
request('get', option)
}
// ajax post
function postJSON(option) {
request('post', option);
}
// 封装 获取公共参数的方法(客户端提供)
// written by zxfxiong
const methodsFromClient = {
// 注意ios 提供的方法属异步操作
"uid": {
android: () => window.androidJsObj.getUid(),
ios: function () {
window.webkit.messageHandlers.getUid.postMessage(null);
// let allcookies = document.cookie;
// let $uid = allcookies.match(/\d+/);
// console.log($uid[0]);
}
},
"ticket": {
android: () => window.androidJsObj.getTicket(),
ios: function () {
window.webkit.messageHandlers.getTicket.postMessage(null);
}
},
"roomUid": {
android: () => window.androidJsObj.getRoomUid(),
ios: function () {
window.webkit.messageHandlers.getRoomUid.postMessage(null);
}
},
"deviceId": {
android: () => window.androidJsObj.getDeviceId(),
ios: function () {
window.webkit.messageHandlers.getDeviceId.postMessage(null);
}
},
"deviceInfo": {
android: () => window.androidJsObj.getDeviceInfo(),
ios: function () {
window.webkit.messageHandlers.getDeviceInfo.postMessage(null);
}
},
"encryptPwd": {
android: (data) => window.androidJsObj.encryptPwd(data),
ios: function (data) {
window.webkit.messageHandlers.encryptPwd.postMessage(data);
}
}
}
// 全局获取并配置公共参数
// written by zxfxiong
const pubInfo = {};
function getInfoFromClient() {
const browser = checkVersion();
if (browser.app) {
console.log('从客户端获取了用户信息设备信息此信息来源common2.js');
if (browser.android) {
pubInfo.uid = methodsFromClient.uid.android();
pubInfo.roomUid = methodsFromClient.roomUid.android();
pubInfo.ticket = methodsFromClient.ticket.android();
pubInfo.deviceId = methodsFromClient.deviceId.android();
pubInfo.deviceInfo = methodsFromClient.deviceInfo.android();
} else {
methodsFromClient.uid.ios();
methodsFromClient.roomUid.ios();
methodsFromClient.ticket.ios();
methodsFromClient.deviceId.ios();
methodsFromClient.deviceInfo.ios();
}
} else {
// 非app环境调试参数
pubInfo.uid = sessionStorage.getItem("uid") ? sessionStorage.getItem("uid") : '';
// pubInfo.ticket = sessionStorage.getItem("ticket") ? sessionStorage.getItem("ticket") : '';
pubInfo.h5_token = sessionStorage.getItem("ticket") ? sessionStorage.getItem("ticket") : '';
pubInfo.deviceId = "0";
pubInfo.deviceInfo = {
app: 'EParty',
appVersion: '9.9.9',
os: '0.0.0',
osVersion: '0.0.0',
channel: 'browser',
client: 'h5',
};
}
};
// 设定语言 fuzzy模糊查询客户端返回的语言
const languageMap = [
{ name: '简体中文', code: 'zh', fuzzy: ['zh', 'zh-Hans', 'zh-'] },
{ name: '繁体中文', code: 'zh', fuzzy: ['zh', 'zh-Hant', 'zh-'] },
{ name: '英语', code: 'en', fuzzy: ['en'] },
{ name: '阿拉伯语', code: 'ar', fuzzy: ['ar', 'ar-'] },
{ name: '印尼语', code: 'id', fuzzy: ['id', 'in', 'id-', 'in-'] },
{ name: '土耳其语', code: 'tr', fuzzy: ['tr', 'tr-'] },
{ name: '巴西语', code: 'pt', fuzzy: ['pt-BR', 'pt'] },
];
// 判断当前语言环境
function getLanguageCode(language) {
if (language) {
// language = language.toLowerCase();
for (const item of languageMap) {
// if (item.fuzzy.indexOf(language) !=-1) {
// return item.code;
// }
for (const list of item.fuzzy) {
if (language.indexOf(list) != -1) {
return item.code;
}
}
}
} else {
if (getQueryString().lang) {
return getQueryString().lang;
} else {
return 'en'; // 旧版本返回默认语言
}
}
}
// 判断国际化参数路径
function fuzzyMatchUpdateQueryStringParameterFun() {
const browser = checkVersion();
if (browser.app) {
if (browser.android) {
console.log('and deviceInfo', JSON.parse(pubInfo.deviceInfo));
let langCode = getLanguageCode(JSON.parse(pubInfo.deviceInfo)["Accept-Language"]);
pubInfo['Accept-Language'] = langCode;
history.replaceState(null, null, updateQueryStringParameter(window.location.href, 'lang', langCode));
// 初始化国际化
initLocalLang();
langCodeFun(langCode);
} else {
setTimeout(function () {
console.log('ios deviceInfo', pubInfo.deviceInfo);
if (pubInfo.deviceInfo) {
let langCode = getLanguageCode(pubInfo.deviceInfo["Accept-Language"]);
pubInfo['Accept-Language'] = langCode;
history.replaceState(null, null, updateQueryStringParameter(window.location.href, 'lang', langCode));
// 初始化国际化
initLocalLang();
langCodeFun(langCode);
} else {
fuzzyMatchUpdateQueryStringParameterFun();
langCodeFun(langCode);
}
}, 40)
// 初始化国际化
initLocalLang();
}
} else {
let langCode = getLanguageCode();
pubInfo['Accept-Language'] = langCode;
history.replaceState(null, null, updateQueryStringParameter(window.location.href, 'lang', langCode));
// 初始化国际化
initLocalLang();
langCodeFun(langCode);
}
}
function langCodeFun(langCode) {
// if (window.location.href.match(/guildAr/)) {
// return
// }
// var body = document.body;
// body.style.display = 'none';
// setTimeout(function () {
// body.style.display = 'block';
// }, 500)
if (langCode == "ar") {
document.documentElement.setAttribute("dir", "rtl");
document.body.classList.add('arabic');
} else if (langCode == "en") {
document.body.classList.add('english');
} else if (langCode == "tr") {
document.body.classList.add('Turkiye');
} else if (langCode == "zh") {
document.body.classList.add('china');
}else if (langCode == "pt") {
document.body.classList.add('brazil');
}
// if (window.location.href.match(/guildAr/)) {
// document.documentElement.setAttribute("dir", "ltr");
// }
}
// 获取整条url
function updateQueryStringParameter(uri, key, value) {
if (!value) {
return uri;
}
var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
var separator = uri.indexOf('?') !== -1 ? "&" : "?";
if (uri.match(re)) {
return uri.replace(re, '$1' + key + "=" + value + '$2');
}
else {
return uri + separator + key + "=" + value;
}
}
// 繁体字转换方法
// fontConvert(true);//调用字体转换函数
// setTimeout(function () {
fontConvert(true);//调用字体转换函数
// }, 1000)
function fontConvert(fontConvertBool) {
function SconvertT() {//简体转换繁体
document.head.innerHTML = s2t(document.head.innerHTML);
document.body.innerHTML = s2t(document.body.innerHTML);
// document.body.innerHTML
}
function TconvertS() {//繁体转换简体
document.head.innerHTML = t2s(document.head.innerHTML);
document.body.innerHTML = t2s(document.body.innerHTML);
}
if (fontConvertBool) {
SconvertT();//转换繁体字
} else {
TconvertS()//转换简体字
}
//功能:转换对象,使用递归,逐层剥到文本;
function transformContent(switcherId, fobj) {
if (typeof (fobj) == "object") {
var obj = fobj.childNodes
} else {
if (parseInt(fobj) != 0) { //在页面初始化时控制不更新当前页面语言状态;
var switcherObj = document.getElementById(switcherId);
with (switcherObj) {
if (parseInt(isCurrentFt)) {
innerHTML = innerHTML.replace('简', '繁')
title = title.replace('简', '繁')
} else {
innerHTML = innerHTML.replace('繁', '简')
title = title.replace('繁', '简')
}
}
switcherObj.innerHTML = transformText(switcherObj.innerHTML, isCurrentFt)
switcherObj.title = transformText(switcherObj.title, isCurrentFt)
if (isCurrentFt == "1") { isCurrentFt = "0" } else { isCurrentFt = "1" }
writeCookie("isCurrentFt", isCurrentFt)
}
var obj = document.body.childNodes
}
for (var i = 0; i < obj.length; i++) {
var OO = obj.item(i)
if ("||BR|HR|TEXTAREA|".indexOf("|" + OO.tagName + "|") > 0 || OO.id == switcherId) continue;
if (OO.title != "" && OO.title != null) OO.title = transformText(OO.title, isCurrentFt);
if (OO.alt != "" && OO.alt != null) OO.alt = transformText(OO.alt, isCurrentFt);
if (OO.tagName == "INPUT" && OO.value != "" && OO.type != "text" && OO.type != "hidden") OO.value = transformText(OO.value, isCurrentFt);
if (OO.nodeType == 3) { OO.data = transformText(OO.data, isCurrentFt) }
else transformContent(switcherId, OO)
}
}
//功能:转换指定字符串;
function transformText(txt, isFt) {
if (txt == null || txt == "") return ""
if (parseInt(isFt)) { return s2t(txt) } else { return t2s(txt) }
}
//功能:简体字符转为繁体字符;
function s2t(cc) {
var str = '', ss = jtpy(), tt = ftpy();
for (var i = 0; i < cc.length; i++) {
var c = cc.charAt(i);
if (c.charCodeAt(0) > 10000 && ss.indexOf(c) != -1) str += tt.charAt(ss.indexOf(c));
else str += c;
}
return str;
}
//功能:繁体字符转为简体字符;
function t2s(cc) {
var str = '', ss = jtpy(), tt = ftpy();
for (var i = 0; i < cc.length; i++) {
var c = cc.charAt(i);
if (c.charCodeAt(0) > 10000 && tt.indexOf(c) != -1) str += ss.charAt(tt.indexOf(c));
else str += c;
}
return str;
}
function jtpy() {
return '号隐爱的魔力之旅週金币榜皑蔼碍翱袄奥坝罢摆败颁办绊帮绑镑谤剥饱宝报鲍辈贝钡狈备惫绷笔毕毙闭边编贬变辩辫鼈瘪濒滨宾摈饼拨钵铂驳卜补参蚕残惭惨灿苍舱仓沧厕侧册测层诧搀掺蝉馋谗缠铲産阐颤场尝长偿肠厂畅钞车彻尘陈衬撑称惩诚骋痴迟驰耻齿炽冲虫宠畴踌筹绸丑橱厨锄雏础储触处传疮闯创锤纯绰辞词赐聪葱囱从丛凑窜错达带贷担单郸掸胆惮诞弹当挡党荡档捣岛祷导盗灯邓敌涤递缔点垫电淀钓调迭谍迭钉顶锭订东动栋冻斗犊独读赌镀锻断缎兑队对吨顿钝夺鹅额讹恶饿儿尔饵贰发罚阀珐矾钒烦范贩饭访纺飞废费纷坟奋愤粪丰枫锋风疯冯缝讽凤肤辐抚辅赋複负讣妇缚该钙盖干赶秆赣冈刚钢纲岗皋镐搁鸽阁铬个给龚宫巩贡鈎沟构购够蛊顾剐关观馆惯贯广规硅归龟闺轨诡柜贵刽辊滚锅国过骇韩汉阂鹤贺横轰鸿红后壶护沪户哗华画划话怀坏欢环还缓换唤痪焕涣黄谎挥辉毁贿秽会烩彙讳诲绘荤浑伙获货祸击机积饥讥鸡绩缉极辑级挤几蓟剂济计记际继纪夹荚颊贾钾价驾歼监坚笺间艰缄茧检碱硷拣捡简俭减荐槛鉴践贱见键舰剑饯渐溅涧浆蒋桨奖讲酱胶浇骄娇搅铰矫侥脚饺缴绞轿较秸阶节茎惊经颈静镜径痉竞淨纠厩旧驹举据锯惧剧鹃绢杰洁结诫届紧锦仅谨进晋烬尽劲荆觉决诀绝钧军骏开凯颗壳课垦恳抠库裤夸块侩宽矿旷况亏岿窥馈溃扩阔蜡腊莱来赖蓝栏拦篮阑兰澜谰揽览懒缆烂滥捞劳涝乐镭垒类泪篱离里鲤礼丽厉励砾曆沥隶俩联莲连镰怜涟帘敛脸链恋炼练粮凉两辆谅疗辽镣猎临邻鳞凛赁龄铃凌灵岭领馏刘龙聋咙笼垄拢陇楼娄搂篓芦卢颅庐炉掳卤虏鲁赂禄录陆驴吕铝侣屡缕虑滤绿峦挛孪滦乱抡轮伦仑沦纶论萝罗逻锣箩骡骆络妈玛码蚂马骂吗买麦卖迈脉瞒馒蛮满谩猫锚铆贸么霉没镁门闷们锰梦谜弥觅绵缅庙灭悯闽鸣铭谬谋亩钠纳难挠脑恼闹馁腻撵捻酿鸟聂齧镊镍柠狞甯拧泞钮纽脓浓农疟诺欧鸥殴呕沤盘庞国爱赔喷鹏骗飘频贫苹凭评泼颇扑铺朴谱脐齐骑岂啓气弃讫牵扦釺铅迁签谦钱钳潜浅谴堑枪呛牆蔷强抢锹桥乔侨翘窍窃钦亲轻氢倾顷请庆琼穷趋区躯驱龋颧权劝却鹊让饶扰绕热韧认纫荣绒软锐闰润洒萨鳃赛伞丧骚扫涩杀纱筛晒闪陝赡缮伤赏烧绍赊摄慑设绅审婶肾渗声绳胜圣师狮湿诗尸时蚀实识驶势释饰视试寿兽枢输书赎属术树竖数帅双谁税顺说硕烁丝饲耸怂颂讼诵擞苏诉肃虽绥岁孙损笋缩琐锁獭挞抬摊贪瘫滩坛谭谈歎汤烫涛縧腾誊锑题体屉条贴铁厅听烃铜统头图涂团颓蜕脱鸵驮驼椭洼袜弯湾顽万网韦违围爲潍维苇伟僞纬谓卫温闻纹稳问瓮挝蜗涡窝呜钨乌诬无芜吴坞雾务误锡牺袭习铣戏细虾辖峡侠狭厦锨鲜纤咸贤衔闲显险现献县馅羡宪线厢镶乡详响项萧销晓啸蝎协挟携胁谐写泻谢锌衅兴汹鏽绣虚嘘须许绪续轩悬选癣绚学勳询寻驯训讯逊压鸦鸭哑亚讶阉烟盐严顔阎豔厌砚彦谚验鸯杨扬疡阳痒养样瑶摇尧遥窑谣药爷页业叶医铱颐遗仪彝蚁艺亿忆义诣议谊译异绎荫阴银饮樱婴鹰应缨莹萤营荧蝇颖哟拥佣痈踊咏涌优忧邮铀犹游诱舆鱼渔娱与屿语吁御狱誉预驭鸳渊辕园员圆缘远愿约跃钥岳粤悦阅云郧匀陨运蕴酝晕韵杂灾载攒暂赞赃髒凿枣灶责择则泽贼赠扎札轧铡闸诈斋债毡盏斩辗崭栈战绽张涨帐账胀赵蛰辙锗这贞针侦诊镇阵挣睁狰帧郑证织职执纸挚掷帜质锺终种肿衆诌轴皱昼骤猪诸诛烛瞩嘱贮铸筑驻专砖转赚桩庄装妆壮状锥赘坠缀谆浊兹资渍踪综总纵邹诅组鑽緻钟么为隻凶准启闆裡雳馀鍊洩并';
}
function ftpy() {
return '號隱愛的魔力之旅週金幣榜皚藹礙翺襖奧壩罷擺敗頒辦絆幫綁鎊謗剝飽寶報鮑輩貝鋇狽備憊繃筆畢斃閉邊編貶變辯辮鼈癟瀕濱賓擯餅撥缽鉑駁蔔補參蠶殘慚慘燦蒼艙倉滄廁側冊測層詫攙摻蟬饞讒纏鏟産闡顫場嘗長償腸廠暢鈔車徹塵陳襯撐稱懲誠騁癡遲馳恥齒熾沖蟲寵疇躊籌綢醜櫥廚鋤雛礎儲觸處傳瘡闖創錘純綽辭詞賜聰蔥囪從叢湊竄錯達帶貸擔單鄲撣膽憚誕彈當擋黨蕩檔搗島禱導盜燈鄧敵滌遞締點墊電澱釣調疊諜疊釘頂錠訂東動棟凍鬥犢獨讀賭鍍鍛斷緞兌隊對噸頓鈍奪鵝額訛惡餓兒爾餌貳發罰閥琺礬釩煩範販飯訪紡飛廢費紛墳奮憤糞豐楓鋒風瘋馮縫諷鳳膚輻撫輔賦複負訃婦縛該鈣蓋幹趕稈贛岡剛鋼綱崗臯鎬擱鴿閣鉻個給龔宮鞏貢鈎溝構購夠蠱顧剮關觀館慣貫廣規矽歸龜閨軌詭櫃貴劊輥滾鍋國過駭韓漢閡鶴賀橫轟鴻紅後壺護滬戶嘩華畫劃話懷壞歡環還緩換喚瘓煥渙黃謊揮輝毀賄穢會燴彙諱誨繪葷渾夥獲貨禍擊機積饑譏雞績緝極輯級擠幾薊劑濟計記際繼紀夾莢頰賈鉀價駕殲監堅箋間艱緘繭檢堿鹼揀撿簡儉減薦檻鑒踐賤見鍵艦劍餞漸濺澗漿蔣槳獎講醬膠澆驕嬌攪鉸矯僥腳餃繳絞轎較稭階節莖驚經頸靜鏡徑痙競淨糾廄舊駒舉據鋸懼劇鵑絹傑潔結誡屆緊錦僅謹進晉燼盡勁荊覺決訣絕鈞軍駿開凱顆殼課墾懇摳庫褲誇塊儈寬礦曠況虧巋窺饋潰擴闊蠟臘萊來賴藍欄攔籃闌蘭瀾讕攬覽懶纜爛濫撈勞澇樂鐳壘類淚籬離裏鯉禮麗厲勵礫曆瀝隸倆聯蓮連鐮憐漣簾斂臉鏈戀煉練糧涼兩輛諒療遼鐐獵臨鄰鱗凜賃齡鈴淩靈嶺領餾劉龍聾嚨籠壟攏隴樓婁摟簍蘆盧顱廬爐擄鹵虜魯賂祿錄陸驢呂鋁侶屢縷慮濾綠巒攣孿灤亂掄輪倫侖淪綸論蘿羅邏鑼籮騾駱絡媽瑪碼螞馬罵嗎買麥賣邁脈瞞饅蠻滿謾貓錨鉚貿麼黴沒鎂門悶們錳夢謎彌覓綿緬廟滅憫閩鳴銘謬謀畝鈉納難撓腦惱鬧餒膩攆撚釀鳥聶齧鑷鎳檸獰寧擰濘鈕紐膿濃農瘧諾歐鷗毆嘔漚盤龐國愛賠噴鵬騙飄頻貧蘋憑評潑頗撲鋪樸譜臍齊騎豈啓氣棄訖牽扡釺鉛遷簽謙錢鉗潛淺譴塹槍嗆牆薔強搶鍬橋喬僑翹竅竊欽親輕氫傾頃請慶瓊窮趨區軀驅齲顴權勸卻鵲讓饒擾繞熱韌認紉榮絨軟銳閏潤灑薩鰓賽傘喪騷掃澀殺紗篩曬閃陝贍繕傷賞燒紹賒攝懾設紳審嬸腎滲聲繩勝聖師獅濕詩屍時蝕實識駛勢釋飾視試壽獸樞輸書贖屬術樹豎數帥雙誰稅順說碩爍絲飼聳慫頌訟誦擻蘇訴肅雖綏歲孫損筍縮瑣鎖獺撻擡攤貪癱灘壇譚談歎湯燙濤縧騰謄銻題體屜條貼鐵廳聽烴銅統頭圖塗團頹蛻脫鴕馱駝橢窪襪彎灣頑萬網韋違圍爲濰維葦偉僞緯謂衛溫聞紋穩問甕撾蝸渦窩嗚鎢烏誣無蕪吳塢霧務誤錫犧襲習銑戲細蝦轄峽俠狹廈鍁鮮纖鹹賢銜閑顯險現獻縣餡羨憲線廂鑲鄉詳響項蕭銷曉嘯蠍協挾攜脅諧寫瀉謝鋅釁興洶鏽繡虛噓須許緒續軒懸選癬絢學勳詢尋馴訓訊遜壓鴉鴨啞亞訝閹煙鹽嚴顔閻豔厭硯彥諺驗鴦楊揚瘍陽癢養樣瑤搖堯遙窯謠藥爺頁業葉醫銥頤遺儀彜蟻藝億憶義詣議誼譯異繹蔭陰銀飲櫻嬰鷹應纓瑩螢營熒蠅穎喲擁傭癰踴詠湧優憂郵鈾猶遊誘輿魚漁娛與嶼語籲禦獄譽預馭鴛淵轅園員圓緣遠願約躍鑰嶽粵悅閱雲鄖勻隕運蘊醞暈韻雜災載攢暫贊贓髒鑿棗竈責擇則澤賊贈紮劄軋鍘閘詐齋債氈盞斬輾嶄棧戰綻張漲帳賬脹趙蟄轍鍺這貞針偵診鎮陣掙睜猙幀鄭證織職執紙摯擲幟質鍾終種腫衆謅軸皺晝驟豬諸誅燭矚囑貯鑄築駐專磚轉賺樁莊裝妝壯狀錐贅墜綴諄濁茲資漬蹤綜總縱鄒詛組鑽緻鐘麼為隻兇準啟闆裡靂餘鍊洩並';
}
//功能:获取指定名称的 Cookie 值;
function readCookie(name) {
var value = "";
if (document.cookie.length > 0) {
var prefix = name + "=";
var begin = document.cookie.indexOf(prefix);
if (begin != -1) {
begin += prefix.length;
var end = document.cookie.indexOf(";", begin);
if (end == -1) end = document.cookie.length;
value = unescape(document.cookie.substring(begin, end));
}
}
return value;
}
//功能:设置指定名称的 Cookie 值;
function writeCookie(name, value, days) {
var argv = writeCookie.arguments;
var argc = writeCookie.arguments.length;
var days = (argc > 2) ? argv[2] : null;
if (days != null) {
var expireDate = new Date();
expireDate.setTime(expireDate.getTime() + (days * 1000 * 3600 * 24));
}
document.cookie = name + "=" + escape(value) + ((days == null) ? "" : ("; expires=" + expireDate.toGMTString())) + "; path=/";
}
var isCurrentFt;
//功能:页面初始化函数
// switcherId 文字链接,点击负责简繁切换,建议:<a id="switcher_link" href="#">繁体中文</a>
// isDefaultFt 当前文档默认是否为繁体中文;
// delay 页面加载后的转换延迟时间,单位毫秒;
// 使用的 Cookie 变量名称isCurrentFt
function initPageLanguage(switcherId, isDefaultFt, delay) {
isDefaultFt = isDefaultFt ? "1" : "0";
var switcherObj = document.getElementById(switcherId)
isCurrentFt = readCookie("isCurrentFt")
if (isCurrentFt == null || isCurrentFt == "") isCurrentFt = isDefaultFt
with (switcherObj) {
if (typeof (document.all) != "object") {//非IE浏览器
href = "javascript:transformContent('" + switcherId + "');"
} else {
href = "#";
onclick = new Function("transformContent('" + switcherId + "');return false;")
}
if (title == null || title == "") title = "点击以繁体中文方式浏览";
if (parseInt(isCurrentFt)) {
innerHTML = innerHTML.replace('繁', '简')
title = title.replace('繁', '简')
}
innerHTML = transformText(innerHTML, parseInt(isCurrentFt) ? 0 : 1)
title = transformText(title, parseInt(isCurrentFt) ? 0 : 1)
}
if (isCurrentFt != isDefaultFt) { setTimeout("transformContent('" + switcherId + "',0)", delay) }
}
// 初始化调用接口
//initPageLanguage("switcher_link", false, 50);
}
// 封装数值超过最大数位处理单位
function unitProcessing(val, num, toFixeds, text) { //值 以什么为单位 保留几位小数 单位后最w
return val >= num ? (Math.floor(val / 1000) / 10).toFixed(toFixeds) + text : val;
}
// 阿拉伯专用
function unitProcessingAr(val, toFixeds) { //值 保留几位小数
if (getQueryString().lang && getQueryString().lang == 'zh') {
return val >= 10000 ? (Math.floor(val / 1000) / 10).toFixed(toFixeds) + 'w' : val;
} else {
if (val < 1000) {
return val;
} else if (val >= 1000 && val < 1000000) {
return (val / 1000).toFixed(toFixeds) + 'K'
} else if (val >= 1000000) {
return (val / 1000000).toFixed(toFixeds) + 'M'
}
}
}
// 封装 在ios环境中 配置公共参数的回调函数
// 配合 methodsFromClient[infoName].ios 方法
// written by zxfxiong
function getMessage(key, value) {
pubInfo[key] = value;
}
function objToParam(a) {
var s = [],
rbracket = /\[\]$/,
isArray = function (obj) {
return Object.prototype.toString.call(obj) === '[object Array]';
},
add = function (k, v) {
v = typeof v === 'function' ? v() : v === null ? '' : v === undefined ? '' : v;
s[s.length] = encodeURIComponent(k) + '=' + encodeURIComponent(v);
},
buildParams = function (prefix, obj) {
var i, len, key;
if (prefix) {
if (isArray(obj)) {
for (i = 0, len = obj.length; i < len; i++) {
if (rbracket.test(prefix)) {
add(prefix, obj[i]);
} else {
buildParams(prefix + '[' + (typeof obj[i] === 'object' ? i : '') + ']', obj[i]);
}
}
} else if (obj && String(obj) === '[object Object]') {
for (key in obj) {
buildParams(prefix + '[' + key + ']', obj[key]);
}
} else {
add(prefix, obj);
}
} else if (isArray(obj)) {
for (i = 0, len = obj.length; i < len; i++) {
add(obj[i].name, obj[i].value);
}
} else {
for (key in obj) {
buildParams(key, obj[key]);
}
}
return s;
};
return buildParams('', a).join('&').replace(/%20/g, '+');
}
// 封装 jquery 请求
// written by zxfxiong
function networkRequest(reqObj = {}, type) {
// 关于reqObj内部参数与 调用原生$.ajax()时传参一致
// 调用该函数前:须保证事先调用了 getInfoFromClient()
if (typeof pubInfo.deviceInfo === 'string') {
pubInfo.deviceInfo = JSON.parse(pubInfo.deviceInfo);
};
var browser = checkVersion();
const pubHeader = {};
pubHeader.app = type != 'yinbaos' ? pubInfo.deviceInfo.app : 'yinbao'
pubHeader.appVersion = pubInfo.deviceInfo.appVersion || ''
pubHeader.os = pubInfo.deviceInfo.os || ''
pubHeader.osVersion = pubInfo.deviceInfo.osVersion || ''
pubHeader.channel = pubInfo.deviceInfo.channel || ''
pubHeader.deviceId = pubInfo.deviceInfo.deviceId || ''
pubHeader.client = 'h5'
pubHeader.pub_uid = window.location.pathname.match(/login.html/) ? 0 : pubInfo.uid
// pubHeader.pub_uid = 3838
pubHeader['Accept-Language'] = pubInfo['Accept-Language']
if (browser.app) {//true
pubHeader.pub_ticket = pubInfo.ticket
} else {
pubHeader.h5_token = sessionStorage.getItem("ticket") ? sessionStorage.getItem("ticket") : '';
if(window.location.pathname.indexOf('h5Income') == -1){
pubHeader.pub_ticket = sessionStorage.getItem("ticket") ? sessionStorage.getItem("ticket") : '';
}
}
const url = reqObj.url;
const commParams = objToParam(pubHeader);
if (url.indexOf('?') >= 0) {
reqObj.url = `${url}&${commParams}`
} else {
reqObj.url = `${url}?${commParams}`
}
if (!reqObj.headers || typeof reqObj.headers !== 'object') {
reqObj.headers = {};
};
Object.assign(reqObj.headers, pubHeader);
const response = $.ajax(reqObj);
return response;
}
function objectToQueryString(obj) {
console.log(obj);
if (JSON.stringify(obj) == "{}") {
var str = 'key=rpbs6us1m8r2j9g6u06ff2bo18orwaya'
} else {
var str = Object.keys(obj)
.sort()
.map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`)
.join('&');
str += '&key=rpbs6us1m8r2j9g6u06ff2bo18orwaya'
}
console.log("str", str);
md5Value = $.md5(str)
return md5Value
}
// 控制body是否可以滑动
function bodyScroolFun(bool) {
if (bool) {
$('body').css('overflow', 'hidden');
} else {
$('body').css('overflow', 'auto');
}
}
function rewardTypeFun(type) {
if (type == "HEADWEAR") {
return { name: "頭飾", unit: '天' };
} else if (type == "NAMEPLATE") {
return { name: "銘牌", unit: '天' };
} else if (type == "CHATBUBBLE") {
return { name: "氣泡", unit: '天' };
} else if (type == "INFOCARD") {
return { name: "資料卡", unit: '天' };
} else if (type == "CAR") {
return { name: "座駕", unit: '天' };
} else if (type == "GIFT") {
return { name: "禮物", unit: '個' };
} else if (type == "DIAMOND") {
return { name: "鉆石", unit: '個' };
} else if (type == "GOLD") {
return { name: "金幣", unit: '個' };
} else if (type == "EMPTY") {
return { name: nick, unit: '個' };
}
}
function rewardTypeNumFun(num) {
if (getQueryString().lang == 'zh') {
if (num == 1) {
return { name: "金幣", unit: '個' };
}
else if (num == 2) {
return { name: "禮物", unit: '個' };
}
else if (num == 3) {
return { name: "座駕", unit: '天' };
}
else if (num == 4) {
return { name: "頭飾", unit: '天' };
}
else if (num == 5) {
return { name: "背景", unit: '天' };
}
else if (num == 6) {
return { name: "實物", unit: '個' };
}
else if (num == 7) {
return { name: "靚號", unit: '天' };
}
else if (num == 8) {
return { name: "全麥禮物", unit: '個' };
}
else if (num == 9) {
return { name: "隨機靚號", unit: '天' };
}
else if (num == 10) {
return { name: "錘子", unit: '個' };
}
else if (num == 13) {
return { name: "祝福語", unit: '天' };
}
else if (num == 14) {
return { name: "銘牌", unit: '天' };
}
else if (num == 15) {
return { name: "虛擬貨幣", unit: '個' };
}
else if (num == 16) {
return { name: "聊天氣泡", unit: '天' };
}
else if (num == 17) {
return { name: "資料卡", unit: '天' };
}
else {
return { name: "null", unit: 'null' };
}
} else if (getQueryString().lang == 'en') {
if (num == 1) {
return { name: "Coins", unit: 'pcs' };
}
else if (num == 2) {
return { name: "Gift", unit: 'pcs' };
}
else if (num == 3) {
return { name: "Vehicle", unit: 'days' };
}
else if (num == 4) {
return { name: "Headgear", unit: 'days' };
}
else if (num == 5) {
return { name: "Background", unit: 'days' };
}
else if (num == 6) {
return { name: "Physical item", unit: 'pcs' };
}
else if (num == 7) {
return { name: "VIP number", unit: 'days' };
}
else if (num == 8) {
return { name: "Whole wheat gift", unit: 'pcs' };
}
else if (num == 9) {
return { name: "Random VIP number", unit: 'days' };
}
else if (num == 10) {
return { name: "Hammer", unit: 'pcs' };
}
else if (num == 13) {
return { name: "Blessing", unit: 'days' };
}
else if (num == 14) {
return { name: "Nameplate", unit: 'days' };
}
else if (num == 15) {
return { name: "Virtual currency", unit: 'pcs' };
}
else if (num == 16) {
return { name: "Chat bubble", unit: 'days' };
}
else if (num == 17) {
return { name: "Profile card", unit: 'days' };
}
else {
return { name: "null", unit: 'null' };
}
} else {
if (num == 1) {
return { name: "القطع النقدية", unit: 'قطعة' };
}
else if (num == 2) {
return { name: "الهدايا", unit: 'قطعة' };
}
else if (num == 3) {
return { name: "المركبة", unit: 'يوم' };
}
else if (num == 4) {
return { name: "القبعة", unit: 'يوم' };
}
else if (num == 5) {
return { name: "الخلفية", unit: 'يوم' };
}
else if (num == 6) {
return { name: "العنصر الفعلي", unit: 'قطعة' };
}
else if (num == 7) {
return { name: "الرقم المميز", unit: 'يوم' };
}
else if (num == 8) {
return { name: "الهدايا الكاملة القمح", unit: 'قطعة' };
}
else if (num == 9) {
return { name: "رقم عشوائي مميز", unit: 'يوم' };
}
else if (num == 10) {
return { name: "مطرقة", unit: 'قطعة' };
}
else if (num == 13) {
return { name: "التبريكات", unit: 'يوم' };
}
else if (num == 14) {
return { name: "لوحة الاسم", unit: 'يوم' };
}
else if (num == 15) {
return { name: "العملة الافتراضية", unit: 'قطعة' };
}
else if (num == 16) {
return { name: "فقاعة الدردشة", unit: 'يوم' };
}
else if (num == 17) {
return { name: "بطاقة الملف الشخصي", unit: 'يوم' };
}
else {
return { name: "null", unit: 'null' };
}
}
}