提交 a1ac0ac4 作者: 王进

提交sdk第一版

上级 d7dc6096
/**
* SDK版本: v1.0
* @author: 推广技术部
* @copyright: 上海鲸团科技有限公司
* @日期: 2018-10-10
*/
var SDKConfig = {
appid: '1106966663',
sdk_domain: 'https://account.jinsdk.com', // SDK接口域名
pay_domain: 'https://pay.jinsdk.com', // 支付接口域名
report_domain: 'https://s.jinsdk.com/qqxyx/api.php', // 数据上报接口域名
ProductCode: "47bf7b2b6f3bba55f5a8a3bafac102a2",
product: '石器文明', // 产品名称
}
var whaleSDK = {
userInfo: {},
sdkStatus: {
initReady: false, // 初始化完成
loginReady: false, // 登录完成
},
// 初始化SDK
init: function (callback) {
var _selt = this;
// 配置公共参数
_selt.ReportParams.extArgs = this.getQueryString("ext_args") ? decodeURI(this.getQueryString("ext_args")) : "";
_selt.ReportParams.fromOpenId = _selt.getQueryString("fromOpenId") || "";
_selt.ReportParams.clickId = _selt.getQueryString("qz_gdt") || "";
_selt.sdkParams.product_code = _selt.ReportParams.productCode = SDKConfig.ProductCode;
if (_selt.ReportParams.fromOpenId != '') _selt.ReportParams.extArgs = 'share';
//发起登录
this.login(function (isLogin) {
if (isLogin) {
_selt.sdkStatus.initReady = true;
callback(true);
return;
}
callback(false);
});
// 获取设备信息
try {
mqq.invoke("device", "getDeviceInfo",
function (evt) {
console.log("@@SDK::getDeviceInfo", evt);
var device = evt.data;
var identifier = device.identifier ? device.identifier : ""; // 设备唯一标识
var model = device.modelVersion ? device.modelVersion : ""; // 机型
var osVerson = device.systemVersion ? device.systemVersion : ""; // 系统版本
_selt.sdkParams.uniqueid = _selt.ReportParams.identifier = _selt.userInfo.identifier = identifier;
_selt.ReportParams.modelVersion = _selt.userInfo.modelVersion = model;
}
);
} catch (error) {
console.log("@SDK::getDeviceInfo Error", error);
}
},
// 设置屏幕常亮
screenOpen: function () {
try {
mqq.device.setScreenStatus({
status: 1
}, function () { });
} catch (error) {
console.log("@@SDK::setScreenStatus Error", error)
}
},
login: function (callback) {
var _selt = this;
//异步方式获取登录态
window.getOpenKey(function (d) {
_selt.userInfo.username = _selt.userInfo.account = _selt.ReportParams.openId = window.OPEN_DATA.openid;
_selt.userInfo.pf = window.OPEN_DATA.pf;
_selt.sdkParams.os = _selt.getOsType();
_selt.sdkParams.pf = window.OPEN_DATA.pf || "";
_selt.sdkParams.appid = SDKConfig.appid;
_selt.sdkParams.open_id = window.OPEN_DATA.openid || "";
_selt.sdkParams.openkey = window.OPEN_DATA.openkey || "";
_selt.sdkParams.loginType = window.OPEN_DATA.loginType || "";
_selt.sdkParams.via = window.OPEN_DATA.via || "";
_selt.sdkParams.equipmentos = window.OPEN_DATA.os || "";
_selt.sdkParams.equipmentname = window.OPEN_DATA.app || "";
_selt.sdkParams.version = window.OPEN_DATA.version || "";
_selt.sdkParams.subVersion = window.OPEN_DATA.subVersion || "";
_selt.sdkParams.appType = window.OPEN_DATA.appType || "";
_selt.sdkParams.source = ('QZONE-' + _selt.sdkParams.loginType).toUpperCase();
// SDK激活
_selt.sdkRequest(Links.active, _selt.sdkParams, function (data) {
if (data && data.code == 0) {
_selt.sdkParams.pay_channel = data.data.default_pay_channel;
_selt.reportData("activation"); // 上报激活
callback(true);
} else {
console.log("@@SDK接口错误::", data.msg);
}
});
});
//发起SDK登录
this.addStatusListen('initReady', function () {
_selt.doLogin();
});
},
doLogin: function () {
var _selt = this;
_selt.sdkRequest(Links.login, _selt.sdkParams, function (data) {
if (data && data.code == 0) {
_selt.sdkParams.token = data.data.token; // 记录用户toekn
_selt.userInfo.uid = _selt.ReportParams.userId = data.data.uid; // 记录用户ID
_selt.sdkStatus.loginReady = true;
} else {
console.log("@@SDK接口错误::", data.msg);
}
});
},
getuser: function () {
this.addStatusListen('loginReady', function () {
_selt.userInfo.ostype = _selt.getOsType();
return _selt.userInfo;
});
},
addStatusListen: function (type, callback) {
var _selt = this;
var val = 0;
if (_selt.sdkStatus[type]) {
callback();
} else {
Object.defineProperty(_selt.sdkStatus, type, {
enumerable: true,
configurable: true,
get: function getter() { return val; },
set: function setter(newVal) {
//如果新设置的值跟之前的值是相等的,则不需要
if (newVal === val) { return; }
callback();
}
})
}
},
addShortcut: function (info) {
try {
// 显示收藏桌面快捷方式的浮点图标或功能按钮
window.mqq.invoke("ui", "setOnAddShortcutHandler", {
"callback": mqq.callback(function () {
mqq.ui.addShortcut({
action: "web",
title: info.title ? "单机游戏" : info.title,
icon: info.icon ? window.OPEN_DATA.appicon : info.icon,
url: window.OPEN_DATA.jumpurl,
callback: function (ret) {
console.log(ret);
}
});
}, false, true)
});
} catch (error) {
console.log("@@SDK错误::addShortcut", error);
}
},
share: function (info) {
try {
// 设置web页面分享的监听事件
mqq.invoke("ui", "setOnShareHandler", function (type) {
mqq.invoke("ui", "shareMessage", {
title: info.title ? "石器文明" : info.title,
desc: info.desc ? "经典玩法,登录即送VIP3" : info.desc,
share_type: type,
share_url: window.OPEN_DATA.shareurl,
image_url: info.icon ? window.OPEN_DATA.appicon : info.icon,
back: true
}, function (result) {
if (result && result.retCode == 0) {
alert("分享成功");
} else {
alert("分享取消");
}
});
});
//拉起分享菜单
mqq.ui.showShareMenu();
} catch (error) {
console.log("@@SDK错误::share", error);
}
},
//上报注册
reportRegister: function (callback) {
this.reportData("register");
try {
window.reportRegister();
} catch (error) {
console.log("@@QQ上报注册失败::", error);
}
if (callback) callback(true);
},
//上报登录
reportLogin: function (callback) {
this.reportData("login");
try {
window.reportLogin();
} catch (error) {
console.log("@@QQ上报登录失败::", error);
}
if (callback) callback(true);
},
//上报创角
createRole: function (roleInfo, callback) {
this.reportData("createRole", roleInfo);
if (callback) callback(true);
},
reportData: function (type, data) {
var _selt = this;
if (!this.sdkStatus.initReady) {
return console.log("@@初始化SDK失败");
}
try {
var postData = _selt.ReportParams;
postData.action = type;
postData.openId = _selt.userInfo.uid;
postData.time = Date.parse(new Date()).toString().substr(0, 10);
if (type == 'createRole') {
postData.roleId = data.role_id;
postData.server_id = data.server_id;
postData.role_name = data.role_name;
postData.server_name = data.server_name;
}
console.log("@@SDK 数据上报:", postData);
$.ajax({
url: SDKConfig.report_domain,
type: "POST",
dataType: "json",
data: postData,
success: function () {
// console.log("@@SDK上报数据成功");
},
fail: function () {
console.log("@@SDK上报数据失败");
}
});
} catch (err) {
console.log("@@SDK 错误::reportData", err)
}
},
sdkRequest: function (uri, data, callback) {
var _selt = this;
if (_selt.sdkParams.uniqueid == '') { // 当uniqueid为空时使用openid
_selt.sdkParams.uniqueid = _selt.ReportParams.openId;
}
var postData = this.md5_sign(data); // 附上签名参数
console.log("@@SDK接口::参数", postData);
$.ajax({
url: uri,
type: "POST",
dataType: "json",
data: postData,
success: function (data) {
// console.log("@@SDK上报数据成功");
callback(data);
},
fail: function () {
console.log("@@SDK上报数据失败");
}
})
},
//支付
pay: function (orderInfo, callback) {
var _selt = this;
if (!_selt.sdkStatus.initReady) {
return console.log("初始化SDK失败");
}
var postData = Object.assign({}, _selt.sdkParams, orderInfo);
//获取订单信息
_selt.sdkRequest(Links.order, postData, function (data) {
console.log("@@SDK支付::订单返回", data);
if (data && data.code == '3021') { // 余额不足
_selt.sdkParams.order_num = data.data.order_num;
//呼起充值流程
window.popPayTips({
version: "v2",
defaultScore: orderInfo.amount * 10,
appid: window.OPEN_DATA.appid
});
} else if (data && data.code == '0') {
// 完成支付并发货成功
_selt.printf('充值成功');
} else {
console.log("@@SDK下单失败::", data.msg);
_selt.printf('支付失败:' + data.msg);
}
});
window.__paySuccess = function () {
//支付成功执行
orderInfo.err_code = '1';
orderInfo.status = true;
_selt.sdkRequest(Links.deliver, _selt.sdkParams, function (data) {
if (data && data.code == 0) {
_selt.printf('充值成功');
} else {
_selt.printf("充值失败:" + data.msg);
}
delete _selt.sdkParams.order_num; // 删除订单字段
});
}
window.__payError = function () {
orderInfo.err_code = '0';
_selt.delOrder();
}
window.__payClose = function () {
orderInfo.err_code = '-1';
_selt.delOrder();
}
},
delOrder: function () {
_selt.sdkRequest(Links.delOrder, _selt.sdkParams, function (data) {
_selt.printf("充值失败");
delete _selt.sdkParams.order_num; // 删除订单字段
});
},
isMobile: function () {
return navigator.userAgent.match(/android|iphone|ipad|ipod|blackberry|meego|symbianos|windowsphone|ucbrowser/i);
},
isIos: function () {
return navigator.userAgent.match(/iphone|ipod|ios|ipad/i);
},
isAndroid: function () {
return navigator.userAgent.match(/android/i);
},
// 系统类型
getOsType: function () {
var ostype = "other";
if (this.isMobile()) {
if (this.isIos()) {
ostype = "ios";
} else if (this.isAndroid()) {
ostype = "android";
}
}
return ostype;
},
getQueryString: function (name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
if (r != null) {
return unescape(r[2]);
}
return null;
},
//接口签名,直接返回完整对象
md5_sign: function (obj) {
obj.time = Date.parse(new Date().toString()) // 获取请求的时间戳秒
var keys = Object.keys(obj).sort();
var key_url = "";
for (var i = 0; i < keys.length; i++) {
if (keys[i] != 'sign') key_url += keys[i] + '=' + obj[keys[i]] + '&'
}
key_url = key_url + SDKConfig.productKey
obj.sign = md5(key_url)
return obj
},
isArray: function (arr) {
var toStr = Object.prototype.toString;
if (typeof Array.isArray === 'function') {
return Array.isArray(arr);
}
return toStr.call(arr) === '[object Array]';
},
printf: function (_txt) {
try {
var tips = {};
tips.text = _txt;
mqq.ui.showTips(tips);
} catch (error) {
console.log("@@SDK提示框错误::", error);
}
},
// 统计上报参数
ReportParams: {
action: null, // 必填,事件类型
openId: null, // 必填,微信openid,通过code去SDK接口换取
userId: '', // 必传,用户ID
fromOpenId: "",
productCode: null, // 必填,产品code
clickId: null, // 点击id
extArgs: null, // 必填 广告来源标识
time: null // 必填,请求的时间戳(秒)
},
// SDK上报参数
sdkParams: {
product_code: "", // 产品code
appid: "", // 小游戏appid
time: "", // 当前时间戳秒
uniqueid: '', // 设备唯一号
mac: '', // 网卡mac地址
idfa: '', // 苹果设备IDFA
open_id: "", // 用户openid
password: '', // 登录密码(微信免密)
source: 'QZONE', // 用户来源
token: '', // 登录成功返回
os: 'H5', // 系统类型
equipmentos: "", // 系统版本
equipmentname: "", // 手机型号
version: "", // SDK版本
package_code: '', // 渠道标识
sign: "", // 签名
unionid: '', // 用户Unionid,用于切支付
pay_channel: '', // 支付方式初始化接口返回
}
}
var Links = {
active: SDKConfig.sdk_domain + '/appInit.php', // SDK初始化接口
login: SDKConfig.sdk_domain + '/login.php', // SDK登录接口,获取用户平台信息
order: SDKConfig.pay_domain + '/pay.php', //订单接口
deliver: SDKConfig.pay_domain + '/order/order_complete.php', //扣费接口
delOrder: SDKConfig.pay_domain + '/order/order_cancel.php' //取消订单
}
// md5加密
var rotateLeft = (lValue, iShiftBits) => { return (lValue << iShiftBits) | (lValue >>> (32 - iShiftBits)) }; var addUnsigned = function (lX, lY) { var lX4, lY4, lX8, lY8, lResult; lX8 = (lX & 2147483648); lY8 = (lY & 2147483648); lX4 = (lX & 1073741824); lY4 = (lY & 1073741824); lResult = (lX & 1073741823) + (lY & 1073741823); if (lX4 & lY4) { return (lResult ^ 2147483648 ^ lX8 ^ lY8) } if (lX4 | lY4) { if (lResult & 1073741824) { return (lResult ^ 3221225472 ^ lX8 ^ lY8) } else { return (lResult ^ 1073741824 ^ 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] | (128 << 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 }; function md5(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 = 1732584193; b = 4023233417; c = 2562383102; d = 271733878; 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, 3614090360); d = FF(d, a, b, c, x[k + 1], S12, 3905402710); c = FF(c, d, a, b, x[k + 2], S13, 606105819); b = FF(b, c, d, a, x[k + 3], S14, 3250441966); a = FF(a, b, c, d, x[k + 4], S11, 4118548399); d = FF(d, a, b, c, x[k + 5], S12, 1200080426); c = FF(c, d, a, b, x[k + 6], S13, 2821735955); b = FF(b, c, d, a, x[k + 7], S14, 4249261313); a = FF(a, b, c, d, x[k + 8], S11, 1770035416); d = FF(d, a, b, c, x[k + 9], S12, 2336552879); c = FF(c, d, a, b, x[k + 10], S13, 4294925233); b = FF(b, c, d, a, x[k + 11], S14, 2304563134); a = FF(a, b, c, d, x[k + 12], S11, 1804603682); d = FF(d, a, b, c, x[k + 13], S12, 4254626195); c = FF(c, d, a, b, x[k + 14], S13, 2792965006); b = FF(b, c, d, a, x[k + 15], S14, 1236535329); a = GG(a, b, c, d, x[k + 1], S21, 4129170786); d = GG(d, a, b, c, x[k + 6], S22, 3225465664); c = GG(c, d, a, b, x[k + 11], S23, 643717713); b = GG(b, c, d, a, x[k + 0], S24, 3921069994); a = GG(a, b, c, d, x[k + 5], S21, 3593408605); d = GG(d, a, b, c, x[k + 10], S22, 38016083); c = GG(c, d, a, b, x[k + 15], S23, 3634488961); b = GG(b, c, d, a, x[k + 4], S24, 3889429448); a = GG(a, b, c, d, x[k + 9], S21, 568446438); d = GG(d, a, b, c, x[k + 14], S22, 3275163606); c = GG(c, d, a, b, x[k + 3], S23, 4107603335); b = GG(b, c, d, a, x[k + 8], S24, 1163531501); a = GG(a, b, c, d, x[k + 13], S21, 2850285829); d = GG(d, a, b, c, x[k + 2], S22, 4243563512); c = GG(c, d, a, b, x[k + 7], S23, 1735328473); b = GG(b, c, d, a, x[k + 12], S24, 2368359562); a = HH(a, b, c, d, x[k + 5], S31, 4294588738); d = HH(d, a, b, c, x[k + 8], S32, 2272392833); c = HH(c, d, a, b, x[k + 11], S33, 1839030562); b = HH(b, c, d, a, x[k + 14], S34, 4259657740); a = HH(a, b, c, d, x[k + 1], S31, 2763975236); d = HH(d, a, b, c, x[k + 4], S32, 1272893353); c = HH(c, d, a, b, x[k + 7], S33, 4139469664); b = HH(b, c, d, a, x[k + 10], S34, 3200236656); a = HH(a, b, c, d, x[k + 13], S31, 681279174); d = HH(d, a, b, c, x[k + 0], S32, 3936430074); c = HH(c, d, a, b, x[k + 3], S33, 3572445317); b = HH(b, c, d, a, x[k + 6], S34, 76029189); a = HH(a, b, c, d, x[k + 9], S31, 3654602809); d = HH(d, a, b, c, x[k + 12], S32, 3873151461); c = HH(c, d, a, b, x[k + 15], S33, 530742520); b = HH(b, c, d, a, x[k + 2], S34, 3299628645); a = II(a, b, c, d, x[k + 0], S41, 4096336452); d = II(d, a, b, c, x[k + 7], S42, 1126891415); c = II(c, d, a, b, x[k + 14], S43, 2878612391); b = II(b, c, d, a, x[k + 5], S44, 4237533241); a = II(a, b, c, d, x[k + 12], S41, 1700485571); d = II(d, a, b, c, x[k + 3], S42, 2399980690); c = II(c, d, a, b, x[k + 10], S43, 4293915773); b = II(b, c, d, a, x[k + 1], S44, 2240044497); a = II(a, b, c, d, x[k + 8], S41, 1873313359); d = II(d, a, b, c, x[k + 15], S42, 4264355552); c = II(c, d, a, b, x[k + 6], S43, 2734768916); b = II(b, c, d, a, x[k + 13], S44, 1309151649); a = II(a, b, c, d, x[k + 4], S41, 4149444226); d = II(d, a, b, c, x[k + 11], S42, 3174756917); c = II(c, d, a, b, x[k + 2], S43, 718787259); b = II(b, c, d, a, x[k + 9], S44, 3951481745); 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() };
\ No newline at end of file
/* Zepto v1.2.0 - zepto event ajax form ie - zeptojs.com/license */
!function (t, e) { "function" == typeof define && define.amd ? define(function () { return e(t) }) : e(t) } (this, function (t) { var e = function () { function $(t) { return null == t ? String(t) : S[C.call(t)] || "object" } function F(t) { return "function" == $(t) } function k(t) { return null != t && t == t.window } function M(t) { return null != t && t.nodeType == t.DOCUMENT_NODE } function R(t) { return "object" == $(t) } function Z(t) { return R(t) && !k(t) && Object.getPrototypeOf(t) == Object.prototype } function z(t) { var e = !!t && "length" in t && t.length, n = r.type(t); return "function" != n && !k(t) && ("array" == n || 0 === e || "number" == typeof e && e > 0 && e - 1 in t) } function q(t) { return a.call(t, function (t) { return null != t }) } function H(t) { return t.length > 0 ? r.fn.concat.apply([], t) : t } function I(t) { return t.replace(/::/g, "/").replace(/([A-Z]+)([A-Z][a-z])/g, "$1_$2").replace(/([a-z\d])([A-Z])/g, "$1_$2").replace(/_/g, "-").toLowerCase() } function V(t) { return t in l ? l[t] : l[t] = new RegExp("(^|\\s)" + t + "(\\s|$)") } function _(t, e) { return "number" != typeof e || h[I(t)] ? e : e + "px" } function B(t) { var e, n; return c[t] || (e = f.createElement(t), f.body.appendChild(e), n = getComputedStyle(e, "").getPropertyValue("display"), e.parentNode.removeChild(e), "none" == n && (n = "block"), c[t] = n), c[t] } function U(t) { return "children" in t ? u.call(t.children) : r.map(t.childNodes, function (t) { return 1 == t.nodeType ? t : void 0 }) } function X(t, e) { var n, r = t ? t.length : 0; for (n = 0; r > n; n++)this[n] = t[n]; this.length = r, this.selector = e || "" } function J(t, r, i) { for (n in r) i && (Z(r[n]) || L(r[n])) ? (Z(r[n]) && !Z(t[n]) && (t[n] = {}), L(r[n]) && !L(t[n]) && (t[n] = []), J(t[n], r[n], i)) : r[n] !== e && (t[n] = r[n]) } function W(t, e) { return null == e ? r(t) : r(t).filter(e) } function Y(t, e, n, r) { return F(e) ? e.call(t, n, r) : e } function G(t, e, n) { null == n ? t.removeAttribute(e) : t.setAttribute(e, n) } function K(t, n) { var r = t.className || "", i = r && r.baseVal !== e; return n === e ? i ? r.baseVal : r : void (i ? r.baseVal = n : t.className = n) } function Q(t) { try { return t ? "true" == t || ("false" == t ? !1 : "null" == t ? null : +t + "" == t ? +t : /^[\[\{]/.test(t) ? r.parseJSON(t) : t) : t } catch (e) { return t } } function tt(t, e) { e(t); for (var n = 0, r = t.childNodes.length; r > n; n++)tt(t.childNodes[n], e) } var e, n, r, i, O, P, o = [], s = o.concat, a = o.filter, u = o.slice, f = t.document, c = {}, l = {}, h = { "column-count": 1, columns: 1, "font-weight": 1, "line-height": 1, opacity: 1, "z-index": 1, zoom: 1 }, p = /^\s*<(\w+|!)[^>]*>/, d = /^<(\w+)\s*\/?>(?:<\/\1>|)$/, m = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, g = /^(?:body|html)$/i, v = /([A-Z])/g, y = ["val", "css", "html", "text", "data", "width", "height", "offset"], x = ["after", "prepend", "before", "append"], b = f.createElement("table"), E = f.createElement("tr"), j = { tr: f.createElement("tbody"), tbody: b, thead: b, tfoot: b, td: E, th: E, "*": f.createElement("div") }, w = /complete|loaded|interactive/, T = /^[\w-]*$/, S = {}, C = S.toString, N = {}, A = f.createElement("div"), D = { tabindex: "tabIndex", readonly: "readOnly", "for": "htmlFor", "class": "className", maxlength: "maxLength", cellspacing: "cellSpacing", cellpadding: "cellPadding", rowspan: "rowSpan", colspan: "colSpan", usemap: "useMap", frameborder: "frameBorder", contenteditable: "contentEditable" }, L = Array.isArray || function (t) { return t instanceof Array }; return N.matches = function (t, e) { if (!e || !t || 1 !== t.nodeType) return !1; var n = t.matches || t.webkitMatchesSelector || t.mozMatchesSelector || t.oMatchesSelector || t.matchesSelector; if (n) return n.call(t, e); var r, i = t.parentNode, o = !i; return o && (i = A).appendChild(t), r = ~N.qsa(i, e).indexOf(t), o && A.removeChild(t), r }, O = function (t) { return t.replace(/-+(.)?/g, function (t, e) { return e ? e.toUpperCase() : "" }) }, P = function (t) { return a.call(t, function (e, n) { return t.indexOf(e) == n }) }, N.fragment = function (t, n, i) { var o, s, a; return d.test(t) && (o = r(f.createElement(RegExp.$1))), o || (t.replace && (t = t.replace(m, "<$1></$2>")), n === e && (n = p.test(t) && RegExp.$1), n in j || (n = "*"), a = j[n], a.innerHTML = "" + t, o = r.each(u.call(a.childNodes), function () { a.removeChild(this) })), Z(i) && (s = r(o), r.each(i, function (t, e) { y.indexOf(t) > -1 ? s[t](e) : s.attr(t, e) })), o }, N.Z = function (t, e) { return new X(t, e) }, N.isZ = function (t) { return t instanceof N.Z }, N.init = function (t, n) { var i; if (!t) return N.Z(); if ("string" == typeof t) if (t = t.trim(), "<" == t[0] && p.test(t)) i = N.fragment(t, RegExp.$1, n), t = null; else { if (n !== e) return r(n).find(t); i = N.qsa(f, t) } else { if (F(t)) return r(f).ready(t); if (N.isZ(t)) return t; if (L(t)) i = q(t); else if (R(t)) i = [t], t = null; else if (p.test(t)) i = N.fragment(t.trim(), RegExp.$1, n), t = null; else { if (n !== e) return r(n).find(t); i = N.qsa(f, t) } } return N.Z(i, t) }, r = function (t, e) { return N.init(t, e) }, r.extend = function (t) { var e, n = u.call(arguments, 1); return "boolean" == typeof t && (e = t, t = n.shift()), n.forEach(function (n) { J(t, n, e) }), t }, N.qsa = function (t, e) { var n, r = "#" == e[0], i = !r && "." == e[0], o = r || i ? e.slice(1) : e, s = T.test(o); return t.getElementById && s && r ? (n = t.getElementById(o)) ? [n] : [] : 1 !== t.nodeType && 9 !== t.nodeType && 11 !== t.nodeType ? [] : u.call(s && !r && t.getElementsByClassName ? i ? t.getElementsByClassName(o) : t.getElementsByTagName(e) : t.querySelectorAll(e)) }, r.contains = f.documentElement.contains ? function (t, e) { return t !== e && t.contains(e) } : function (t, e) { for (; e && (e = e.parentNode);)if (e === t) return !0; return !1 }, r.type = $, r.isFunction = F, r.isWindow = k, r.isArray = L, r.isPlainObject = Z, r.isEmptyObject = function (t) { var e; for (e in t) return !1; return !0 }, r.isNumeric = function (t) { var e = Number(t), n = typeof t; return null != t && "boolean" != n && ("string" != n || t.length) && !isNaN(e) && isFinite(e) || !1 }, r.inArray = function (t, e, n) { return o.indexOf.call(e, t, n) }, r.camelCase = O, r.trim = function (t) { return null == t ? "" : String.prototype.trim.call(t) }, r.uuid = 0, r.support = {}, r.expr = {}, r.noop = function () { }, r.map = function (t, e) { var n, i, o, r = []; if (z(t)) for (i = 0; i < t.length; i++)n = e(t[i], i), null != n && r.push(n); else for (o in t) n = e(t[o], o), null != n && r.push(n); return H(r) }, r.each = function (t, e) { var n, r; if (z(t)) { for (n = 0; n < t.length; n++)if (e.call(t[n], n, t[n]) === !1) return t } else for (r in t) if (e.call(t[r], r, t[r]) === !1) return t; return t }, r.grep = function (t, e) { return a.call(t, e) }, t.JSON && (r.parseJSON = JSON.parse), r.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function (t, e) { S["[object " + e + "]"] = e.toLowerCase() }), r.fn = { constructor: N.Z, length: 0, forEach: o.forEach, reduce: o.reduce, push: o.push, sort: o.sort, splice: o.splice, indexOf: o.indexOf, concat: function () { var t, e, n = []; for (t = 0; t < arguments.length; t++)e = arguments[t], n[t] = N.isZ(e) ? e.toArray() : e; return s.apply(N.isZ(this) ? this.toArray() : this, n) }, map: function (t) { return r(r.map(this, function (e, n) { return t.call(e, n, e) })) }, slice: function () { return r(u.apply(this, arguments)) }, ready: function (t) { return w.test(f.readyState) && f.body ? t(r) : f.addEventListener("DOMContentLoaded", function () { t(r) }, !1), this }, get: function (t) { return t === e ? u.call(this) : this[t >= 0 ? t : t + this.length] }, toArray: function () { return this.get() }, size: function () { return this.length }, remove: function () { return this.each(function () { null != this.parentNode && this.parentNode.removeChild(this) }) }, each: function (t) { return o.every.call(this, function (e, n) { return t.call(e, n, e) !== !1 }), this }, filter: function (t) { return F(t) ? this.not(this.not(t)) : r(a.call(this, function (e) { return N.matches(e, t) })) }, add: function (t, e) { return r(P(this.concat(r(t, e)))) }, is: function (t) { return this.length > 0 && N.matches(this[0], t) }, not: function (t) { var n = []; if (F(t) && t.call !== e) this.each(function (e) { t.call(this, e) || n.push(this) }); else { var i = "string" == typeof t ? this.filter(t) : z(t) && F(t.item) ? u.call(t) : r(t); this.forEach(function (t) { i.indexOf(t) < 0 && n.push(t) }) } return r(n) }, has: function (t) { return this.filter(function () { return R(t) ? r.contains(this, t) : r(this).find(t).size() }) }, eq: function (t) { return -1 === t ? this.slice(t) : this.slice(t, +t + 1) }, first: function () { var t = this[0]; return t && !R(t) ? t : r(t) }, last: function () { var t = this[this.length - 1]; return t && !R(t) ? t : r(t) }, find: function (t) { var e, n = this; return e = t ? "object" == typeof t ? r(t).filter(function () { var t = this; return o.some.call(n, function (e) { return r.contains(e, t) }) }) : 1 == this.length ? r(N.qsa(this[0], t)) : this.map(function () { return N.qsa(this, t) }) : r() }, closest: function (t, e) { var n = [], i = "object" == typeof t && r(t); return this.each(function (r, o) { for (; o && !(i ? i.indexOf(o) >= 0 : N.matches(o, t));)o = o !== e && !M(o) && o.parentNode; o && n.indexOf(o) < 0 && n.push(o) }), r(n) }, parents: function (t) { for (var e = [], n = this; n.length > 0;)n = r.map(n, function (t) { return (t = t.parentNode) && !M(t) && e.indexOf(t) < 0 ? (e.push(t), t) : void 0 }); return W(e, t) }, parent: function (t) { return W(P(this.pluck("parentNode")), t) }, children: function (t) { return W(this.map(function () { return U(this) }), t) }, contents: function () { return this.map(function () { return this.contentDocument || u.call(this.childNodes) }) }, siblings: function (t) { return W(this.map(function (t, e) { return a.call(U(e.parentNode), function (t) { return t !== e }) }), t) }, empty: function () { return this.each(function () { this.innerHTML = "" }) }, pluck: function (t) { return r.map(this, function (e) { return e[t] }) }, show: function () { return this.each(function () { "none" == this.style.display && (this.style.display = ""), "none" == getComputedStyle(this, "").getPropertyValue("display") && (this.style.display = B(this.nodeName)) }) }, replaceWith: function (t) { return this.before(t).remove() }, wrap: function (t) { var e = F(t); if (this[0] && !e) var n = r(t).get(0), i = n.parentNode || this.length > 1; return this.each(function (o) { r(this).wrapAll(e ? t.call(this, o) : i ? n.cloneNode(!0) : n) }) }, wrapAll: function (t) { if (this[0]) { r(this[0]).before(t = r(t)); for (var e; (e = t.children()).length;)t = e.first(); r(t).append(this) } return this }, wrapInner: function (t) { var e = F(t); return this.each(function (n) { var i = r(this), o = i.contents(), s = e ? t.call(this, n) : t; o.length ? o.wrapAll(s) : i.append(s) }) }, unwrap: function () { return this.parent().each(function () { r(this).replaceWith(r(this).children()) }), this }, clone: function () { return this.map(function () { return this.cloneNode(!0) }) }, hide: function () { return this.css("display", "none") }, toggle: function (t) { return this.each(function () { var n = r(this); (t === e ? "none" == n.css("display") : t) ? n.show() : n.hide() }) }, prev: function (t) { return r(this.pluck("previousElementSibling")).filter(t || "*") }, next: function (t) { return r(this.pluck("nextElementSibling")).filter(t || "*") }, html: function (t) { return 0 in arguments ? this.each(function (e) { var n = this.innerHTML; r(this).empty().append(Y(this, t, e, n)) }) : 0 in this ? this[0].innerHTML : null }, text: function (t) { return 0 in arguments ? this.each(function (e) { var n = Y(this, t, e, this.textContent); this.textContent = null == n ? "" : "" + n }) : 0 in this ? this.pluck("textContent").join("") : null }, attr: function (t, r) { var i; return "string" != typeof t || 1 in arguments ? this.each(function (e) { if (1 === this.nodeType) if (R(t)) for (n in t) G(this, n, t[n]); else G(this, t, Y(this, r, e, this.getAttribute(t))) }) : 0 in this && 1 == this[0].nodeType && null != (i = this[0].getAttribute(t)) ? i : e }, removeAttr: function (t) { return this.each(function () { 1 === this.nodeType && t.split(" ").forEach(function (t) { G(this, t) }, this) }) }, prop: function (t, e) { return t = D[t] || t, 1 in arguments ? this.each(function (n) { this[t] = Y(this, e, n, this[t]) }) : this[0] && this[0][t] }, removeProp: function (t) { return t = D[t] || t, this.each(function () { delete this[t] }) }, data: function (t, n) { var r = "data-" + t.replace(v, "-$1").toLowerCase(), i = 1 in arguments ? this.attr(r, n) : this.attr(r); return null !== i ? Q(i) : e }, val: function (t) { return 0 in arguments ? (null == t && (t = ""), this.each(function (e) { this.value = Y(this, t, e, this.value) })) : this[0] && (this[0].multiple ? r(this[0]).find("option").filter(function () { return this.selected }).pluck("value") : this[0].value) }, offset: function (e) { if (e) return this.each(function (t) { var n = r(this), i = Y(this, e, t, n.offset()), o = n.offsetParent().offset(), s = { top: i.top - o.top, left: i.left - o.left }; "static" == n.css("position") && (s.position = "relative"), n.css(s) }); if (!this.length) return null; if (f.documentElement !== this[0] && !r.contains(f.documentElement, this[0])) return { top: 0, left: 0 }; var n = this[0].getBoundingClientRect(); return { left: n.left + t.pageXOffset, top: n.top + t.pageYOffset, width: Math.round(n.width), height: Math.round(n.height) } }, css: function (t, e) { if (arguments.length < 2) { var i = this[0]; if ("string" == typeof t) { if (!i) return; return i.style[O(t)] || getComputedStyle(i, "").getPropertyValue(t) } if (L(t)) { if (!i) return; var o = {}, s = getComputedStyle(i, ""); return r.each(t, function (t, e) { o[e] = i.style[O(e)] || s.getPropertyValue(e) }), o } } var a = ""; if ("string" == $(t)) e || 0 === e ? a = I(t) + ":" + _(t, e) : this.each(function () { this.style.removeProperty(I(t)) }); else for (n in t) t[n] || 0 === t[n] ? a += I(n) + ":" + _(n, t[n]) + ";" : this.each(function () { this.style.removeProperty(I(n)) }); return this.each(function () { this.style.cssText += ";" + a }) }, index: function (t) { return t ? this.indexOf(r(t)[0]) : this.parent().children().indexOf(this[0]) }, hasClass: function (t) { return t ? o.some.call(this, function (t) { return this.test(K(t)) }, V(t)) : !1 }, addClass: function (t) { return t ? this.each(function (e) { if ("className" in this) { i = []; var n = K(this), o = Y(this, t, e, n); o.split(/\s+/g).forEach(function (t) { r(this).hasClass(t) || i.push(t) }, this), i.length && K(this, n + (n ? " " : "") + i.join(" ")) } }) : this }, removeClass: function (t) { return this.each(function (n) { if ("className" in this) { if (t === e) return K(this, ""); i = K(this), Y(this, t, n, i).split(/\s+/g).forEach(function (t) { i = i.replace(V(t), " ") }), K(this, i.trim()) } }) }, toggleClass: function (t, n) { return t ? this.each(function (i) { var o = r(this), s = Y(this, t, i, K(this)); s.split(/\s+/g).forEach(function (t) { (n === e ? !o.hasClass(t) : n) ? o.addClass(t) : o.removeClass(t) }) }) : this }, scrollTop: function (t) { if (this.length) { var n = "scrollTop" in this[0]; return t === e ? n ? this[0].scrollTop : this[0].pageYOffset : this.each(n ? function () { this.scrollTop = t } : function () { this.scrollTo(this.scrollX, t) }) } }, scrollLeft: function (t) { if (this.length) { var n = "scrollLeft" in this[0]; return t === e ? n ? this[0].scrollLeft : this[0].pageXOffset : this.each(n ? function () { this.scrollLeft = t } : function () { this.scrollTo(t, this.scrollY) }) } }, position: function () { if (this.length) { var t = this[0], e = this.offsetParent(), n = this.offset(), i = g.test(e[0].nodeName) ? { top: 0, left: 0 } : e.offset(); return n.top -= parseFloat(r(t).css("margin-top")) || 0, n.left -= parseFloat(r(t).css("margin-left")) || 0, i.top += parseFloat(r(e[0]).css("border-top-width")) || 0, i.left += parseFloat(r(e[0]).css("border-left-width")) || 0, { top: n.top - i.top, left: n.left - i.left } } }, offsetParent: function () { return this.map(function () { for (var t = this.offsetParent || f.body; t && !g.test(t.nodeName) && "static" == r(t).css("position");)t = t.offsetParent; return t }) } }, r.fn.detach = r.fn.remove, ["width", "height"].forEach(function (t) { var n = t.replace(/./, function (t) { return t[0].toUpperCase() }); r.fn[t] = function (i) { var o, s = this[0]; return i === e ? k(s) ? s["inner" + n] : M(s) ? s.documentElement["scroll" + n] : (o = this.offset()) && o[t] : this.each(function (e) { s = r(this), s.css(t, Y(this, i, e, s[t]())) }) } }), x.forEach(function (n, i) { var o = i % 2; r.fn[n] = function () { var n, a, s = r.map(arguments, function (t) { var i = []; return n = $(t), "array" == n ? (t.forEach(function (t) { return t.nodeType !== e ? i.push(t) : r.zepto.isZ(t) ? i = i.concat(t.get()) : void (i = i.concat(N.fragment(t))) }), i) : "object" == n || null == t ? t : N.fragment(t) }), u = this.length > 1; return s.length < 1 ? this : this.each(function (e, n) { a = o ? n : n.parentNode, n = 0 == i ? n.nextSibling : 1 == i ? n.firstChild : 2 == i ? n : null; var c = r.contains(f.documentElement, a); s.forEach(function (e) { if (u) e = e.cloneNode(!0); else if (!a) return r(e).remove(); a.insertBefore(e, n), c && tt(e, function (e) { if (!(null == e.nodeName || "SCRIPT" !== e.nodeName.toUpperCase() || e.type && "text/javascript" !== e.type || e.src)) { var n = e.ownerDocument ? e.ownerDocument.defaultView : t; n.eval.call(n, e.innerHTML) } }) }) }) }, r.fn[o ? n + "To" : "insert" + (i ? "Before" : "After")] = function (t) { return r(t)[n](this), this } }), N.Z.prototype = X.prototype = r.fn, N.uniq = P, N.deserializeValue = Q, r.zepto = N, r } (); return t.Zepto = e, void 0 === t.$ && (t.$ = e), function (e) { function h(t) { return t._zid || (t._zid = n++) } function p(t, e, n, r) { if (e = d(e), e.ns) var i = m(e.ns); return (a[h(t)] || []).filter(function (t) { return t && (!e.e || t.e == e.e) && (!e.ns || i.test(t.ns)) && (!n || h(t.fn) === h(n)) && (!r || t.sel == r) }) } function d(t) { var e = ("" + t).split("."); return { e: e[0], ns: e.slice(1).sort().join(" ") } } function m(t) { return new RegExp("(?:^| )" + t.replace(" ", " .* ?") + "(?: |$)") } function g(t, e) { return t.del && !f && t.e in c || !!e } function v(t) { return l[t] || f && c[t] || t } function y(t, n, i, o, s, u, f) { var c = h(t), p = a[c] || (a[c] = []); n.split(/\s/).forEach(function (n) { if ("ready" == n) return e(document).ready(i); var a = d(n); a.fn = i, a.sel = s, a.e in l && (i = function (t) { var n = t.relatedTarget; return !n || n !== this && !e.contains(this, n) ? a.fn.apply(this, arguments) : void 0 }), a.del = u; var c = u || i; a.proxy = function (e) { if (e = T(e), !e.isImmediatePropagationStopped()) { e.data = o; var n = c.apply(t, e._args == r ? [e] : [e].concat(e._args)); return n === !1 && (e.preventDefault(), e.stopPropagation()), n } }, a.i = p.length, p.push(a), "addEventListener" in t && t.addEventListener(v(a.e), a.proxy, g(a, f)) }) } function x(t, e, n, r, i) { var o = h(t); (e || "").split(/\s/).forEach(function (e) { p(t, e, n, r).forEach(function (e) { delete a[o][e.i], "removeEventListener" in t && t.removeEventListener(v(e.e), e.proxy, g(e, i)) }) }) } function T(t, n) { return (n || !t.isDefaultPrevented) && (n || (n = t), e.each(w, function (e, r) { var i = n[e]; t[e] = function () { return this[r] = b, i && i.apply(n, arguments) }, t[r] = E }), t.timeStamp || (t.timeStamp = Date.now()), (n.defaultPrevented !== r ? n.defaultPrevented : "returnValue" in n ? n.returnValue === !1 : n.getPreventDefault && n.getPreventDefault()) && (t.isDefaultPrevented = b)), t } function S(t) { var e, n = { originalEvent: t }; for (e in t) j.test(e) || t[e] === r || (n[e] = t[e]); return T(n, t) } var r, n = 1, i = Array.prototype.slice, o = e.isFunction, s = function (t) { return "string" == typeof t }, a = {}, u = {}, f = "onfocusin" in t, c = { focus: "focusin", blur: "focusout" }, l = { mouseenter: "mouseover", mouseleave: "mouseout" }; u.click = u.mousedown = u.mouseup = u.mousemove = "MouseEvents", e.event = { add: y, remove: x }, e.proxy = function (t, n) { var r = 2 in arguments && i.call(arguments, 2); if (o(t)) { var a = function () { return t.apply(n, r ? r.concat(i.call(arguments)) : arguments) }; return a._zid = h(t), a } if (s(n)) return r ? (r.unshift(t[n], t), e.proxy.apply(null, r)) : e.proxy(t[n], t); throw new TypeError("expected function") }, e.fn.bind = function (t, e, n) { return this.on(t, e, n) }, e.fn.unbind = function (t, e) { return this.off(t, e) }, e.fn.one = function (t, e, n, r) { return this.on(t, e, n, r, 1) }; var b = function () { return !0 }, E = function () { return !1 }, j = /^([A-Z]|returnValue$|layer[XY]$|webkitMovement[XY]$)/, w = { preventDefault: "isDefaultPrevented", stopImmediatePropagation: "isImmediatePropagationStopped", stopPropagation: "isPropagationStopped" }; e.fn.delegate = function (t, e, n) { return this.on(e, t, n) }, e.fn.undelegate = function (t, e, n) { return this.off(e, t, n) }, e.fn.live = function (t, n) { return e(document.body).delegate(this.selector, t, n), this }, e.fn.die = function (t, n) { return e(document.body).undelegate(this.selector, t, n), this }, e.fn.on = function (t, n, a, u, f) { var c, l, h = this; return t && !s(t) ? (e.each(t, function (t, e) { h.on(t, n, a, e, f) }), h) : (s(n) || o(u) || u === !1 || (u = a, a = n, n = r), (u === r || a === !1) && (u = a, a = r), u === !1 && (u = E), h.each(function (r, o) { f && (c = function (t) { return x(o, t.type, u), u.apply(this, arguments) }), n && (l = function (t) { var r, s = e(t.target).closest(n, o).get(0); return s && s !== o ? (r = e.extend(S(t), { currentTarget: s, liveFired: o }), (c || u).apply(s, [r].concat(i.call(arguments, 1)))) : void 0 }), y(o, t, u, a, n, l || c) })) }, e.fn.off = function (t, n, i) { var a = this; return t && !s(t) ? (e.each(t, function (t, e) { a.off(t, n, e) }), a) : (s(n) || o(i) || i === !1 || (i = n, n = r), i === !1 && (i = E), a.each(function () { x(this, t, i, n) })) }, e.fn.trigger = function (t, n) { return t = s(t) || e.isPlainObject(t) ? e.Event(t) : T(t), t._args = n, this.each(function () { t.type in c && "function" == typeof this[t.type] ? this[t.type]() : "dispatchEvent" in this ? this.dispatchEvent(t) : e(this).triggerHandler(t, n) }) }, e.fn.triggerHandler = function (t, n) { var r, i; return this.each(function (o, a) { r = S(s(t) ? e.Event(t) : t), r._args = n, r.target = a, e.each(p(a, t.type || t), function (t, e) { return i = e.proxy(r), r.isImmediatePropagationStopped() ? !1 : void 0 }) }), i }, "focusin focusout focus blur load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select keydown keypress keyup error".split(" ").forEach(function (t) { e.fn[t] = function (e) { return 0 in arguments ? this.bind(t, e) : this.trigger(t) } }), e.Event = function (t, e) { s(t) || (e = t, t = e.type); var n = document.createEvent(u[t] || "Events"), r = !0; if (e) for (var i in e) "bubbles" == i ? r = !!e[i] : n[i] = e[i]; return n.initEvent(t, r, !0), T(n) } } (e), function (e) { function p(t, n, r) { var i = e.Event(n); return e(t).trigger(i, r), !i.isDefaultPrevented() } function d(t, e, n, i) { return t.global ? p(e || r, n, i) : void 0 } function m(t) { t.global && 0 === e.active++ && d(t, null, "ajaxStart") } function g(t) { t.global && !--e.active && d(t, null, "ajaxStop") } function v(t, e) { var n = e.context; return e.beforeSend.call(n, t, e) === !1 || d(e, n, "ajaxBeforeSend", [t, e]) === !1 ? !1 : void d(e, n, "ajaxSend", [t, e]) } function y(t, e, n, r) { var i = n.context, o = "success"; n.success.call(i, t, o, e), r && r.resolveWith(i, [t, o, e]), d(n, i, "ajaxSuccess", [e, n, t]), b(o, e, n) } function x(t, e, n, r, i) { var o = r.context; r.error.call(o, n, e, t), i && i.rejectWith(o, [n, e, t]), d(r, o, "ajaxError", [n, r, t || e]), b(e, n, r) } function b(t, e, n) { var r = n.context; n.complete.call(r, e, t), d(n, r, "ajaxComplete", [e, n]), g(n) } function E(t, e, n) { if (n.dataFilter == j) return t; var r = n.context; return n.dataFilter.call(r, t, e) } function j() { } function w(t) { return t && (t = t.split(";", 2)[0]), t && (t == c ? "html" : t == f ? "json" : a.test(t) ? "script" : u.test(t) && "xml") || "text" } function T(t, e) { return "" == e ? t : (t + "&" + e).replace(/[&?]{1,2}/, "?") } function S(t) { t.processData && t.data && "string" != e.type(t.data) && (t.data = e.param(t.data, t.traditional)), !t.data || t.type && "GET" != t.type.toUpperCase() && "jsonp" != t.dataType || (t.url = T(t.url, t.data), t.data = void 0) } function C(t, n, r, i) { return e.isFunction(n) && (i = r, r = n, n = void 0), e.isFunction(r) || (i = r, r = void 0), { url: t, data: n, success: r, dataType: i } } function O(t, n, r, i) { var o, s = e.isArray(n), a = e.isPlainObject(n); e.each(n, function (n, u) { o = e.type(u), i && (n = r ? i : i + "[" + (a || "object" == o || "array" == o ? n : "") + "]"), !i && s ? t.add(u.name, u.value) : "array" == o || !r && "object" == o ? O(t, u, r, n) : t.add(n, u) }) } var i, o, n = +new Date, r = t.document, s = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, a = /^(?:text|application)\/javascript/i, u = /^(?:text|application)\/xml/i, f = "application/json", c = "text/html", l = /^\s*$/, h = r.createElement("a"); h.href = t.location.href, e.active = 0, e.ajaxJSONP = function (i, o) { if (!("type" in i)) return e.ajax(i); var c, p, s = i.jsonpCallback, a = (e.isFunction(s) ? s() : s) || "Zepto" + n++, u = r.createElement("script"), f = t[a], l = function (t) { e(u).triggerHandler("error", t || "abort") }, h = { abort: l }; return o && o.promise(h), e(u).on("load error", function (n, r) { clearTimeout(p), e(u).off().remove(), "error" != n.type && c ? y(c[0], h, i, o) : x(null, r || "error", h, i, o), t[a] = f, c && e.isFunction(f) && f(c[0]), f = c = void 0 }), v(h, i) === !1 ? (l("abort"), h) : (t[a] = function () { c = arguments }, u.src = i.url.replace(/\?(.+)=\?/, "?$1=" + a), r.head.appendChild(u), i.timeout > 0 && (p = setTimeout(function () { l("timeout") }, i.timeout)), h) }, e.ajaxSettings = { type: "GET", beforeSend: j, success: j, error: j, complete: j, context: null, global: !0, xhr: function () { return new t.XMLHttpRequest }, accepts: { script: "text/javascript, application/javascript, application/x-javascript", json: f, xml: "application/xml, text/xml", html: c, text: "text/plain" }, crossDomain: !1, timeout: 0, processData: !0, cache: !0, dataFilter: j }, e.ajax = function (n) { var u, f, s = e.extend({}, n || {}), a = e.Deferred && e.Deferred(); for (i in e.ajaxSettings) void 0 === s[i] && (s[i] = e.ajaxSettings[i]); m(s), s.crossDomain || (u = r.createElement("a"), u.href = s.url, u.href = u.href, s.crossDomain = h.protocol + "//" + h.host != u.protocol + "//" + u.host), s.url || (s.url = t.location.toString()), (f = s.url.indexOf("#")) > -1 && (s.url = s.url.slice(0, f)), S(s); var c = s.dataType, p = /\?.+=\?/.test(s.url); if (p && (c = "jsonp"), s.cache !== !1 && (n && n.cache === !0 || "script" != c && "jsonp" != c) || (s.url = T(s.url, "_=" + Date.now())), "jsonp" == c) return p || (s.url = T(s.url, s.jsonp ? s.jsonp + "=?" : s.jsonp === !1 ? "" : "callback=?")), e.ajaxJSONP(s, a); var P, d = s.accepts[c], g = {}, b = function (t, e) { g[t.toLowerCase()] = [t, e] }, C = /^([\w-]+:)\/\//.test(s.url) ? RegExp.$1 : t.location.protocol, N = s.xhr(), O = N.setRequestHeader; if (a && a.promise(N), s.crossDomain || b("X-Requested-With", "XMLHttpRequest"), b("Accept", d || "*/*"), (d = s.mimeType || d) && (d.indexOf(",") > -1 && (d = d.split(",", 2)[0]), N.overrideMimeType && N.overrideMimeType(d)), (s.contentType || s.contentType !== !1 && s.data && "GET" != s.type.toUpperCase()) && b("Content-Type", s.contentType || "application/x-www-form-urlencoded"), s.headers) for (o in s.headers) b(o, s.headers[o]); if (N.setRequestHeader = b, N.onreadystatechange = function () { if (4 == N.readyState) { N.onreadystatechange = j, clearTimeout(P); var t, n = !1; if (N.status >= 200 && N.status < 300 || 304 == N.status || 0 == N.status && "file:" == C) { if (c = c || w(s.mimeType || N.getResponseHeader("content-type")), "arraybuffer" == N.responseType || "blob" == N.responseType) t = N.response; else { t = N.responseText; try { t = E(t, c, s), "script" == c ? (1, eval)(t) : "xml" == c ? t = N.responseXML : "json" == c && (t = l.test(t) ? null : e.parseJSON(t)) } catch (r) { n = r } if (n) return x(n, "parsererror", N, s, a) } y(t, N, s, a) } else x(N.statusText || null, N.status ? "error" : "abort", N, s, a) } }, v(N, s) === !1) return N.abort(), x(null, "abort", N, s, a), N; var A = "async" in s ? s.async : !0; if (N.open(s.type, s.url, A, s.username, s.password), s.xhrFields) for (o in s.xhrFields) N[o] = s.xhrFields[o]; for (o in g) O.apply(N, g[o]); return s.timeout > 0 && (P = setTimeout(function () { N.onreadystatechange = j, N.abort(), x(null, "timeout", N, s, a) }, s.timeout)), N.send(s.data ? s.data : null), N }, e.get = function () { return e.ajax(C.apply(null, arguments)) }, e.post = function () { var t = C.apply(null, arguments); return t.type = "POST", e.ajax(t) }, e.getJSON = function () { var t = C.apply(null, arguments); return t.dataType = "json", e.ajax(t) }, e.fn.load = function (t, n, r) { if (!this.length) return this; var a, i = this, o = t.split(/\s/), u = C(t, n, r), f = u.success; return o.length > 1 && (u.url = o[0], a = o[1]), u.success = function (t) { i.html(a ? e("<div>").html(t.replace(s, "")).find(a) : t), f && f.apply(i, arguments) }, e.ajax(u), this }; var N = encodeURIComponent; e.param = function (t, n) { var r = []; return r.add = function (t, n) { e.isFunction(n) && (n = n()), null == n && (n = ""), this.push(N(t) + "=" + N(n)) }, O(r, t, n), r.join("&").replace(/%20/g, "+") } } (e), function (t) { t.fn.serializeArray = function () { var e, n, r = [], i = function (t) { return t.forEach ? t.forEach(i) : void r.push({ name: e, value: t }) }; return this[0] && t.each(this[0].elements, function (r, o) { n = o.type, e = o.name, e && "fieldset" != o.nodeName.toLowerCase() && !o.disabled && "submit" != n && "reset" != n && "button" != n && "file" != n && ("radio" != n && "checkbox" != n || o.checked) && i(t(o).val()) }), r }, t.fn.serialize = function () { var t = []; return this.serializeArray().forEach(function (e) { t.push(encodeURIComponent(e.name) + "=" + encodeURIComponent(e.value)) }), t.join("&") }, t.fn.submit = function (e) { if (0 in arguments) this.bind("submit", e); else if (this.length) { var n = t.Event("submit"); this.eq(0).trigger(n), n.isDefaultPrevented() || this.get(0).submit() } return this } } (e), function () { try { getComputedStyle(void 0) } catch (e) { var n = getComputedStyle; t.getComputedStyle = function (t, e) { try { return n(t, e) } catch (r) { return null } } } } (), e });
/**
* SDK版本: v1.0
* @author: 推广技术部
* @copyright: 上海鲸团科技有限公司
* @日期: 2018-10-10
*/
var SDKConfig = {
version: "v1.5",
appid: '1106966663',
sdk_domain: 'https://account.jinsdk.com', // SDK接口域名
pay_domain: 'https://pay.jinsdk.com', // 支付接口域名
report_domain: 'https://s.jinsdk.com/qqxyx/api.php', // 数据上报接口域名
ProductCode: "47bf7b2b6f3bba55f5a8a3bafac102a2",
ProductKey: "adbd0af423938f903858697dcd2dc206",
product: '石器文明', // 产品名称
}
var whaleSDK = {
userInfo: {},
initReady: false, // 初始化完成
loginReady: { isLogin: 0 }, // 登录完成
// 初始化SDK
init: function (callback) {
var _selt = this;
// 配置公共参数
_selt.ReportParams.extArgs = _selt.userInfo.extArgs = _selt.getQueryString("ext_args") ? decodeURI(_selt.getQueryString("ext_args")) : "";
_selt.ReportParams.fromOpenId = _selt.userInfo.fromOpenId = _selt.getQueryString("fromOpenId") || "";
_selt.ReportParams.clickId = _selt.userInfo.clickId = _selt.getQueryString("qz_gdt") || "";
_selt.sdkParams.product_code = _selt.ReportParams.productCode = SDKConfig.ProductCode;
if (_selt.ReportParams.fromOpenId != '') _selt.ReportParams.extArgs = 'share';
//发起登录
this.login(function (isLogin) {
if (isLogin) {
_selt.initReady = true;
_selt.doLogin();
callback(true);
return;
}
callback(false);
});
// 获取设备信息
try {
mqq.device.getDeviceInfo(function (evt) {
console.log("@@SDK::getDeviceInfo", evt);
var device = evt.data;
var identifier = device.identifier ? device.identifier : ""; // 设备唯一标识
var model = device.modelVersion ? device.modelVersion : ""; // 机型
var osVerson = device.systemVersion ? device.systemVersion : ""; // 系统版本
_selt.sdkParams.uniqueid = _selt.ReportParams.identifier = _selt.userInfo.identifier = identifier;
_selt.ReportParams.modelVersion = _selt.userInfo.modelVersion = model;
});
} catch (error) {
console.log("@SDK::getDeviceInfo Error", error);
}
},
// 设置屏幕常亮
screenOpen: function () {
try {
mqq.device.setScreenStatus({
status: 1
}, function () { });
} catch (error) {
console.log("@@SDK::setScreenStatus Error", error)
}
},
login: function (callback) {
var _selt = this;
//异步方式获取登录态
window.getOpenKey(function (d) {
_selt.userInfo.username = _selt.userInfo.account = _selt.ReportParams.openId = window.OPEN_DATA.openid;
_selt.userInfo.pf = window.OPEN_DATA.pf;
_selt.sdkParams.os = _selt.getOsType();
_selt.sdkParams.pf = window.OPEN_DATA.pf || "";
_selt.sdkParams.appid = SDKConfig.appid;
_selt.ReportParams.openId = _selt.sdkParams.open_id = window.OPEN_DATA.openid || "";
_selt.sdkParams.openkey = window.OPEN_DATA.openkey || "";
_selt.sdkParams.loginType = window.OPEN_DATA.loginType || "";
_selt.sdkParams.via = window.OPEN_DATA.via || "";
_selt.sdkParams.equipmentos = window.OPEN_DATA.os || "";
_selt.sdkParams.equipmentname = window.OPEN_DATA.app || "";
_selt.sdkParams.version = window.OPEN_DATA.version || "";
_selt.sdkParams.subVersion = window.OPEN_DATA.subVersion || "";
_selt.sdkParams.appType = window.OPEN_DATA.appType || "";
_selt.sdkParams.source = ('QZONE-' + _selt.sdkParams.loginType).toUpperCase();
// SDK激活
_selt.sdkRequest(Links.active, _selt.sdkParams, function (data) {
if (data && data.code == 0) {
_selt.sdkParams.pay_channel = data.data.default_pay_channel;
callback(true);
} else {
console.log("@@SDK接口错误::", data.msg);
}
});
});
},
doLogin: function () {
var _selt = this;
_selt.sdkRequest(Links.login, _selt.sdkParams, function (data) {
if (data && data.code == 0) {
_selt.sdkParams.token = data.data.token; // 记录用户toekn
_selt.userInfo.uid = _selt.ReportParams.userId = data.data.uid; // 记录用户ID
_selt.reportData("activation"); // 上报激活
_selt.loginReady.isLogin = 1;
} else {
console.log("@@SDK接口错误::", data.msg);
}
});
},
getuser: function (callback) {
var _selt = this;
var val = 0;
_selt.userInfo.ostype = _selt.getOsType();
if (_selt.loginReady.isLogin) {
callback(_selt.userInfo);
} else {
Object.defineProperty(_selt.loginReady, 'isLogin', {
enumerable: true,
configurable: true,
get: function getter() {
return val;
},
set: function setter(newVal) {
//如果新设置的值跟之前的值是相等的,则不需要处理
if (newVal === val) { return; }
callback(_selt.userInfo);
}
});
}
},
addShortcut: function (info) {
try {
// 显示收藏桌面快捷方式的浮点图标或功能按钮
window.mqq.invoke("ui", "setOnAddShortcutHandler", {
"callback": mqq.callback(function () {
mqq.ui.addShortcut({
action: "web",
title: info.title ? info.title : "单机游戏",
icon: info.icon ? info.icon : window.OPEN_DATA.appicon,
url: window.OPEN_DATA.jumpurl,
callback: function (ret) {
console.log(ret);
}
});
}, false, true)
});
} catch (error) {
console.log("@@SDK错误::addShortcut", error);
}
},
share: function (info) {
try {
// 设置web页面分享的监听事件
mqq.invoke("ui", "setOnShareHandler", function (type) {
mqq.invoke("ui", "shareMessage", {
title: info.title ? info.title : "石器文明",
desc: info.desc ? info.desc : "经典玩法,登录即送VIP3",
share_type: type,
share_url: window.OPEN_DATA.shareurl,
image_url: info.icon ? info.icon : window.OPEN_DATA.appicon,
back: true
}, function (result) {
if (result && result.retCode == 0) {
alert("分享成功");
} else {
alert("分享取消");
}
});
});
//拉起分享菜单
mqq.ui.showShareMenu();
} catch (error) {
console.log("@@SDK错误::share", error);
}
},
//上报注册
reportRegister: function (callback) {
this.reportData("register");
if (callback) callback(true);
},
//上报登录
reportLogin: function (callback) {
this.reportData("login");
try {
window.reportLogin();
} catch (error) {
console.log("@@QQ上报登录失败::", error);
}
if (callback) callback(true);
},
//上报创角
createRole: function (roleInfo, callback) {
this.reportData("createRole", roleInfo);
try {
window.reportRegister();
} catch (error) {
console.log("@@QQ上报注册失败::", error);
}
if (callback) callback(true);
},
reportData: function (type, data) {
var _selt = this;
if (!_selt.initReady) {
return console.log("@@初始化SDK失败::", type);
}
try {
var postData = _selt.ReportParams;
postData.action = type;
postData.time = Date.parse(new Date()).toString().substr(0, 10);
if (type == 'createRole') {
postData.roleId = data ? data.role_id : "";
postData.server_id = data ? data.server_id : "";
postData.role_name = data ? data.role_name : "";
postData.server_name = data ? data.server_name : "";
}
console.log("@@SDK 数据上报:", postData);
$.ajax({
url: SDKConfig.report_domain,
type: "POST",
dataType: "json",
data: postData,
success: function () {
// console.log("@@SDK上报数据成功");
},
fail: function () {
console.log("@@SDK上报数据失败");
}
});
} catch (err) {
console.log("@@SDK 错误::reportData", err)
}
},
sdkRequest: function (uri, data, callback) {
var _selt = this;
if (_selt.sdkParams.uniqueid == '') { // 当uniqueid为空时使用openid
_selt.sdkParams.uniqueid = _selt.ReportParams.openId;
}
var postData = _selt.md5_sign(data); // 附上签名参数
console.log("@@SDK接口::" + uri, postData);
$.ajax({
url: uri,
type: "POST",
dataType: "json",
data: postData,
success: function (data) {
// console.log("@@SDK上报数据成功");
callback(data);
},
fail: function () {
console.log("@@SDK上报数据失败");
}
})
},
//支付
pay: function (orderInfo, callback) {
var _selt = this;
if (!_selt.initReady) {
return console.log("@@初始化SDK失败");
}
try {
window.getOpenKey(function (d) {
_selt.sdkParams.openkey = d.openkey ? d.openkey : window.OPEN_DATA.openkey; // 重新获取openkey
_selt.sdkParams.money = (orderInfo.amount / 100);
var postData = _selt.dataCopy(_selt.sdkParams, orderInfo);
//获取订单信息
_selt.sdkRequest(Links.order, postData, function (data) {
console.log("@@SDK支付::订单返回", data);
if (data && data.code == '3021') { // 余额不足
_selt.sdkParams.order_num = data.data.order_num;
//呼起充值流程
window.popPayTips({
version: "v2",
defaultScore: _selt.sdkParams.money * 10, // 单位分转成元,然后乘以货币比列
appid: window.OPEN_DATA.appid
});
} else if (data && data.code == '0') {
// 完成支付并发货成功
_selt.printf('充值成功');
callback(true);
} else {
console.log("@@SDK下单失败::", data.msg);
_selt.printf('支付失败:' + data.msg);
callback(false);
}
});
window.__paySuccess = function () {
//支付成功执行
orderInfo.err_code = '1';
orderInfo.status = true;
_selt.sdkRequest(Links.deliver, _selt.sdkParams, function (data) {
if (data && data.code == 0) {
_selt.printf('充值成功');
callback(true)
} else {
_selt.printf("充值失败:" + data.msg);
callback(false);
}
delete _selt.sdkParams.order_num; // 删除订单字段
});
}
window.__payError = function () {
orderInfo.err_code = '0';
_selt.delOrder();
callback(false);
}
window.__payClose = function () {
orderInfo.err_code = '-1';
_selt.delOrder();
callback(false);
}
});
} catch (error) {
console.log("@@SDK充值失败", error);
}
},
delOrder: function () {
var _selt = this;
_selt.sdkRequest(Links.delOrder, _selt.sdkParams, function (data) {
_selt.printf("充值失败");
delete _selt.sdkParams.order_num; // 删除订单字段
});
},
isMobile: function () {
return navigator.userAgent.match(/android|iphone|ipad|ipod|blackberry|meego|symbianos|windowsphone|ucbrowser/i);
},
isIos: function () {
return navigator.userAgent.match(/iphone|ipod|ios|ipad/i);
},
isAndroid: function () {
return navigator.userAgent.match(/android/i);
},
// 系统类型
getOsType: function () {
var ostype = "other";
if (this.isMobile()) {
if (this.isIos()) {
ostype = "ios";
} else if (this.isAndroid()) {
ostype = "android";
}
}
return ostype;
},
getQueryString: function (name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
if (r != null) {
return unescape(r[2]);
}
return null;
},
//接口签名,直接返回完整对象
md5_sign: function (obj) {
delete obj.sign;
obj.time = Date.parse(new Date().toString()) // 获取请求的时间戳秒
var keys = Object.keys(obj).sort();
var key_url = "";
for (var i = 0; i < keys.length; i++) {
if (keys[i] != 'sign') key_url += keys[i] + '=' + obj[keys[i]] + '&'
}
key_url = key_url + SDKConfig.ProductKey;
obj.sign = _md5(key_url);
return obj
},
isArray: function (arr) {
var toStr = Object.prototype.toString;
if (typeof Array.isArray === 'function') {
return Array.isArray(arr);
}
return toStr.call(arr) === '[object Array]';
},
isPlainObject: function (obj) {
var toStr = Object.prototype.toString;
var hasOwn = Object.prototype.hasOwnProperty;
if (!obj || toStr.call(obj) !== '[object Object]') {
return false;
}
var hasOwnConstructor = hasOwn.call(obj, 'constructor');
var hasIsPrototypeOf = obj.constructor && obj.constructor.prototype && hasOwn.call(obj.constructor.prototype, 'isPrototypeOf');
if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) {
return false;
}
var key;
for (key in obj) { /**/ }
return typeof key === 'undefined' || hasOwn.call(obj, key);
},
// 数据深拷贝
dataCopy: function (a, b) {
const that = this
let options, name, src, copy, copyIsArray, clone;
let target = arguments[0];
let i = 1;
let length = arguments.length;
let deep = false;
if (typeof target === 'boolean') {
deep = target;
target = arguments[1] || {};
i = 2;
}
if (target == null || (typeof target !== 'object' && typeof target !== 'function')) {
target = {};
}
for (; i < length; ++i) {
options = arguments[i];
if (options != null) {
for (name in options) {
src = target[name];
copy = options[name];
if (target !== copy) {
if (deep && copy && (that.isPlainObject(copy) || (copyIsArray = that.isArray(copy)))) {
if (copyIsArray) {
copyIsArray = false;
clone = src && that.isArray(src) ? src : [];
} else {
clone = src && that.isPlainObject(src) ? src : {};
}
target[name] = that.deepCopy(deep, clone, copy);
} else if (typeof copy !== 'undefined') {
target[name] = copy;
}
}
}
}
}
return target
},
printf: function (_txt) {
try {
var tips = {};
tips.text = _txt;
mqq.ui.showTips(tips);
} catch (error) {
console.log("@@SDK提示框错误::", error);
}
},
// 统计上报参数
ReportParams: {
action: null, // 必填,事件类型
openId: null, // 必填,微信openid,通过code去SDK接口换取
userId: '', // 必传,用户ID
fromOpenId: "",
productCode: null, // 必填,产品code
clickId: null, // 点击id
extArgs: null, // 必填 广告来源标识
time: null // 必填,请求的时间戳(秒)
},
// SDK上报参数
sdkParams: {
product_code: "", // 产品code
appid: "", // 小游戏appid
time: "", // 当前时间戳秒
uniqueid: '', // 设备唯一号
mac: '', // 网卡mac地址
idfa: '', // 苹果设备IDFA
open_id: "", // 用户openid
password: '', // 登录密码(微信免密)
source: 'QZONE', // 用户来源
token: '', // 登录成功返回
os: 'H5', // 系统类型
equipmentos: "", // 系统版本
equipmentname: "", // 手机型号
version: "", // SDK版本
package_code: '', // 渠道标识
sign: "", // 签名
unionid: '', // 用户Unionid,用于切支付
pay_channel: '', // 支付方式初始化接口返回
}
}
var Links = {
active: SDKConfig.sdk_domain + '/appInit.php', // SDK初始化接口
login: SDKConfig.sdk_domain + '/login.php', // SDK登录接口,获取用户平台信息
order: SDKConfig.pay_domain + '/pay.php', //订单接口
deliver: SDKConfig.pay_domain + '/order/order_complete.php', //扣费接口
delOrder: SDKConfig.pay_domain + '/order/order_cancel.php' //取消订单
}
/*md5*/
var rotateLeft = function (lValue, iShiftBits) { return (lValue << iShiftBits) | (lValue >>> (32 - iShiftBits)) }; var addUnsigned = function (lX, lY) { var lX4, lY4, lX8, lY8, lResult; lX8 = (lX & 2147483648); lY8 = (lY & 2147483648); lX4 = (lX & 1073741824); lY4 = (lY & 1073741824); lResult = (lX & 1073741823) + (lY & 1073741823); if (lX4 & lY4) { return (lResult ^ 2147483648 ^ lX8 ^ lY8) } if (lX4 | lY4) { if (lResult & 1073741824) { return (lResult ^ 3221225472 ^ lX8 ^ lY8) } else { return (lResult ^ 1073741824 ^ 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] | (128 << 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 }; function _md5(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 = 1732584193; b = 4023233417; c = 2562383102; d = 271733878; 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, 3614090360); d = FF(d, a, b, c, x[k + 1], S12, 3905402710); c = FF(c, d, a, b, x[k + 2], S13, 606105819); b = FF(b, c, d, a, x[k + 3], S14, 3250441966); a = FF(a, b, c, d, x[k + 4], S11, 4118548399); d = FF(d, a, b, c, x[k + 5], S12, 1200080426); c = FF(c, d, a, b, x[k + 6], S13, 2821735955); b = FF(b, c, d, a, x[k + 7], S14, 4249261313); a = FF(a, b, c, d, x[k + 8], S11, 1770035416); d = FF(d, a, b, c, x[k + 9], S12, 2336552879); c = FF(c, d, a, b, x[k + 10], S13, 4294925233); b = FF(b, c, d, a, x[k + 11], S14, 2304563134); a = FF(a, b, c, d, x[k + 12], S11, 1804603682); d = FF(d, a, b, c, x[k + 13], S12, 4254626195); c = FF(c, d, a, b, x[k + 14], S13, 2792965006); b = FF(b, c, d, a, x[k + 15], S14, 1236535329); a = GG(a, b, c, d, x[k + 1], S21, 4129170786); d = GG(d, a, b, c, x[k + 6], S22, 3225465664); c = GG(c, d, a, b, x[k + 11], S23, 643717713); b = GG(b, c, d, a, x[k + 0], S24, 3921069994); a = GG(a, b, c, d, x[k + 5], S21, 3593408605); d = GG(d, a, b, c, x[k + 10], S22, 38016083); c = GG(c, d, a, b, x[k + 15], S23, 3634488961); b = GG(b, c, d, a, x[k + 4], S24, 3889429448); a = GG(a, b, c, d, x[k + 9], S21, 568446438); d = GG(d, a, b, c, x[k + 14], S22, 3275163606); c = GG(c, d, a, b, x[k + 3], S23, 4107603335); b = GG(b, c, d, a, x[k + 8], S24, 1163531501); a = GG(a, b, c, d, x[k + 13], S21, 2850285829); d = GG(d, a, b, c, x[k + 2], S22, 4243563512); c = GG(c, d, a, b, x[k + 7], S23, 1735328473); b = GG(b, c, d, a, x[k + 12], S24, 2368359562); a = HH(a, b, c, d, x[k + 5], S31, 4294588738); d = HH(d, a, b, c, x[k + 8], S32, 2272392833); c = HH(c, d, a, b, x[k + 11], S33, 1839030562); b = HH(b, c, d, a, x[k + 14], S34, 4259657740); a = HH(a, b, c, d, x[k + 1], S31, 2763975236); d = HH(d, a, b, c, x[k + 4], S32, 1272893353); c = HH(c, d, a, b, x[k + 7], S33, 4139469664); b = HH(b, c, d, a, x[k + 10], S34, 3200236656); a = HH(a, b, c, d, x[k + 13], S31, 681279174); d = HH(d, a, b, c, x[k + 0], S32, 3936430074); c = HH(c, d, a, b, x[k + 3], S33, 3572445317); b = HH(b, c, d, a, x[k + 6], S34, 76029189); a = HH(a, b, c, d, x[k + 9], S31, 3654602809); d = HH(d, a, b, c, x[k + 12], S32, 3873151461); c = HH(c, d, a, b, x[k + 15], S33, 530742520); b = HH(b, c, d, a, x[k + 2], S34, 3299628645); a = II(a, b, c, d, x[k + 0], S41, 4096336452); d = II(d, a, b, c, x[k + 7], S42, 1126891415); c = II(c, d, a, b, x[k + 14], S43, 2878612391); b = II(b, c, d, a, x[k + 5], S44, 4237533241); a = II(a, b, c, d, x[k + 12], S41, 1700485571); d = II(d, a, b, c, x[k + 3], S42, 2399980690); c = II(c, d, a, b, x[k + 10], S43, 4293915773); b = II(b, c, d, a, x[k + 1], S44, 2240044497); a = II(a, b, c, d, x[k + 8], S41, 1873313359); d = II(d, a, b, c, x[k + 15], S42, 4264355552); c = II(c, d, a, b, x[k + 6], S43, 2734768916); b = II(b, c, d, a, x[k + 13], S44, 1309151649); a = II(a, b, c, d, x[k + 4], S41, 4149444226); d = II(d, a, b, c, x[k + 11], S42, 3174756917); c = II(c, d, a, b, x[k + 2], S43, 718787259); b = II(b, c, d, a, x[k + 9], S44, 3951481745); 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() };
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论