var api_token = 'crdwap';
let winH = window.location.host;
let pcLocation, serverHost, appletHost;
var imgpath = "https://img.crd.cn/";
var getHost = "";
if (['www.fuzhoujinrong.com', 'm.crd.cn', 'img.crd.cn', 'm921.crd.cn', 'p921.crd.cn'].includes(winH)) {
pcLocation = 'http://www.fuzhoujinrong.com/';
serverHost = 'https://newapplet.crd.cn/';
appletHost = "https://newmallapplet.crd.cn/api";
getHost = "https://mallapi.crd.cn/api";
} else {
pcLocation = 'http://crd.crd.hone.cn/';
serverHost = 'https://qasmallwapapi.hone.cn/';
appletHost = "https://newmallapplet.hone.cn/api";
getHost = "https://qasmallwapapi.hone.cn/api";
}
let fiterChannelID = ['R010501', 'R010502', 'R010504', 'R010505', 'R0201', 'R0301', 'R0302', 'R0303']; //付費渠道
var cloudBirdLink = [
{
channelId: "R0403",
channelPath: "https://uclient.yunque360.com/frame.html?company_id=cja1uk0l03qs24&yq_src=custom&custom_source=PC%E2%80%94%E5%BD%A9%E4%BF%A1",
channelName: "PC—彩信",
},
{
channelId: "R040201",
channelPath: "https://uclient.yunque360.com/frame.html?company_id=cja1uk0l03qs24&yq_src=custom&custom_source=PC%E2%80%94%E7%99%BE%E5%BA%A6%E2%80%94%E5%BC%80%E5%B1%8F",
channelName: "PC—百度—開屏",
},
{
channelId: "R040202",
channelPath: "https://uclient.yunque360.com/frame.html?company_id=cja1uk0l03qs24&yq_src=custom&custom_source=PC%E2%80%94%E7%99%BE%E5%BA%A6%E2%80%94%E5%93%81%E4%B8%93",
channelName: "PC—百度—品專",
},
{
channelId: "R040204",
channelPath: "https://uclient.yunque360.com/frame.html?company_id=cja1uk0l03qs24&yq_src=custom&custom_source=PC%E2%80%94%E7%99%BE%E5%BA%A6%E2%80%94SEM",
channelName: "PC—百度—SEM",
},
{
channelId: "R0404",
channelPath: "https://uclient.yunque360.com/frame.html?company_id=cja1uk0l03qs24&yq_src=custom&custom_source=PC%E2%80%94%E5%BE%AE%E5%8D%9A",
channelName: "PC—微博",
},
{
channelId: "R0503",
channelPath: "https://uclient.yunque360.com/frame.html?company_id=cja1uk0l03qs24&yq_src=custom&custom_source=M%E7%AB%99%E2%80%94%E5%BD%A9%E4%BF%A1",
channelName: "M站—彩信",
},
{
channelId: "R050201",
channelPath: "https://uclient.yunque360.com/frame.html?company_id=cja1uk0l03qs24&yq_src=custom&custom_source=M%E7%AB%99%E2%80%94%E7%99%BE%E5%BA%A6%E2%80%94%E5%BC%80%E5%B1%8F",
channelName: "M站—百度—開屏",
},
{
channelId: "R050202",
channelPath: "https://uclient.yunque360.com/frame.html?company_id=cja1uk0l03qs24&yq_src=custom&custom_source=M%E7%AB%99%E2%80%94%E7%99%BE%E5%BA%A6%E2%80%94%E5%93%81%E4%B8%93",
channelName: "M站—百度—品專",
},
{
channelId: "R050204",
channelPath: "https://uclient.yunque360.com/frame.html?company_id=cja1uk0l03qs24&yq_src=custom&custom_source=M%E7%AB%99%E2%80%94%E7%99%BE%E5%BA%A6%E2%80%94SEM",
channelName: "M站—百度—SEM",
},
{
channelId: "R0504",
channelPath: "https://uclient.yunque360.com/frame.html?company_id=cja1uk0l03qs24&yq_src=custom&custom_source=M%E7%AB%99%E2%80%94%E5%BE%AE%E5%8D%9A",
channelName: "M站—微博",
}
];
function setChannelStorage(channel, channelfullname = "") {
var channelItem = JSON.stringify({
key: new Date().getTime(), channelId: channel, channelFullName: channelfullname
});
console.log("___2.0___", channelItem);
localStorage.setItem("ChannelInfo", channelItem);
}
/**************/
/*JS函數庫*/
/**************/
/*獲取字符串長度 中文算2 英文算1*/
function GetCharLength(str) {
var iLength = 0;
for (var i = 0; i < str.length; i++) {
if (str.charCodeAt(i) > 255) {
iLength += 2;
}
else {
iLength += 1;
}
}
return iLength;
}
/*獲取網頁中的控件*/
var $$ = function (ID) { return document.getElementById(ID); };
/*去除字符串兩邊的空格*/
String.prototype.Trim = function () {
return this.replace(/(^\s*)|(\s*$)/g, "");
}
/*字符串超出省略*/
String.prototype.cutstr = function (len) {
var restr = this;
var wlength = this.replace(/[^\x00-\xff]/g, "**").length;
if (wlength > len) {
for (var k = len / 2; k < this.length; k++) {
if (this.substr(0, k).replace(/[^\x00-\xff]/g, "**").length >= len) {
restr = this.substr(0, k) + "...";
break;
}
}
}
return restr;
}
/** 在字符串末尾追加字符串 **/
String.prototype.append = function (str) {
return this.concat(str);
}
/** 比較兩個字符串是否相等,也可以直接用 == 進行比較 **/
String.prototype.equal = function (str) {
if (this.length != str.length) {
return false;
}
else {
for (var i = 0; i < this.length; i++) {
if (this.charAt(i) != str.charAt(i)) {
return false;
}
}
return true;
}
}
/** 保留數字 **/
String.prototype.getNum = function () {
return this.replace(/[^d]/g, "");
}
/** 保留字母 **/
String.prototype.getEn = function () {
return this.replace(/[^A-Za-z]/g, "");
}
/** 保留中文 **/
String.prototype.getCn = function () {
return this.replace(/[^u4e00-u9fa5uf900-ufa2d]/g, "");
}
// String轉化為Number
String.prototype.ToInt = function () {
return isNaN(parseInt(this)) ? this.toString() : parseInt(this);
};
/*重定義精確度函數*/
Number.prototype.toFixed = function (len) {
var a = Math.round(this * Math.pow(10, len)) / Math.pow(10, len)
var b = a + "";
var c = b.split(".");
var d = "0000000000";
if (c.length == 1) {
if (len == 0)
b = c[0];
else
b = c[0] + "." + d.substr(0, len);
}
else {
b = c[0] + "." + (c[1] + d).substr(0, len);
}
return b;
}
/*自定義去小數末尾0的方法*/
Number.prototype.Save = function (MinLen) {
var Num1 = this.toFixed(4).split(".");
var Num2 = Num1[1]
var MaxLen = Num2.length;
var Len = MinLen;
for (var i = MaxLen; i >= MinLen; i--) {
if (Num2.substr(i - 1, 1) != "0") {
Len = i;
break;
}
}
return Num1[0] + "." + Num1[1].substr(0, Len);
}
/*獲取網頁地址欄參數*/
function QueryStringUrl(key) {
var locString = location.search;
var reg = new RegExp("(\\?|\\&)" + key + "=([^\\&]*)(\\&?)", "i").exec(locString);
if (reg != null) {
return RegExp.$2;
}
else {
return "";
}
}
/*設置網頁地址欄參數*/
function changeURLPar(destiny, par, par_value) {
var pattern = par + '=([^&]*)';
var replaceText = par + '=' + par_value;
if (destiny.match(pattern)) {
var tmp = '/' + par + '=[^&]*/';
tmp = destiny.replace(eval(tmp), replaceText);
return (tmp);
} else {
if (destiny.match('[\?]')) {
return destiny + '&' + replaceText;
} else {
return destiny + '?' + replaceText;
}
}
return destiny + '\n' + par + '\n' + par_value;
}
/*設置網頁地址*/
function setPath(currentUrl, name, pvalue) {
if (currentUrl.indexOf("?") > 0) {
if (currentUrl.indexOf(name) > 0) {
currentUrl = changeURLPar(currentUrl, name, pvalue);
} else {
currentUrl += "&" + name + "=" + pvalue;
}
} else {
if (currentUrl.indexOf(name) > 0) {
currentUrl = changeURLPar(currentUrl, name, pvalue);
} else {
currentUrl += "?" + name + "=" + pvalue;
}
}
return currentUrl;
}
/*獲取客戶瀏覽器類型*/
function BrowserType() {
var IeType = "";
try {
var _Agt = navigator.userAgent.toLowerCase();
var _bs = /(firefox|netscape|opera|chrome|msie|safari).?[\d\.]+/.exec(_Agt);
IeType = _bs[0];
}
catch (e) {
IeType = "Browser_Error";
}
return IeType;
}
/*驗證手機號碼*/
function RegMobileNo(strMobileNo) {
var regMobileNo = /^(13[0-9]|14[0-9]|15[0-9]|16[0-9]|17[0-9]|18[0-9]|19[0-9])[0-9]{8}$/;
if (regMobileNo.test(strMobileNo)) {
return true;
}
else {
return false;
}
}
/*判斷是否為空*/
function isEmpty(str) {
if (str == null || typeof str == "undefined" || str.trim() == "") {
return true;
} else {
return false;
}
}
/*驗證郵箱*/
function RegEmail(strEmail) {
var regEmail = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
if (regEmail.test(strEmail)) {
return true;
}
else {
return false;
}
}
/*驗證中文*/
function RegChina(strChina) {
var regChina = /^[\u0391-\uFFE5]+$/;
if (regChina.test(strChina)) {
return true;
}
else {
return false;
}
}
/*驗證QQ*/
function RegQq(strQq) {
var regQq = /^[^0]\d{3,10}$/;
if (regQq.test(strQq)) {
return true;
}
else {
return false;
}
}
/*驗證手機*/
function RegPhoneNumber(strPhoneNumber) {
var regPhoneNumber = /^(((13[0-9]{1})|15[0-9]{1}|18[0-9]{1}|14[0-9]{1}|)+\d{8})+$/;
if (regPhoneNumber.test(strPhoneNumber)) {
return true;
}
else {
return false;
}
}
/*日期比較*/
function CompareDate(parDate1, parDate2) {
var strDate1 = parDate1.split("-");
var strDate2 = parDate2.split("-");
var strYear1 = strDate1[0];
var strMonth1 = strDate1[1];
var strDay1 = strDate1[2];
var strYear2 = strDate2[0];
var strMonth2 = strDate2[1];
var strDay2 = strDate2[2];
var datDate1 = new Date(strYear1, strMonth1, strDay1);
var datDate2 = new Date(strYear2, strMonth2, strDay2);
if (datDate2 <= datDate1) {
return true;
}
else {
return false;
}
}
/*驗證是否為錢單位*/
function RegCurrency(strCurrency) {
var regsCurrency = /^\d+(\.\d+)?$/;
if (regsCurrency.test(strCurrency)) {
return true;
}
else {
return false;
}
}
/*驗證數字*/
function RegNumber(strNumber) {
var regNumber = /^\d+$/;
if (regNumber.test(strNumber)) {
return true;
}
else {
return false;
}
}
/*驗證數值*/
function RegDouble(strDouble) {
var regDouble = /^[-\+]?\d+(\.\d+)?$/;
if (regDouble.test(strDouble)) {
return true;
}
else {
return false;
}
}
/*==
根據〖中華人民共和國國家標準 GB 11643-1999〗中有關公民身份號碼的規定,公民身份號碼是特征組合碼,由十七位數字本體碼和一位數字校驗碼組成。排列順序從左至右依次為:六位數字地址碼,八位數字出生日期碼,三位數字順序碼和一位數字校驗碼。
地址碼表示編碼對象常住戶口所在縣(市、旗、區)的行政區劃代碼。
出生日期碼表示編碼對象出生的年、月、日,其中年份用四位數字表示,年、月、日之間不用分隔符。
順序碼表示同一地址碼所標識的區域范圍內,對同年、月、日出生的人員編定的順序號。順序碼的奇數分給男性,偶數分給女性。
校驗碼是根據前面十七位數字碼,按照ISO 7064:1983.MOD 11-2校驗碼計算出來的檢驗碼。
出生日期計算方法。
15位的身份證編碼首先把出生年擴展為4位,簡單的就是增加一個19或18,這樣就包含了所有1800-1999年出生的人;
2000年后出生的肯定都是18位的了沒有這個煩惱,至于1800年前出生的,那啥那時應該還沒身份證號這個東東,⊙﹏⊙b汗...
下面是正則表達式:
出生日期1800-2099 (18|19|20)?\d{2}(0[1-9]|1[12])(0[1-9]|[12]\d|3[01])
身份證正則表達式 /^\d{6}(18|19|20)?\d{2}(0[1-9]|1[12])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i
15位校驗規則 6位地址編碼+6位出生日期+3位順序號
18位校驗規則 6位地址編碼+8位出生日期+3位順序號+1位校驗位
校驗位規則 公式:∑(ai×Wi)(mod 11)……………………………………(1)
公式(1)中:
i----表示號碼字符從由至左包括校驗碼在內的位置序號;
ai----表示第i位置上的號碼字符值;
Wi----示第i位置上的加權因子,其數值依據公式Wi=2^(n-1)(mod 11)計算得出。
i 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
Wi 7 9 10 5 8 4 2 1 6 3 7 9 10 5 8 4 2 1
*/
//身份證號合法性驗證
//支持15位和18位身份證號
//支持地址編碼、出生日期、校驗位驗證
function RegIDCard(code) {
var city = { 11: "北京", 12: "天津", 13: "河北", 14: "山西", 15: "內蒙古", 21: "遼寧", 22: "吉林", 23: "黑龍江 ", 31: "上海", 32: "江蘇", 33: "浙江", 34: "安徽", 35: "福建", 36: "江西", 37: "山東", 41: "河南", 42: "湖北 ", 43: "湖南", 44: "廣東", 45: "廣西", 46: "海南", 50: "重慶", 51: "四川", 52: "貴州", 53: "云南", 54: "西藏 ", 61: "陜西", 62: "甘肅", 63: "青海", 64: "寧夏", 65: "新疆", 71: "臺灣", 81: "香港", 82: "澳門", 91: "國外 " };
var tip = "";
var pass = true;
if (!code || !/^\d{6}(18|19|20)?\d{2}(0[1-9]|1[12])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i.test(code)) {
tip = "身份證號格式錯誤";
pass = false;
}
else if (!city[code.substr(0, 2)]) {
tip = "地址編碼錯誤";
pass = false;
}
else {
//18位身份證需要驗證最后一位校驗位
if (code.length == 18) {
code = code.split('');
//∑(ai×Wi)(mod 11)
//加權因子
var factor = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
//校驗位
var parity = [1, 0, 'X', 9, 8, 7, 6, 5, 4, 3, 2];
var sum = 0;
var ai = 0;
var wi = 0;
for (var i = 0; i < 17; i++) {
ai = code[i];
wi = factor[i];
sum += ai * wi;
}
var last = parity[sum % 11];
if (parity[sum % 11] != code[17]) {
tip = "校驗位錯誤";
pass = false;
}
}
}
//if (!pass) alert(tip);
return pass;
}
//檢查是否是日期格式
function isDate(datestr) {
var result = datestr.match(/((^((1[8-9]\d{2})|([2-9]\d{3}))(-)(10|12|0?[13578])(-)(3[01]|[12][0-9]|0?[1-9])$)|(^((1[8-9]\d{2})|([2-9]\d{3}))(-)(11|0?[469])(-)(30|[12][0-9]|0?[1-9])$)|(^((1[8-9]\d{2})|([2-9]\d{3}))(-)(0?2)(-)(2[0-8]|1[0-9]|0?[1-9])$)|(^([2468][048]00)(-)(0?2)(-)(29)$)|(^([3579][26]00)(-)(0?2)(-)(29)$)|(^([1][89][0][48])(-)(0?2)(-)(29)$)|(^([2-9][0-9][0][48])(-)(0?2)(-)(29)$)|(^([1][89][2468][048])(-)(0?2)(-)(29)$)|(^([2-9][0-9][2468][048])(-)(0?2)(-)(29)$)|(^([1][89][13579][26])(-)(0?2)(-)(29)$)|(^([2-9][0-9][13579][26])(-)(0?2)(-)(29)$))/);
if (result == null) {
return false;
}
return true;
}
//判斷輸入的字符是否為中文
function IsChinese(str) {
if (str.length != 0) {
var reg = /^[\u0391-\uFFE5]+$/;
if (!reg.test(str)) {
return false;
}
}
return true;
}
/*驗證日期*/
function RegDate(strDate) {
var regDate = /^([0-9]{1,2})[./]{1}([0-9]{1,2})[./]{1}([0-9]{4})$/;
if (regDate.test(strDate)) {
return true;
}
else {
return false;
}
}
//清除字符串兩頭的空格
function Trim(str) {
return str.replace(/(^\s*)|(\s*$)/g, "");
}
/*回車事件*/
function EventEnter(evt, para, option) {
evt = evt ? evt : (window.event ? window.event : null);
if (evt.keyCode == 13) {
switch (para) {
case 0:
$$(option).focus();
break;
case 1:
eval(option);
break;
}
return false;
}
}
/*禁用F5按鍵*/
var booStopF5 = true;
/*屏蔽回車和F5*/
function CheckKeyDown(e) {
e = e || window.event;
if ((e.which || e.keyCode) == 116 && booStopF5) {
if (e.preventDefault) {
e.preventDefault();
}
else {
event.keyCode = 0;
e.returnValue = false;
}
}
else {
var evtnode = e.srcElement ? e.srcElement : e.target;
if ((e.which || e.keyCode) == 13 && evtnode.nodeName != "TEXTAREA") {
return false;
}
}
}
/*網頁路徑*/
var strWebPath = "";
/*檢查路徑*/
function CheckPath() {
var Path = "";
var CurrentPath = window.location.href.split("&")[0].split("/");
var len1 = 4;
if (document.domain.indexOf("localhost") == -1) {
len1 = 3;
}
var len = CurrentPath.length - len1;
for (var i = 0; i < len; i++) {
Path += "../";
}
return Path;
}
/*下拉框初始化*/
function DropInit(ID, Value, Text) {
$$(ID).options.length = 0;
$$(ID).options.add(document.createElement("OPTION"));
$$(ID).options[0].text = Text;
$$(ID).options[0].value = Value;
}
/*空函數*/
function NullFunction() {
;
}
/*分離鼠標事件*/
function DetachMouseOutEvent(ID) {
$$(ID).onmouseout =
function () {
NullFunction();
}
}
/*用戶控件絕對定位*/
function PositionLayer(SourceID, DestID, OffsetTop, OffsetLeft) {
var tbMenu = document.getElementById(SourceID);
var tdId = document.getElementById(DestID);
var MenuStyle = tbMenu.style;
var MeTop = tdId.offsetTop;
var MeLeft = tdId.offsetLeft;
while (tdId = tdId.offsetParent) {
MeTop += tdId.offsetTop;
MeLeft += tdId.offsetLeft;
}
MenuStyle.top = Number(MeTop + OffsetTop) + "px";
MenuStyle.left = Number(MeLeft + OffsetLeft) + "px";
}
/*加載JS*/
function LoadJsFile(strUrl) {
var datTime = new Date();
var eleUrl = document.createElement("script");
eleUrl.setAttribute("type", "text/javascript");
eleUrl.setAttribute("src", strUrl + "?Time=" + datTime.getTime());
document.body.appendChild(eleUrl);
}
/*關閉當前窗口*/
function CloseWindow() {
window.opener = null;
window.self.close();
}
/*關閉父窗口*/
function CloseParentWindow() {
top.window.opener = null;
top.window.self.close();
}
/*清除文本框內容*/
function ClearInputText(strID, strText) {
if ($$(strID).value == strText) {
$$(strID).value = "";
}
}
//文本框只能輸入數字
function clearNoNum(event, obj) {
//響應鼠標事件,允許左右方向鍵移動
event = window.event || event;
if (event.keyCode == 37 | event.keyCode == 39) {
return;
}
//先把非數字的都替換掉,除了數字
obj.value = obj.value.replace(/[^\d]/g, "");
if (obj.min != null && obj.min != undefined) {
if (!isNaN(obj.min)) {
var min = parseInt(obj.min);
if (parseInt(obj.value) < min)
obj.value = min;
}
}
}
//文本框只能輸入數字和.
function clearNoNums(event, obj) {
//響應鼠標事件,允許左右方向鍵移動
event = window.event || event;
if (event.keyCode == 37 | event.keyCode == 39) {
return;
}
//先把非數字的都替換掉,除了數字和.
obj.value = obj.value.replace(/[^\d.]/g, "");
//必須保證第一個為數字而不是.
obj.value = obj.value.replace(/^\./g, "");
//保證只有出現一個.而沒有多個.
obj.value = obj.value.replace(/\.{2,}/g, ".");
//保證.只出現一次,而不能出現兩次以上
obj.value = obj.value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
}
function checkNums(obj) {
//為了去除最后一個.
obj.value = obj.value.replace(/\.$/g, "");
}
//清除所有文本框和下拉框內容
function clearVal() {
$("input").val('');
$("select").val('');
}
/*************/
/*XmlHttp調用*/
/*************/
/*xmlHttp調用[異步]*/
function RequestXML(strUrl, strPostValue, strFuntionName) {
var xmlHttp;
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHttp");
}
else {
if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
}
xmlHttp.open("Post", strUrl, true)
xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlHttp.onreadystatechange = function () {
ResponseXML(xmlHttp, strFuntionName)
}
xmlHttp.send(strPostValue);
}
/*xmlHttp調用[同步]*/
function RequestXML1(strUrl, strPostValue, strFuntionName) {
var xmlHttp;
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHttp");
}
else {
if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
}
xmlHttp.open("Post", strUrl, false)
xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlHttp.send(strPostValue);
/*結果處理*/
if (xmlHttp.readyState == 4) {
var intStatus = xmlHttp.status;
if (intStatus == 200) {
eval(strFuntionName);
}
else {
alert("程序異常,找不到被調用的頁面。");
}
}
}
/*xmlHttp結果*/
function ResponseXML(xmlHttp, strFuntionName) {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
eval(strFuntionName);
}
else {
if (xmlHttp.readyState == 4 && xmlHttp.status == 404) {
alert("程序異常,找不到被調用的頁面。");
}
}
}
/**********/
/*分頁函數*/
/**********/
/*當前頁號,每頁記錄數,總記錄數*/
var intPageIndex = 1;
var intPageSize = 20;
var intRecordCount = 0;
/*頁碼列表*/
function PageList(strFunName) {
/*總頁數*/
var intPageCount = parseInt((parseInt(intRecordCount) + parseInt(intPageSize) - 1) / parseInt(intPageSize));
if (intPageCount <= 1) {
return "";
}
/*頁碼距*/
var intPageCurrent = 10;
/*起始頁碼*/
var intStartPage = (parseInt((intPageIndex + intPageCurrent - 1) / intPageCurrent) - 1) * intPageCurrent + 1;
/*結束頁碼*/
var intEndPage = intStartPage + intPageCurrent - 1;
if (intPageIndex % intPageCurrent == 0) {
intStartPage++;
intEndPage++;
}
if (intPageIndex % intPageCurrent - 1 == 0 && intPageIndex != 1) {
intStartPage--;
intEndPage--;
}
if (intEndPage >= intPageCount) {
intEndPage = intPageCount;
}
/*上一頁,下一頁*/
var intUpPage = intPageIndex - 1;
var intDownPage = intPageIndex + 1;
var strUpPage = "";
var strDownPage = "";
if (intUpPage < 1) {
intUpPage = 1;
strUpPage = "";
}
if (intDownPage > intPageCount) {
intDownPage = intPageCount;
strDownPage = "";
}
/*生成頁碼列表*/
var strPageList = "
" + strUpPage;
for (var i = intStartPage; i <= intEndPage; i++) {
if (intPageIndex == i) {
/*當前頁碼*/
strPageList += "
" + i + "";
}
else {
strPageList += "
" + i + "";
}
}
strPageList = strPageList + strDownPage + "
";
strPageList += "總共:" + intRecordCount + " 條 共:" + intPageCount + " 頁 當前第:" + intPageIndex + " 頁";
return strPageList;
}
/***前臺 頁碼列表***/
function PageListUi(strFunName) {
/***總頁數***/
var intPageCount = parseInt((parseInt(intRecordCount) + parseInt(intPageSize) - 1) / parseInt(intPageSize));
if (intPageCount <= 1) {
return "";
}
/***頁碼距***/
var intPageCurrent = 5;
/***起始頁碼***/
var intStartPage = (parseInt((intPageIndex + intPageCurrent - 1) / intPageCurrent) - 1) * intPageCurrent + 1;
/***結束頁碼***/
var intEndPage = intStartPage + intPageCurrent - 1;
if (intPageIndex % intPageCurrent == 0) {
intStartPage++;
intEndPage++;
}
if (intPageIndex % intPageCurrent - 1 == 0 && intPageIndex != 1) {
intStartPage--;
intEndPage--;
}
if (intEndPage >= intPageCount) {
intEndPage = intPageCount;
}
/***上一頁,下一頁***/
var intUpPage = intPageIndex - 1;
var intDownPage = intPageIndex + 1;
var strUpPage = "上一頁\n";
var strDownPage = "下一頁\n";
if (intUpPage < 1) {
intUpPage = 1;
strUpPage = "";
}
if (intDownPage > intPageCount) {
intDownPage = intPageCount;
strDownPage = "";
}
/***生成頁碼列表***/
var strPageList = "";
for (var i = intStartPage; i <= intEndPage; i++) {
if (intPageIndex == i) {
/***當前頁碼***/
strPageList += "" + i + "\n";
}
else {
strPageList += "" + i + "\n";
}
}
strPageList = "\n" + strUpPage + strPageList + strDownPage + "
";
return strPageList;
}
///
/// 去字符串前面的0
///
///
///
function OutputZero(str) {
//var i = 0;
//if (str.length > 0 && str.indexOf(".") < 0)
//{
// while (str.substring(i, 1) == "0")
// {
// str = str.substring(i + 1, str.length - 1);
// }
//}
str = str.replace(/\b(0+)/gi, "");
return str;
}
/**
* 獲取當前頁面相對url地址
* @returns {}
*/
function GetCurrentUrl() {
var url = document.location.toString();
var arrUrl = url.split("http://");
var start = arrUrl[1].indexOf("/");
var relUrl = arrUrl[1].substring(start); //stop省略,截取從start開始到結尾的所有字符
/*if (relUrl.indexOf("?") != -1) {
relUrl = relUrl.split("?")[0];
}*/
return escape(relUrl);
}
/**
* 生成唯一標識UUID
* @returns {}
*/
function generateUUID() {
var d = new Date().getTime();
if (window.performance && typeof window.performance.now === "function") {
d += performance.now(); //use high-precision timer if available
}
var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = (d + Math.random() * 16) % 16 | 0;
d = Math.floor(d / 16);
return (c == 'x' ? r : (r & 0x3 | 0x8)).toString(16);
});
return uuid;
}
function createUUID(len, radix) {
//第一個參數長度,第二個參數進制
let chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
let uuid = [], i;
radix = radix || chars.length;
if (len) {
// Compact form
for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix];
} else {
// rfc4122, version 4 form
let r;
// rfc4122 requires these characters
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
uuid[14] = '4';
// Fill in random data. At i==19 set the high bits of clock sequence as
// per rfc4122, sec. 4.1.5
for (i = 0; i < 36; i++) {
if (!uuid[i]) {
r = 0 | Math.random() * 16;
uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
}
}
}
let timestamp = new Date().getTime();
return timestamp + '-' + uuid.join('');
}
function setCookie(c_name, value, expire_days) {
let expires = "";
if (expire_days) {
let exDate = new Date();
exDate.setDate(exDate.getDate() + expire_days);
expires = ';expires=' + exDate.toUTCString();
}
document.cookie = c_name + '=' + escape(value) + expires + ';path=/'; //encodeURIComponent(value)
}
function getCookie(c_name) {
let c_start = null;
let c_end = null;
if (document.cookie.length > 0) {
c_start = document.cookie.indexOf(c_name + '=');
if (c_start !== -1) {
c_start = c_start + c_name.length + 1;
c_end = document.cookie.indexOf(';', c_start);
if (c_end === -1) c_end = document.cookie.length;
return unescape(document.cookie.substring(c_start, c_end));
}
}
return '';
}
function checkCookie(c_name) {
let username = getCookie(c_name);
if (username !== null && username !== '') {
return true;
} else {
return false;
}
}
function clearCookie(c_name) {
setCookie(c_name, '', -1);
}
// localStorage增刪改查
// 切換站點
let targetHost;
let ua = navigator.userAgent.toLowerCase();
function changePort() {
let curUrlPath = window.location.pathname;
window.location.href = targetHost + '' + curUrlPath;
}
function docReady(fn) {
if (document.readyState === 'complete' || document.readyState === 'interactive') {
fn()
} else {
document.addEventListener('DOMContentLoaded', fn);
}
}
docReady(async function () {
var isWXWork = ua.match(/wxwork/i) == 'wxwork'
var isWeixin = !isWXWork && ua.match(/micromessenger/i) == 'micromessenger'
var isMobile = false
var isDesktop = false
if (navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|IEMobile)/i)) {
isMobile = true
} else {
isDesktop = true
}
//console.log("設備:", "isWXWork", isWXWork, "isWeixin", isWeixin, "isMobile", isMobile, "isDesktop", isDesktop);
if (isDesktop) { // 在PC端打開了 m.crd.cn || m.crd.hone.cn
if ($(window).width() < 1002 && (winLocHost == 'www.fuzhoujinrong.com' || winLocHost == 'crd.crd.hone.cn')) {
targetHost = winLocHost == 'www.fuzhoujinrong.com' ? 'https://m.crd.cn' : 'http://m.crd.hone.cn';
changePort();
}
if ($(window).width() >= 1002 && (winLocHost == 'm.crd.cn' || winLocHost == 'm.crd.hone.cn')) {
targetHost = winLocHost == 'm.crd.cn' ? 'http://www.fuzhoujinrong.com' : 'http://crd.crd.hone.cn';
changePort();
}
} else { // 非PC端打開 www.fuzhoujinrong.com || m.crd.cn
if (winLocHost == 'www.fuzhoujinrong.com' || winLocHost == 'crd.crd.hone.cn') {
targetHost = winLocHost == 'www.fuzhoujinrong.com' ? 'https://m.crd.cn' : 'http://m.crd.hone.cn';
changePort();
}
}
})
$(window).resize(function () {
// 優化方向,事件節流
if ($(window).width() < 1002) {
let wlh = window.location.host;
if (wlh == 'www.fuzhoujinrong.com' || wlh == 'crd.crd.hone.cn') {
targetHost = wlh == 'www.fuzhoujinrong.com' ? 'http://www.fuzhoujinrong.com' : 'http://crd.crd.hone.cn';
changePort();
}
} else {
let wlh = window.location.host;
if (wlh == 'm.crd.cn' || wlh == 'm.crd.hone.cn') {
targetHost = wlh == 'm.crd.cn' ? 'http://www.fuzhoujinrong.com' : 'http://crd.crd.hone.cn';
changePort();
}
}
});
function setChannelStorage(channel, channelfullname = "") {
var channelItem = JSON.stringify({
key: new Date().getTime(), channelId: channel, channelFullName: channelfullname
});
localStorage.setItem("ChannelInfo", channelItem);
}
function sendToken(callback) {
let id = createUUID(18, 16);//getOpenid();
const xhr = new XMLHttpRequest();
let str = JSON.stringify({
"OpenId": id,
"Sign": md5(id + "" + api_token)
})
xhr.open("POST", getHost + "/UniApp/GetToken");
xhr.setRequestHeader("Content-Type", "application/json; charset=utf-8");
xhr.send(str);
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
if (xhr.status >= 200 && xhr.status < 300) {
const res = JSON.parse(xhr.response);
localStorage.setItem('Authorization', res.Value.AccessToken);
localStorage.setItem('X-Authorization', res.Value.RefreshToken);
xhr.onreadystatechange = function () { }; //清理事件響應函數
xhr.abort(); //中止請求
callback(res);
}
}
}
}
// Ajax method, url, data
function sendAjax(options, callback) {
if (options.url.indexOf("http") != -1) { } else {
options.url = getHost + options.url;
}
const xhr = new XMLHttpRequest();
if (localStorage.getItem("Authorization")) {
xhr.open(options.method, options.url);
xhr.setRequestHeader("Authorization", "Bearer " + localStorage.getItem("Authorization"));
xhr.setRequestHeader("X-Authorization", "Bearer " + localStorage.getItem("X-Authorization"));
xhr.setRequestHeader("Content-Type", options.type ? options.type : "application/json;charset=utf-8");
if (options.data && options.data != null) {
let str = JSON.stringify(options.data);
xhr.send(str);
} else {
xhr.send();
}
xhr.onreadystatechange = function () {
if (xhr.status == 401) {
xhr.onreadystatechange = function () { }; //清理事件響應函數
//xhr.abort(); //中止請求
sendToken(function (res) {
xhr.open(options.method, options.url);
xhr.setRequestHeader("Authorization", "Bearer " + localStorage.getItem("Authorization"));
xhr.setRequestHeader("X-Authorization", "Bearer " + localStorage.getItem("X-Authorization"));
xhr.setRequestHeader("Content-Type", options.type ? options.type : "application/json;charset=utf-8");
if (options.data && options.data != null) {
let str = JSON.stringify(options.data);
xhr.send(str);
} else {
xhr.send();
}
xhr.onreadystatechange = function () {
if (xhr.status == 401) {
xhr.onreadystatechange = function () { }; //清理事件響應函數
xhr.abort(); //中止請求
} else {
if (xhr.readyState === 4) {
if (xhr.status >= 200 && xhr.status < 300) {
const res = JSON.parse(xhr.response);
callback(res);
}
}
}
}
});
} else {
if (xhr.readyState === 4) {
if (xhr.status >= 200 && xhr.status < 300) {
const res = JSON.parse(xhr.response);
callback(res);
}
}
}
}
} else {
sendToken(function (res) {
xhr.open(options.method, options.url);
xhr.setRequestHeader("Authorization", "Bearer " + localStorage.getItem("Authorization"));
xhr.setRequestHeader("X-Authorization", "Bearer " + localStorage.getItem("X-Authorization"));
xhr.setRequestHeader("Content-Type", options.type ? options.type : "application/json;charset=utf-8");
if (options.data && options.data != null) {
let str = JSON.stringify(options.data);
xhr.send(str);
} else {
xhr.send();
}
xhr.onreadystatechange = function () {
if (xhr.status == 401) {
xhr.onreadystatechange = function () { }; //清理事件響應函數
//xhr.abort(); //中止請求
sendToken(function (res) {
xhr.open(options.method, options.url);
xhr.setRequestHeader("Authorization", "Bearer " + localStorage.getItem("Authorization"));
xhr.setRequestHeader("X-Authorization", "Bearer " + localStorage.getItem("X-Authorization"));
xhr.setRequestHeader("Content-Type", options.type ? options.type : "application/json;charset=utf-8");
if (options.data && options.data != null) {
let str = JSON.stringify(options.data);
xhr.send(str);
} else {
xhr.send();
}
xhr.onreadystatechange = function () {
if (xhr.status == 401) {
xhr.onreadystatechange = function () { }; //清理事件響應函數
xhr.abort(); //中止請求
} else {
if (xhr.readyState === 4) {
if (xhr.status >= 200 && xhr.status < 300) {
const res = JSON.parse(xhr.response);
callback(res);
}
}
}
}
});
} else {
if (xhr.readyState === 4) {
if (xhr.status >= 200 && xhr.status < 300) {
const res = JSON.parse(xhr.response);
callback(res);
}
}
}
}
});
}
}
function sendChannel() {
let PcOpenId, Channel;
if (localStorage.getItem("PcOpenId")) {
PcOpenId = localStorage.getItem("PcOpenId");
} else {
PcOpenId = createUUID(18, 16);
localStorage.setItem("PcOpenId", PcOpenId);
// this.getToken(PcOpenId);
}
let host = window.location.host;
let routerPath = window.location.href;
let search = window.location.search;
let pathName = window.location.pathname;
if (search.length !== '') {
let newSearch = search.substr(search.indexOf('?') + 1);
let searchArray = [];
if (newSearch.includes('&')) {
searchArray = newSearch.split('&').filter(x => x != '');
} else {
searchArray = [newSearch];
}
if (searchArray.length > 0) {
searchArray.forEach(item => {
if (item.includes('channel=')) {
Channel = item.substr(item.indexOf('=') + 1);
}
});
}
}
console.log("___///___", Channel);
if (Channel) {
$.ajax({
type: "POST",
// timeout: 10000,
url: "/memberinfo/ChannelLabelReport",
dataType: "json",
data: {
channelId: Channel,
cookieId: PcOpenId
},
async: false,
beforeSend: function () { },
success: function (result) {
console.log("上報PcOpenId,Channel", PcOpenId, Channel);
getChannel();
},
error: function (msg) {
console.log("send Channel error!");
},
complete: function (data) { }
});
// 前端緩存24H
setChannelStorage(Channel);
} else {
getChannel();
}
}
function getChannel(mobile) {
let options = {
method: 'GET',
url: getHost + "/ChannelLabel/GetChannelLabelByOpenId?openid=" + localStorage.getItem('PcOpenId'),
data: null,
};
if (mobile) {
options.url = getHost + "/ChannelLabel/GetChannelLabelByMobile?mobile=" + mobile;
}
sendAjax(options, function (res) {
if (res.Success && res.Value && res.Value != "" && JSON.stringify(res.Value) != "{}") {
if (fiterChannelID.includes(res.Value.ChannelId)) {
//console.log("___444___.", fiterChannelID.includes(res.Value.ChannelId));
localStorage.removeItem("ChannelInfo");
} else {
if (localStorage.getItem("ChannelInfo")) {
//console.log("___555___.", res);
var cacheChannel = JSON.parse(localStorage.getItem("ChannelInfo"));
// 判斷是否是24小時內
var totaltime = (new Date().getTime() - cacheChannel.key) / 1000;
var is24time = parseInt(totaltime / (60 * 60)) > 24;
if (is24time) {
// 24小時外
setChannelStorage(res.Value.ChannelId, res.Value.ChannelFullName);
}
}
}
} else {
if (localStorage.getItem("ChannelInfo")) {
var cacheChannel = JSON.parse(localStorage.getItem("ChannelInfo"));
// 判斷是否是24小時內
var totaltime = (new Date().getTime() - cacheChannel.key) / 1000;
var is24time = parseInt(totaltime / (60 * 60)) > 24;
if (is24time) {
// 24小時外 清除緩存數據
localStorage.removeItem("ChannelInfo");
}
}
}
//getToken();
});
//$.ajax({
// type: "GET",
// timeout: 10000,
// url: serverHost + "Api/Basic/BasicData/GetChannelLabel?userId=" + localStorage.getItem('PcOpenId'),
// data: {},
// async: false,
// //dataType: "html",
// beforeSend: function () { },
// success: function (res) {
// if (res.Success && res.Value && res.Value != "" && JSON.stringify(res.Value) != "{}") {
// if (fiterChannelID.includes(res.Value.ChannelId)) {
// setChannelStorage(res.Value.ChannelId, res.Value.ChannelFullName);
// } else {
// if (localStorage.getItem("ChannelInfo")) {
// var cacheChannel = JSON.parse(localStorage.getItem("ChannelInfo"));
// // 判斷是否是24小時內
// var totaltime = (new Date().getTime() - cacheChannel.key) / 1000;
// var is24time = parseInt(totaltime / (60 * 60)) > 24;
// if (is24time) {
// // 24小時外
// setChannelStorage(res.Value.ChannelId, res.Value.ChannelFullName);
// }
// }
// }
// } else {
// if (localStorage.getItem("ChannelInfo")) {
// var cacheChannel = JSON.parse(localStorage.getItem("ChannelInfo"));
// // 判斷是否是24小時內
// var totaltime = (new Date().getTime() - cacheChannel.key) / 1000;
// var is24time = parseInt(totaltime / (60 * 60)) > 24;
// if (is24time) {
// // 24小時外 清除緩存數據
// localStorage.removeItem("ChannelInfo");
// }
// }
// }
// },
// error: function () {
// },
// complete: function (data) {
// getToken();
// }
//});
}
function cloudBirdJump(jumpType) {
let jumTypeUrl = "https://uclient.yunque360.com/frame.html?company_id=cja1uk0l03qs24";
if (localStorage.getItem('ChannelInfo')) {
var cacheChannel = JSON.parse(localStorage.getItem('ChannelInfo'));
console.log("___cloudBirdJump___", cacheChannel);
gio('track', 'customerServiceClick', { 'customerServiceType_var': '在線客服', 'customerServiceChannel_var': localStorage.getItem('channelID') });
let urlItem = cloudBirdLink.find(x => x.channelId == cacheChannel.channelId);
console.log("___cloudBirdJump___2.", urlItem);
if (urlItem) {
jumTypeUrl = urlItem.channelPath;
}
}
if (jumpType == '_blank') {
window.open(jumTypeUrl);
} else {
window.location.href = jumTypeUrl;
}
}
////function getToken(cookieId) {
//// if (!cookieId) return false;
//// let sign = hex_md5(cookieId + 'crdapplet');
//// $.ajax({
//// type: "POST",
//// timeout: 10000,
//// url: appletHost + "/UniApp/GetToken",
//// //dataType: "json",
//// data: JSON.stringify({
//// OpenId: cookieId,
//// Sign: sign
//// }),
//// contentType: 'application/json',
//// crossDomain: true,
//// async: false,
//// success: function (result) {
//// if (result.Success) {
//// localStorage.setItem("AccessToken", result.Value.AccessToken);
//// localStorage.setItem("RefreshToken", result.Value.RefreshToken);
//// }
//// },
//// error: function (msg) {
//// console.log("獲取Token失敗,請稍候再試...");
//// },
//// complete: function (data) { }
//// });
////}
////if (!localStorage.getItem("AccessToken")) {
//// let cookieid;
//// if (localStorage.getItem("PcOpenId")) {
//// cookieid = localStorage.getItem("PcOpenId");
//// } else {
//// cookieid = createUUID(18, 16);
//// }
//// this.getToken(cookieid);
////}
/*
* These functions implement the four basic operations the algorithm uses.
*/
/********************************************************************
**
**比較通用的正則表達式,捕獲url各個部分。
**注意各部分基本上都包含了相應的符號,例如端口號如果捕獲成功,那就是':80'
**函數返回一個正則表達式捕獲數組。
**注意,現在獲得的是一個數組,所以需要通過arr[i]的方式引用。
**正則表達式所有的匹配說明::
**$0
**整個url本身。如果$0==null,那就是我的正則有意外,未捕獲的可能。
**有一種未捕獲的情況已經被發現,那就是域名后面沒有以'/'結尾,如:'http://localhost'
**但是經過我的測試,IE和firefox會自動把域名后面加上'/'的。
**$1-$4 協議,域名,端口號,還有最重要的路徑path!
**$5-$7 文件名,錨點(#top),query參數(?id=55)
**
*********************************************************************/
function UrlRegEx(url) {
if (url != undefined && url != null && url.length > 5) {
var strHtml = url.substr(url.length - 5, 5);
if (strHtml != ".html" && strHtml.substr(strHtml.length - 1, 1) != "/") {
url = url + "/";
}
}
//如果加上/g參數,那么只返回$0匹配。也就是說arr.length = 0
var re = /(\w+):\/\/([^\:|\/]+)(\:\d*)?(.*\/)([^#|\?|\n]+)?(#.*)?(\?.*)?/i;
//re.exec(url);
var arr = url.match(re);
return arr;
}
//--------示例代碼:
function getPath() {
return UrlRegEx(location.href)[4];
}
function linkIndex() {
window.location.href = "/";
}
function safe_add(x, y) {
var lsw = (x & 0xFFFF) + (y & 0xFFFF),
msw = (x >> 16) + (y >> 16) + (lsw >> 16);
return (msw << 16) | (lsw & 0xFFFF);
}
/*
* Bitwise rotate a 32-bit number to the left.
*/
function bit_rol(num, cnt) {
return (num << cnt) | (num >>> (32 - cnt));
}
/*
* These functions implement the four basic operations the algorithm uses.
*/
function md5_cmn(q, a, b, x, s, t) {
return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b);
}
function md5_ff(a, b, c, d, x, s, t) {
return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
}
function md5_gg(a, b, c, d, x, s, t) {
return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
}
function md5_hh(a, b, c, d, x, s, t) {
return md5_cmn(b ^ c ^ d, a, b, x, s, t);
}
function md5_ii(a, b, c, d, x, s, t) {
return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
}
/*
* Calculate the MD5 of an array of little-endian words, and a bit length.
*/
function binl_md5(x, len) {
/* append padding */
x[len >> 5] |= 0x80 << (len % 32);
x[(((len + 64) >>> 9) << 4) + 14] = len;
var i, olda, oldb, oldc, oldd,
a = 1732584193,
b = -271733879,
c = -1732584194,
d = 271733878;
for (i = 0; i < x.length; i += 16) {
olda = a;
oldb = b;
oldc = c;
oldd = d;
a = md5_ff(a, b, c, d, x[i], 7, -680876936);
d = md5_ff(d, a, b, c, x[i + 1], 12, -389564586);
c = md5_ff(c, d, a, b, x[i + 2], 17, 606105819);
b = md5_ff(b, c, d, a, x[i + 3], 22, -1044525330);
a = md5_ff(a, b, c, d, x[i + 4], 7, -176418897);
d = md5_ff(d, a, b, c, x[i + 5], 12, 1200080426);
c = md5_ff(c, d, a, b, x[i + 6], 17, -1473231341);
b = md5_ff(b, c, d, a, x[i + 7], 22, -45705983);
a = md5_ff(a, b, c, d, x[i + 8], 7, 1770035416);
d = md5_ff(d, a, b, c, x[i + 9], 12, -1958414417);
c = md5_ff(c, d, a, b, x[i + 10], 17, -42063);
b = md5_ff(b, c, d, a, x[i + 11], 22, -1990404162);
a = md5_ff(a, b, c, d, x[i + 12], 7, 1804603682);
d = md5_ff(d, a, b, c, x[i + 13], 12, -40341101);
c = md5_ff(c, d, a, b, x[i + 14], 17, -1502002290);
b = md5_ff(b, c, d, a, x[i + 15], 22, 1236535329);
a = md5_gg(a, b, c, d, x[i + 1], 5, -165796510);
d = md5_gg(d, a, b, c, x[i + 6], 9, -1069501632);
c = md5_gg(c, d, a, b, x[i + 11], 14, 643717713);
b = md5_gg(b, c, d, a, x[i], 20, -373897302);
a = md5_gg(a, b, c, d, x[i + 5], 5, -701558691);
d = md5_gg(d, a, b, c, x[i + 10], 9, 38016083);
c = md5_gg(c, d, a, b, x[i + 15], 14, -660478335);
b = md5_gg(b, c, d, a, x[i + 4], 20, -405537848);
a = md5_gg(a, b, c, d, x[i + 9], 5, 568446438);
d = md5_gg(d, a, b, c, x[i + 14], 9, -1019803690);
c = md5_gg(c, d, a, b, x[i + 3], 14, -187363961);
b = md5_gg(b, c, d, a, x[i + 8], 20, 1163531501);
a = md5_gg(a, b, c, d, x[i + 13], 5, -1444681467);
d = md5_gg(d, a, b, c, x[i + 2], 9, -51403784);
c = md5_gg(c, d, a, b, x[i + 7], 14, 1735328473);
b = md5_gg(b, c, d, a, x[i + 12], 20, -1926607734);
a = md5_hh(a, b, c, d, x[i + 5], 4, -378558);
d = md5_hh(d, a, b, c, x[i + 8], 11, -2022574463);
c = md5_hh(c, d, a, b, x[i + 11], 16, 1839030562);
b = md5_hh(b, c, d, a, x[i + 14], 23, -35309556);
a = md5_hh(a, b, c, d, x[i + 1], 4, -1530992060);
d = md5_hh(d, a, b, c, x[i + 4], 11, 1272893353);
c = md5_hh(c, d, a, b, x[i + 7], 16, -155497632);
b = md5_hh(b, c, d, a, x[i + 10], 23, -1094730640);
a = md5_hh(a, b, c, d, x[i + 13], 4, 681279174);
d = md5_hh(d, a, b, c, x[i], 11, -358537222);
c = md5_hh(c, d, a, b, x[i + 3], 16, -722521979);
b = md5_hh(b, c, d, a, x[i + 6], 23, 76029189);
a = md5_hh(a, b, c, d, x[i + 9], 4, -640364487);
d = md5_hh(d, a, b, c, x[i + 12], 11, -421815835);
c = md5_hh(c, d, a, b, x[i + 15], 16, 530742520);
b = md5_hh(b, c, d, a, x[i + 2], 23, -995338651);
a = md5_ii(a, b, c, d, x[i], 6, -198630844);
d = md5_ii(d, a, b, c, x[i + 7], 10, 1126891415);
c = md5_ii(c, d, a, b, x[i + 14], 15, -1416354905);
b = md5_ii(b, c, d, a, x[i + 5], 21, -57434055);
a = md5_ii(a, b, c, d, x[i + 12], 6, 1700485571);
d = md5_ii(d, a, b, c, x[i + 3], 10, -1894986606);
c = md5_ii(c, d, a, b, x[i + 10], 15, -1051523);
b = md5_ii(b, c, d, a, x[i + 1], 21, -2054922799);
a = md5_ii(a, b, c, d, x[i + 8], 6, 1873313359);
d = md5_ii(d, a, b, c, x[i + 15], 10, -30611744);
c = md5_ii(c, d, a, b, x[i + 6], 15, -1560198380);
b = md5_ii(b, c, d, a, x[i + 13], 21, 1309151649);
a = md5_ii(a, b, c, d, x[i + 4], 6, -145523070);
d = md5_ii(d, a, b, c, x[i + 11], 10, -1120210379);
c = md5_ii(c, d, a, b, x[i + 2], 15, 718787259);
b = md5_ii(b, c, d, a, x[i + 9], 21, -343485551);
a = safe_add(a, olda);
b = safe_add(b, oldb);
c = safe_add(c, oldc);
d = safe_add(d, oldd);
}
return [a, b, c, d];
}
/*
* Convert an array of little-endian words to a string
*/
function binl2rstr(input) {
var i,
output = '';
for (i = 0; i < input.length * 32; i += 8) {
output += String.fromCharCode((input[i >> 5] >>> (i % 32)) & 0xFF);
}
return output;
}
/*
* Convert a raw string to an array of little-endian words
* Characters >255 have their high-byte silently ignored.
*/
function rstr2binl(input) {
var i,
output = [];
output[(input.length >> 2) - 1] = undefined;
for (i = 0; i < output.length; i += 1) {
output[i] = 0;
}
for (i = 0; i < input.length * 8; i += 8) {
output[i >> 5] |= (input.charCodeAt(i / 8) & 0xFF) << (i % 32);
}
return output;
}
/*
* Calculate the MD5 of a raw string
*/
function rstr_md5(s) {
return binl2rstr(binl_md5(rstr2binl(s), s.length * 8));
}
/*
* Calculate the HMAC-MD5, of a key and some data (raw strings)
*/
function rstr_hmac_md5(key, data) {
var i,
bkey = rstr2binl(key),
ipad = [],
opad = [],
hash;
ipad[15] = opad[15] = undefined;
if (bkey.length > 16) {
bkey = binl_md5(bkey, key.length * 8);
}
for (i = 0; i < 16; i += 1) {
ipad[i] = bkey[i] ^ 0x36363636;
opad[i] = bkey[i] ^ 0x5C5C5C5C;
}
hash = binl_md5(ipad.concat(rstr2binl(data)), 512 + data.length * 8);
return binl2rstr(binl_md5(opad.concat(hash), 512 + 128));
}
/*
* Convert a raw string to a hex string
*/
function rstr2hex(input) {
var hex_tab = '0123456789abcdef',
output = '',
x,
i;
for (i = 0; i < input.length; i += 1) {
x = input.charCodeAt(i);
output += hex_tab.charAt((x >>> 4) & 0x0F) +
hex_tab.charAt(x & 0x0F);
}
return output;
}
/*
* Encode a string as utf-8
*/
function str2rstr_utf8(input) {
return unescape(encodeURIComponent(input));
}
/*
* Take string arguments and return either raw or hex encoded strings
*/
function raw_md5(s) {
return rstr_md5(str2rstr_utf8(s));
}
function hex_md5(s) {
return rstr2hex(raw_md5(s));
}
function raw_hmac_md5(k, d) {
return rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d));
}
function hex_hmac_md5(k, d) {
return rstr2hex(raw_hmac_md5(k, d));
}
function md5(string, key, raw) {
if (!key) {
if (!raw) {
return hex_md5(string);
}
return raw_md5(string);
}
if (!raw) {
return hex_hmac_md5(key, string);
}
return raw_hmac_md5(key, string);
}
国产亚洲精品xxx