Light12306/Mobile12306New/js/init.js

755 lines
18 KiB
JavaScript
Raw Normal View History

2014-09-09 12:41:28 +08:00
// var base64 = base64 || (function() {
// var base64Map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split('');
// var base64DeMap = ! function() {
// var result = {};
// $.each(base64Map, function(i, e) {
// result[e] = i;
// });
// return result;
// }();
// var target = {};
// target.encode = function(data) {
// var buf = [];
// var map = base64Map;
// var n = data.length; //总字节数
// var val; //中间值
// var i = 0;
// /*
// * 3字节 ==> val ==> 4字符
// */
// while (i < n) {
// val = (data[i] << 16) |
// (data[i + 1] << 8) |
// (data[i + 2]);
// buf.push(map[val >> 18],
// map[val >> 12 & 63],
// map[val >> 6 & 63],
// map[val & 63]);
// i += 3;
// }
// if (n % 3 == 1) //凑两个"="
// buf.pop(), buf.pop(), buf.push('=', '=');
// else //凑一个"="
// buf.pop(), buf.push('=');
// return buf.join('');
// };
// target.decode = function(str) {
// var buf = [];
// var arr = str.split('');
// var map = base64DeMap;
// var n = arr.length; //总字符数
// var val; //中间值
// var i = 0;
// /*
// * 长度异常
// */
// if (n % 4)
// return null;
// /*
// * 4字符 ==> val ==> 3字节
// */
// while (i < n) {
// val = (map[arr[i]] << 18) |
// (map[arr[i + 1]] << 12) |
// (map[arr[i + 2]] << 6) |
// (map[arr[i + 3]]);
// buf.push(val >> 16,
// val >> 8 & 0xFF,
// val & 0xFF);
// i += 4;
// }
// /*
// * 凑字字符"="个数
// */
// while (arr[--n] == '=')
// buf.pop();
// return buf;
// };
// target.encodeArrayBuffer = function(arrayBuffer) {
// /// <summary>将ArrayBuffer转换为Base64字符串</summary>
// var dv = new DataView(arrayBuffer);
// var length = dv.byteLength;
// var data = [];
// for (var i = 0; i < length; i++) {
// data.push(dv.getUint8(i));
// }
// return base64.encode(data);
// };
// target.toObjectUrl = function(base64str, type) {
// /// <summary>获得指定base64字符串的对象链接格式</summary>
// return "data:" + type + ";base64," + base64str;
// };
// return target;
// })();
2014-09-01 13:50:43 +08:00
var bootStrap = (function() {
2014-08-21 17:00:33 +08:00
var def = $.Deferred();
2014-09-01 13:50:43 +08:00
// alert(typeof __TicketJavaScriptObject__);
2014-08-21 17:00:33 +08:00
2014-09-01 13:50:43 +08:00
var isAndroid = typeof(__TicketJavaScriptObject__) !== 'undefined';
var isIos = typeof(window.__ksticket) != 'undefined' || typeof(window.__gChrome) != 'undefined';
var isOldBrowser = typeof(window.__ksticket) != 'undefined' || typeof(window.liebaoExtentions) !== 'undefined';
var deviceObject = window.__TicketJavaScriptObject__ || window.__ksticket;
2014-08-21 17:00:33 +08:00
var isExtension = document.body.dataset["mobileSupportInitialized"] || false;
Object.defineProperties(def, {
'isAndroid': {
2014-09-01 13:50:43 +08:00
get: function() {
2014-09-04 20:32:24 +08:00
return isAndroid;
2014-08-21 17:00:33 +08:00
}
},
'isIos': {
2014-09-01 13:50:43 +08:00
get: function() {
return isIos;
}
},
'isIosOld': {
2014-09-01 13:50:43 +08:00
get: function() {
return !isOldBrowser;
}
2014-08-21 17:00:33 +08:00
},
2014-09-01 13:50:43 +08:00
'device_info': {
get: function() {
if (deviceObject)
return deviceObject.get_device_info();
return null;
}
2014-08-21 17:00:33 +08:00
}
});
2014-09-01 13:50:43 +08:00
def.open_url = function(url) {
2014-08-21 17:00:33 +08:00
if (deviceObject) {
deviceObject.open_url(url);
} else {
window.open(url);
}
}
2014-09-01 13:50:43 +08:00
def.refresh_start = function() {
2014-08-21 17:00:33 +08:00
var args = [].slice.call(arguments);
2014-09-01 13:50:43 +08:00
if (deviceObject) {
// deviceObject.refresh_start.apply(this, arguments);
deviceObject.refresh_start();
}
// $(document).dispatchEvent("refreshStart", args);
2014-08-21 17:00:33 +08:00
};
2014-09-01 13:50:43 +08:00
def.refresh_end = function() {
2014-08-21 17:00:33 +08:00
var args = [].slice.call(arguments);
2014-09-01 13:50:43 +08:00
if (deviceObject) {
// deviceObject.refresh_end.apply(this, arguments);
deviceObject.refresh_end();
}
// $(document).dispatchEvent("refreshEnd", args);
2014-08-21 17:00:33 +08:00
};
2014-09-01 13:50:43 +08:00
def.refresh_success = function() {
2014-08-21 17:00:33 +08:00
var args = [].slice.call(arguments);
2014-09-01 13:50:43 +08:00
if (deviceObject) {
// deviceObject.refresh_success.apply(this, arguments);
deviceObject.refresh_success();
2014-09-09 12:41:28 +08:00
try {
2014-09-04 14:46:15 +08:00
deviceObject.toast('刷票成功,请尽快订票');
2014-09-09 12:41:28 +08:00
} catch (e) {
2014-09-04 14:46:15 +08:00
}
2014-09-01 13:50:43 +08:00
} else if (window.liebaoExtentions && window.liebaoExtentions.vibrate) {
window.liebaoExtentions.vibrate(5000);
2014-09-01 13:50:43 +08:00
} else if (window.__gChrome && window.__gChrome.hasTicket) {
window.__gChrome.hasTicket("刷票成功,请尽快订票", "");
2014-09-01 13:50:43 +08:00
}
2014-09-01 13:50:43 +08:00
// $(document).dispatchEvent("refreshSuccess", args);
2014-08-21 17:00:33 +08:00
};
var queue = {};
var callid = 0;
2014-09-01 13:50:43 +08:00
var ajaxCommon = (function() {
2014-08-21 17:00:33 +08:00
var baseUri = "https://kyfw.12306.cn/otn/";
return {
2014-09-01 13:50:43 +08:00
getUrl: function(url) {
2014-08-21 17:00:33 +08:00
if (url[4] === ":" || url[5] === ":") return url;
return baseUri + url;
},
2014-09-01 13:50:43 +08:00
getHeaders: function(url, headers) {
2014-08-21 17:00:33 +08:00
headers = headers || {};
headers['Origin'] = /(https?:\/\/[^\/]+\/)/i.exec(url)[1];
if (isIos) {
var nheaders = {};
2014-09-01 13:50:43 +08:00
$.each(headers, function(k, v) {
2014-08-21 17:00:33 +08:00
nheaders["Fish-" + k] = v;
});
headers = nheaders;
}
return headers;
}
};
})();
2014-09-01 13:50:43 +08:00
var ajaxAndLb = (function() {
2014-08-21 17:00:33 +08:00
2014-09-01 13:50:43 +08:00
window.fishXhrLoadCallback = function(obj) {
if (typeof(obj) === "string")
2014-08-21 17:00:33 +08:00
obj = JSON.parse(obj);
var ad = queue[obj.id];
if (!ad)
return;
//process with json
if (ad.rawResultType === "json") {
try {
obj.result = JSON.parse(obj.result);
} catch (e) {
obj.success = false;
}
2014-09-01 13:50:43 +08:00
} else if (ad.rawResultType === "image") {
obj.result = base64.toObjectUrl(obj.result, "png");
2014-08-21 17:00:33 +08:00
}
delete queue[obj.id];
if (obj.success) {
ad.resolve(obj.result, {
headers: obj.headers,
statusCode: obj.statusCode,
statusDescription: obj.statusDescription,
id: obj.id
});
} else {
ad.reject(obj.result, {
headers: obj.headers,
statusCode: obj.statusCode,
statusDescription: obj.statusDescription,
id: obj.id
});
}
};
2014-09-01 13:50:43 +08:00
var ajax = function(method, url, returnType, postdata, refer, headers) {
2014-08-21 17:00:33 +08:00
var ad = new $.Deferred();
postdata = postdata || "";
2014-09-01 13:50:43 +08:00
if (typeof(postdata) !== "string")
2014-08-21 17:00:33 +08:00
postdata = $.param(postdata);
2014-09-01 13:50:43 +08:00
if (method == 'GET' && (returnType || "json") != "image") {
url = url + "?" + postdata;
}
2014-08-21 17:00:33 +08:00
headers = headers || {};
if (refer) {
2014-09-01 13:50:43 +08:00
headers = $.extend({}, headers, {
Referer: refer
});
2014-08-21 17:00:33 +08:00
}
ad.rawResultType = returnType || "json";
ad.context = {
id: ++callid,
url: url,
method: method,
postdata: postdata,
refer: refer,
headers: headers || {},
callback: "fishXhrLoadCallback",
requestCharset: "UTF-8",
returnType: ad.rawResultType === "image" ? "image" : "text"
};
queue[ad.context.id] = ad;
deviceObject.sendRequest(JSON.stringify(ad.context));
return ad.promise();
};
return {
ajax: ajax,
2014-09-01 13:50:43 +08:00
get: function() {
2014-08-21 17:00:33 +08:00
var arr = [].slice.call(arguments);
arr.unshift("GET");
return ajax.apply(this, arr);
},
2014-09-01 13:50:43 +08:00
post: function() {
2014-08-21 17:00:33 +08:00
var arr = [].slice.call(arguments);
arr.unshift("POST");
return ajax.apply(this, arr);
},
2014-09-01 13:50:43 +08:00
getImage: function(url, refer) {
2014-08-21 17:00:33 +08:00
return ajax("GET", url, "image", null, refer);
}
}
})();
2014-09-01 13:50:43 +08:00
var ajaxIos = (function() {
2014-08-21 17:00:33 +08:00
//ios
2014-09-01 13:50:43 +08:00
var ajax = function(method, url, returnType, postdata, refer, headers) {
2014-08-21 17:00:33 +08:00
var ad = new $.Deferred();
headers = headers || {};
if (refer) {
2014-09-01 13:50:43 +08:00
headers = $.extend({}, headers, {
Referer: refer
});
2014-08-21 17:00:33 +08:00
}
2014-09-01 13:50:43 +08:00
var nheaders = {};
$.each(headers, function(k, v) {
nheaders["Fish-" + k] = v;
2014-08-22 18:00:59 +08:00
});
2014-09-01 13:50:43 +08:00
headers = nheaders;
2014-08-21 17:00:33 +08:00
$.ajax({
url: url,
data: postdata,
timeout: 120000,
type: method,
dataType: returnType,
refer: refer,
headers: headers
2014-09-01 13:50:43 +08:00
}).done(function(result, status, xhr) {
2014-08-21 17:00:33 +08:00
ad.resolve(result, {
headers: xhr.getAllResponseHeaders(),
statusCode: xhr.statusCode,
statusDescription: xhr.statusText,
id: 0
});
2014-09-01 13:50:43 +08:00
}).fail(function(xhr) {
2014-08-21 17:00:33 +08:00
ad.reject(result, {
headers: xhr.getAllResponseHeaders(),
statusCode: xhr.statusCode,
statusDescription: xhr.statusText,
id: 0
});
});
return ad;
};
2014-09-01 13:50:43 +08:00
var ajaxLoadImage = function(method, url, postdata, refer, headers) {
2014-08-21 17:00:33 +08:00
var ad = new $.Deferred();
var xhr = new window.XMLHttpRequest();
headers = headers || {};
xhr.open(method, url, true);
2014-09-01 13:50:43 +08:00
$.each(headers, function(k, v) {
2014-08-21 17:00:33 +08:00
xhr.setRequestHeader("Fish-" + k, v);
});
2014-09-01 13:50:43 +08:00
xhr.onreadystatechange = function() {
2014-08-21 17:00:33 +08:00
if (xhr.readyState === 4) {
if (xhr.status !== 200) {
ad.reject("加载验证码失败,请点击验证码刷新", {
2014-08-21 17:00:33 +08:00
headers: xhr.getAllResponseHeaders(),
statusCode: xhr.statusCode,
statusDescription: xhr.statusText,
id: 0
});
} else {
ad.resolve(base64.toObjectUrl(base64.encodeArrayBuffer(xhr.response), "image/jpeg"), {
headers: xhr.getAllResponseHeaders(),
statusCode: xhr.statusCode,
statusDescription: xhr.statusText,
id: 0
});
}
}
};
var prefix = "Fish-";
xhr.responseType = "arraybuffer";
xhr.setRequestHeader(prefix + "Referer", refer || "");
xhr.setRequestHeader(prefix + "User-Agent", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)");
xhr.setRequestHeader(prefix + "Origin", /(https?:\/\/[^\/]+\/)/.exec(url)[1]);
xhr.send(postdata);
return ad;
}
return {
ajax: ajax,
2014-09-01 13:50:43 +08:00
get: function() {
2014-08-21 17:00:33 +08:00
var arr = [].slice.call(arguments);
arr.unshift("GET");
return ajax.apply(this, arr);
},
2014-09-01 13:50:43 +08:00
post: function() {
2014-08-21 17:00:33 +08:00
var arr = [].slice.call(arguments);
arr.unshift("POST");
return ajax.apply(this, arr);
},
2014-09-01 13:50:43 +08:00
getImage: function(url, refer) {
2014-08-21 17:00:33 +08:00
return ajaxLoadImage("GET", url, null, refer);
}
}
})();
2014-09-01 13:50:43 +08:00
var ajaxExtension = (function() {
2014-08-21 17:00:33 +08:00
//ios
2014-09-01 13:50:43 +08:00
var ajax = function(method, url, returnType, postdata, refer, headers) {
2014-08-21 17:00:33 +08:00
var ad = new $.Deferred();
headers = headers || {};
if (refer) {
2014-09-01 13:50:43 +08:00
headers = $.extend({}, headers, {
Referer: refer
});
2014-08-21 17:00:33 +08:00
}
var xhrData = {
url: url,
data: postdata,
timeout: 120000,
type: method,
dataType: returnType,
refer: refer,
headers: headers
};
2014-09-01 13:50:43 +08:00
var e = new CustomEvent("ajaxproxy", {
detail: {
data: xhrData,
index: ++callid
},
cancelable: true
});
2014-08-21 17:00:33 +08:00
if (!document.dispatchEvent(e)) {
queue[e.detail.index] = {
2014-09-01 13:50:43 +08:00
done: function(result) {
2014-08-21 17:00:33 +08:00
ad.resolve(result, {
headers: this.headers,
statusCode: this.status,
statusDescription: this.statusText,
id: this.index
});
},
2014-09-01 13:50:43 +08:00
fail: function() {
2014-08-21 17:00:33 +08:00
ad.reject(this.text, {
headers: this.headers,
statusCode: this.status,
statusDescription: this.statusText,
id: this.index
});
}
};
} else {
document.dispatchEvent(new CustomEvent("requestSupportError"));
def.reject("平台错误");
2014-08-21 17:00:33 +08:00
}
return ad;
};
2014-09-01 13:50:43 +08:00
var ajaxLoadImage = function(method, url, postdata, refer, headers) {
2014-08-21 17:00:33 +08:00
var ad = new $.Deferred();
headers = headers || {};
if (refer) {
2014-09-01 13:50:43 +08:00
headers = $.extend({}, headers, {
Referer: refer
});
2014-08-21 17:00:33 +08:00
}
var e = new CustomEvent("ajaxLoadVerifyCode", {
2014-09-01 13:50:43 +08:00
detail: {
2014-08-21 17:00:33 +08:00
method: method,
url: url,
refer: refer,
index: ++callid,
headers: headers,
data: postdata
2014-09-01 13:50:43 +08:00
},
cancelable: true
2014-08-21 17:00:33 +08:00
});
if (!document.dispatchEvent(e)) {
queue[e.detail.index] = {
2014-09-01 13:50:43 +08:00
done: function() {
2014-08-21 17:00:33 +08:00
ad.resolve(this.url, {
headers: this.headers,
statusCode: this.status,
statusDescription: this.statusText,
id: this.index
});
},
2014-09-01 13:50:43 +08:00
fail: function() {
2014-08-21 17:00:33 +08:00
ad.reject(this.text, {
headers: this.headers,
statusCode: this.status,
statusDescription: this.statusText,
id: this.index
});
}
};
} else {
document.dispatchEvent(new CustomEvent("requestSupportError"));
ad.reject("平台错误");
2014-08-21 17:00:33 +08:00
}
return ad;
2014-08-21 17:00:33 +08:00
}
2014-09-01 13:50:43 +08:00
document.addEventListener("ajaxproxyfinished", function(e) {
2014-08-21 17:00:33 +08:00
var data = e.detail;
if (!queue[data.index]) return;
var param = queue[data.index];
delete queue[data.index];
if (data.status === 404) {
//404是个比较特殊的错误这个错误一般是证书有问题
2014-08-21 17:00:33 +08:00
document.dispatchEvent(new CustomEvent("networkOrCertificationError"));
}
data.success ? param.done.call(data || window, data.model) : param.fail.call(data || window, data.model);
});
return {
ajax: ajax,
2014-09-01 13:50:43 +08:00
get: function() {
2014-08-21 17:00:33 +08:00
var arr = [].slice.call(arguments);
arr.unshift("GET");
return ajax.apply(this, arr);
},
2014-09-01 13:50:43 +08:00
post: function() {
2014-08-21 17:00:33 +08:00
var arr = [].slice.call(arguments);
arr.unshift("POST");
return ajax.apply(this, arr);
},
2014-09-01 13:50:43 +08:00
getImage: function(url, refer) {
2014-08-21 17:00:33 +08:00
return ajaxLoadImage("GET", url, null, refer);
}
}
})();
2014-09-01 13:50:43 +08:00
var ajaxProxy = (function() {
var ajax = function(method, url, returnType, postdata, refer, headers) {
2014-08-21 17:00:33 +08:00
var ad = new $.Deferred();
2014-09-05 21:03:19 +08:00
var headers = headers || {};
returnType = returnType || 'json';
// headers = headers || {};
2014-08-21 17:00:33 +08:00
if (refer) {
2014-09-01 13:50:43 +08:00
headers = $.extend({}, headers, {
Referer: refer
});
2014-08-21 17:00:33 +08:00
}
2014-09-09 12:41:28 +08:00
var header = {};
2014-09-05 21:03:19 +08:00
for (var k in headers) {
2014-09-09 12:41:28 +08:00
header["FISHPROXY-" + k] = headers[k];
2014-09-05 21:03:19 +08:00
};
header["FISHPROXY-RawUrl"] = url;
2014-09-02 19:09:24 +08:00
url = "/12306/proxy.php";
2014-08-21 17:00:33 +08:00
$.ajax({
url: url,
data: postdata,
timeout: 120000,
type: method,
dataType: returnType,
refer: refer,
2014-09-05 21:03:19 +08:00
headers: header
}).done(function(result, status, xhr) {
2014-08-21 17:00:33 +08:00
ad.resolve(result, {
headers: xhr.getAllResponseHeaders(),
statusCode: xhr.statusCode,
statusDescription: xhr.statusText,
id: 0
});
2014-09-05 21:03:19 +08:00
}).fail(function(xhr) {
2014-08-22 18:00:59 +08:00
ad.reject(xhr.responseText, {
2014-08-21 17:00:33 +08:00
headers: xhr.getAllResponseHeaders(),
statusCode: xhr.statusCode,
statusDescription: xhr.statusText,
id: 0
});
});
return ad;
};
2014-09-01 13:50:43 +08:00
var ajaxLoadImage = function(method, url, postdata, refer, headers) {
2014-08-21 17:00:33 +08:00
var ad = new $.Deferred();
var xhr = new window.XMLHttpRequest();
headers = headers || {};
headers["RawUrl"] = url;
headers["Origin"] = /(https?:\/\/[^\/]+\/)/.exec(url)[1];
headers["User-Agent"] = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)";
headers["Referer"] = refer || "";
2014-09-02 19:09:24 +08:00
url = "/12306/proxy.php";
2014-08-21 17:00:33 +08:00
xhr.open(method, url, true);
2014-09-01 13:50:43 +08:00
$.each(headers, function(k, v) {
2014-09-05 21:03:19 +08:00
xhr.setRequestHeader("FISHPROXY-" + k, v);
});
2014-09-01 13:50:43 +08:00
xhr.onreadystatechange = function() {
2014-08-21 17:00:33 +08:00
if (xhr.readyState === 4) {
if (xhr.status !== 200) {
ad.reject("加载验证码失败,请点击验证码刷新", {
2014-08-21 17:00:33 +08:00
headers: xhr.getAllResponseHeaders(),
statusCode: xhr.statusCode,
statusDescription: xhr.statusText,
id: 0
});
} else {
ad.resolve(base64.toObjectUrl(base64.encodeArrayBuffer(xhr.response), "image/jpeg"), {
headers: xhr.getAllResponseHeaders(),
statusCode: xhr.statusCode,
statusDescription: xhr.statusText,
id: 0
});
}
}
};
xhr.responseType = "arraybuffer";
xhr.send(postdata || null);
2014-08-21 17:00:33 +08:00
return ad;
}
return {
ajax: ajax,
2014-09-01 13:50:43 +08:00
get: function() {
2014-08-21 17:00:33 +08:00
var arr = [].slice.call(arguments);
arr.unshift("GET");
return ajax.apply(this, arr);
},
2014-09-01 13:50:43 +08:00
post: function() {
2014-08-21 17:00:33 +08:00
var arr = [].slice.call(arguments);
arr.unshift("POST");
return ajax.apply(this, arr);
},
2014-09-01 13:50:43 +08:00
getImage: function(url, refer) {
2014-08-21 17:00:33 +08:00
return ajaxLoadImage("GET", url, null, refer);
}
}
})();
2014-09-01 13:50:43 +08:00
def.getAjaxComponent = function() {
return (isAndroid ? ajaxAndLb : (isIos ? ajaxIos : (isExtension ? ajaxExtension : ajaxProxy)));
2014-08-21 17:00:33 +08:00
};
2014-09-01 13:50:43 +08:00
def.ajax = function() {
2014-08-21 17:00:33 +08:00
var args = [].slice.call(arguments);
if (args[1])
args[1] = ajaxCommon.getUrl(args[1]);
if (args[4])
args[4] = ajaxCommon.getUrl(args[4]);
if (args[5])
args[5] = ajaxCommon.getHeaders(args[5]);
return def.getAjaxComponent().ajax.apply(this, args);
2014-08-21 17:00:33 +08:00
};
2014-09-01 13:50:43 +08:00
def.get = function() {
2014-08-21 17:00:33 +08:00
var args = [].slice.call(arguments);
args.unshift("GET");
return def.ajax.apply(this, args);
2014-08-21 17:00:33 +08:00
};
2014-09-01 13:50:43 +08:00
def.post = function() {
2014-08-21 17:00:33 +08:00
var args = [].slice.call(arguments);
args.unshift("POST");
return def.ajax.apply(this, args);
2014-08-21 17:00:33 +08:00
};
2014-09-01 13:50:43 +08:00
def.getImage = function() {
2014-08-21 17:00:33 +08:00
var args = [].slice.call(arguments);
if (args[1])
args[1] = ajaxCommon.getUrl(args[1]);
if (args[3])
args[3] = ajaxCommon.getUrl(args[3]);
if (args[5])
args[4] = ajaxCommon.getHeaders(args[4]);
return def.getAjaxComponent().getImage.apply(this, args);
2014-08-21 17:00:33 +08:00
};
2014-09-01 13:50:43 +08:00
$(function() {
2014-09-04 20:32:24 +08:00
if (isIos || isExtension || isAndroid) {
2014-08-21 17:00:33 +08:00
def.resolve();
} else {
2014-09-01 13:50:43 +08:00
var timer = setTimeout(function() {
2014-08-21 17:00:33 +08:00
def.resolve();
}, 500);
2014-09-01 13:50:43 +08:00
document.addEventListener("mobileSupportInitialized", function() {
2014-08-21 17:00:33 +08:00
clearTimeout(timer);
isExtension = true;
def.resolve();
});
}
});
return def;
})();
2014-09-01 13:50:43 +08:00
bootStrap.done(function() {
Client.init();
2014-08-19 16:11:37 +08:00
Public.init();
2014-08-21 17:00:33 +08:00
Login.init();
Query.init();
RunQuery.init();
2014-08-22 18:00:59 +08:00
OrderSubmit.init();
2014-09-01 13:50:43 +08:00
NoComplete.init();
2014-09-09 12:41:28 +08:00
MyRemind.init();
2014-09-01 13:50:43 +08:00
Remind.init();
2014-09-02 19:09:24 +08:00
OrderList.init();
2014-09-05 21:08:31 +08:00
2014-09-09 12:41:28 +08:00
var adUrl = 'http://dl.liebao.cn/android/fast/cheetah_2.11.0.apk',
iosUrl = 'https://itunes.apple.com/cn/app/id641522896',
downloadUrl = IsIOS ? iosUrl : adUrl,
lowerUA = UA.toLowerCase(),
IsLiebao = lowerUA.match(/LieBao/i) == 'liebao',
IsConfirm = tryShowConfrim();
// IsConfirm = true;
// alert(IsConfirm);
if (lowerUA.match(/MicroMessenger/i) == "micromessenger") {
$('body').prepend('<span class="update_notice"><a href="' + downloadUrl + '"><img src="images/update_all.png"></a></span>').addClass('showBanner');
} else if (!(bootStrap.isIos || bootStrap.isAndroid) && ($('#myremind_page').length == 0 && $('#remind_page').length == 0)) {
if (IsLiebao) {
if (lowerUA.match(/LieBaoFast/i) == "liebaofast") {
if(IsConfirm){
Public.confirm('请升级至最新版本', Public.updateAndroid, '立即升级');
setShowADConfrimTime();
}
} else if (IsAndroid) {
$('body').prepend('<span class="update_notice"><a href="' + downloadUrl + '"><img src="images/update_lb.png"></a></span>').addClass('showBanner');
if(IsConfirm){
Public.confirm('手机猎豹极速版全新体验,更轻、更快、更安全!', Public.updateAndroid, '立即升级');
setShowADConfrimTime();
}
} else {
//iOS低版本猎豹处理
}
} else {
// 非猎豹处理
$('body').prepend('<span class="update_notice"><a href="' + downloadUrl + '"><img src="images/update_all.png"></a></span>').addClass('showBanner');
if(IsConfirm){
Public.confirm('下载手机猎豹浏览器,手机抢票更快、更方便。', IsIOS ? Public.updateIos : Public.updateAndroid, '立即下载');
setShowADConfrimTime();
}
}
}
2014-09-09 12:41:28 +08:00
function tryShowConfrim() {
var page = $('body').attr('id')||'',
t = localStorage.getItem(page+'confirmTime');
// alert(t);
if (!t) {
// alert(1);
return true;
}
if ((new Date(parseInt(t))).date.getTime() < (new Date).date.getTime()) {
// alert(2)
return true;
}
2014-09-05 21:08:31 +08:00
2014-09-09 12:41:28 +08:00
return false;
}
2014-09-05 21:08:31 +08:00
2014-09-09 12:41:28 +08:00
function setShowADConfrimTime(){
var page = $('body').attr('id')||'';
localStorage.setItem(page+'confirmTime',(new Date()).getTime());
}
2014-09-05 21:08:31 +08:00
2014-08-19 16:11:37 +08:00
});