diff --git a/RwTicketAssistantV2/app/12306/mobileproxy.js b/RwTicketAssistantV2/app/12306/mobileproxy.js index d5b7193..6eeafca 100644 --- a/RwTicketAssistantV2/app/12306/mobileproxy.js +++ b/RwTicketAssistantV2/app/12306/mobileproxy.js @@ -128,7 +128,7 @@ $(function () { if (!data.headers["Fish-Referer"]) data.headers["Fish-Referer"] = null; - if (!enableDirectAccess || data.url.indexOf("leftTicket/query") === -1 || (directAccessCounter++) % 3 === 0) { + if (!enableDirectAccess || data.url.indexOf("leftTicket/query") === -1 || (directAccessCounter++) % 3 === 0 || localStorage["noDirectAccess"] === "1") { $.ajax(data).done(function (result, status, xhr) { handle.success = true; handle.status = xhr.status; @@ -149,8 +149,8 @@ $(function () { notifyAjaxComplete(handle); }); } else { - chrome.runtime.sendMessage({ action: "directAccess", data: data }, function(args) { - (function(success, status, statusText, text, headers, model) { + chrome.runtime.sendMessage({ action: "directAccess", data: data }, function (args) { + (function (success, status, statusText, text, headers, model) { handle.success = success; handle.status = status; handle.statusText = statusText || ""; diff --git a/RwTicketAssistantV2/app/background.js b/RwTicketAssistantV2/app/background.js index 8a5f4e2..ff189b2 100644 --- a/RwTicketAssistantV2/app/background.js +++ b/RwTicketAssistantV2/app/background.js @@ -924,81 +924,83 @@ window.cbl = function (u, h) { var testLoopSleepTime = 20000; var testServerLoop = function () { - if (entry12306) { - var testCallback = function (time) { - var server = servers[serverIndex]; - var host = server.host; - if (CFG_MANGER.config.enableServerAutoChange) { - if (time > 3000 || (time > 500 && ++currentServer[host].count >= 5)) { - currentServer[host].count = 0; + //切换IP会导致掉线,所以暂时屏蔽 + return; + //if (entry12306) { + // var testCallback = function (time) { + // var server = servers[serverIndex]; + // var host = server.host; + // if (CFG_MANGER.config.enableServerAutoChange) { + // if (time > 3000 || (time > 500 && ++currentServer[host].count >= 5)) { + // currentServer[host].count = 0; - if (!currentServer[host].ip) { - //速度过慢,请求切换,策略随机选 - var targetList = serverStorage.validList[host]; - var target = targetList[Math.floor(Math.random() * targetList.length)]; - if (target && target.ip && (targetList[0].speed < time || time <= 0)) { - currentServer[host].rate = Math.max(Math.floor((target.speed - time) * 1000 / time), 10) / 10; - currentServer[host].ip = target.ip; - applyServer(host, target.ip); + // if (!currentServer[host].ip) { + // //速度过慢,请求切换,策略随机选 + // var targetList = serverStorage.validList[host]; + // var target = targetList[Math.floor(Math.random() * targetList.length)]; + // if (target && target.ip && (targetList[0].speed < time || time <= 0)) { + // currentServer[host].rate = Math.max(Math.floor((target.speed - time) * 1000 / time), 10) / 10; + // currentServer[host].ip = target.ip; + // applyServer(host, target.ip); - //立刻重新测速 - setTimeout(testServerLoop, 1000); - return; - } - } else { - //实在找不到或已经设置过了,那就恢复默认吧。 - currentServer[host].ip = null; - applyServer(host, null); - setTimeout(testServerLoop, 1000); - return; - } - } else { - currentServer[host].speed = time; - currentServer[host].count = 0; - } - } - chrome.runtime.sendMessage({ action: "serverStateChange", detail: { state: serverStorage.status } }); + // //立刻重新测速 + // setTimeout(testServerLoop, 1000); + // return; + // } + // } else { + // //实在找不到或已经设置过了,那就恢复默认吧。 + // currentServer[host].ip = null; + // applyServer(host, null); + // setTimeout(testServerLoop, 1000); + // return; + // } + // } else { + // currentServer[host].speed = time; + // currentServer[host].count = 0; + // } + // } + // chrome.runtime.sendMessage({ action: "serverStateChange", detail: { state: serverStorage.status } }); - serverIndex++; - if (serverIndex >= servers.length) { - serverIndex = 0; + // serverIndex++; + // if (serverIndex >= servers.length) { + // serverIndex = 0; - if (!initialChange && entry12306) { + // if (!initialChange && entry12306) { - //初始化的时候自动选择一次 - var selected = []; - _.each(currentServer, function (e, h) { - var list = serverStorage.validList[h]; - if (!list || !list.length) return; + // //初始化的时候自动选择一次 + // var selected = []; + // _.each(currentServer, function (e, h) { + // var list = serverStorage.validList[h]; + // if (!list || !list.length) return; - if (e.speed > list[0].speed) { - var rate = Math.max(Math.floor((e.speed - list[0].speed) * 1000 / e.speed), 10) / 10; - e.ip = list[0].ip; - e.speed = list[0].speed; - e.rate = rate; - applyServer(h, e.ip); - selected.push(e.ip + "(加速 " + rate + "%)"); - } - }); + // if (e.speed > list[0].speed) { + // var rate = Math.max(Math.floor((e.speed - list[0].speed) * 1000 / e.speed), 10) / 10; + // e.ip = list[0].ip; + // e.speed = list[0].speed; + // e.rate = rate; + // applyServer(h, e.ip); + // selected.push(e.ip + "(加速 " + rate + "%)"); + // } + // }); - if (selected.length) { - chrome.runtime.sendMessage({ action: "showNotification", detail: { title: "订票助手已优化服务器", message: "订票助手已为您选择最快的服务器:" + selected.join("; ") + "。", iconUrl: "/icons/icon_128.png" } }); - } - chrome.runtime.sendMessage({ action: "serverStateChange", detail: { state: serverStorage.status } }); - initialChange = true; - } - setTimeout(testServerLoop, testLoopSleepTime); - testLoopSleepTime += 5000; + // if (selected.length) { + // chrome.runtime.sendMessage({ action: "showNotification", detail: { title: "订票助手已优化服务器", message: "订票助手已为您选择最快的服务器:" + selected.join("; ") + "。", iconUrl: "/icons/icon_128.png" } }); + // } + // chrome.runtime.sendMessage({ action: "serverStateChange", detail: { state: serverStorage.status } }); + // initialChange = true; + // } + // setTimeout(testServerLoop, testLoopSleepTime); + // testLoopSleepTime += 5000; - } else { - testServerLoop(); - } - }; + // } else { + // testServerLoop(); + // } + // }; - testUrlSpeed(servers[serverIndex].url, testCallback); - } else { - setTimeout(testServerLoop, 5000); - } + // testUrlSpeed(servers[serverIndex].url, testCallback); + //} else { + // setTimeout(testServerLoop, 5000); + //} }; var testUrlSpeed = function (url, callback) { diff --git a/RwTicketAssistantV2/app/manifest.json b/RwTicketAssistantV2/app/manifest.json index c26dc43..f707fbb 100644 --- a/RwTicketAssistantV2/app/manifest.json +++ b/RwTicketAssistantV2/app/manifest.json @@ -19,7 +19,7 @@ "description": "12306订票助手 v7: 帮您订票的小助手 by 木鱼,全力为您的车票购买献计献策!", "key": "7k6gnXVACvUPU2DfslJgSrWJTHqIg5uwd+Kgl/5zSg==", "name": "猎豹抢票党/12306订票助手 V7", - "version": "7.3.1", + "version": "7.4.1", "manifest_version": 2, "icons": { "16": "icons/icon_16.png", diff --git a/Web12306/Web12306.csproj b/Web12306/Web12306.csproj index 351a937..b953f7e 100644 --- a/Web12306/Web12306.csproj +++ b/Web12306/Web12306.csproj @@ -179,6 +179,9 @@ + + + @@ -194,6 +197,8 @@ + + diff --git a/Web12306/css/base.css b/Web12306/css/base.css index 6208b88..275330e 100644 --- a/Web12306/css/base.css +++ b/Web12306/css/base.css @@ -404,3 +404,27 @@ div.text-input-wrap { .remark-primary { background-color: #5088DF; } + +/*touch-vc*/ +.vc-touchclick-container { + position: relative; +} + +.vc-touchclick { + cursor: pointer; +} + +.vc-touchclick-desc { +} + + .vc-touchclick-desc .touch-click-clicked { + color: green; + } + + .vc-touchclick-desc .touch-click-current { + color: blue; + } + + .vc-touchclick-desc .touch-click-wait { + color: #555; + } diff --git a/Web12306/css/index.css b/Web12306/css/index.css index b4c00b7..7361981 100644 --- a/Web12306/css/index.css +++ b/Web12306/css/index.css @@ -81,6 +81,7 @@ #wx_sell_notification .info .desc { color: #4c4c4c; + margin-bottom: 15px; } #wx_sell_notification .info .desc span { diff --git a/Web12306/css/ui/widget-ticketsubmit.css b/Web12306/css/ui/widget-ticketsubmit.css index ced2ff0..a7719c2 100644 --- a/Web12306/css/ui/widget-ticketsubmit.css +++ b/Web12306/css/ui/widget-ticketsubmit.css @@ -272,6 +272,7 @@ #ticket-submit-info .ticket-submit-info-status-failed, #ticket-submit-info .ticket-submit-info-status-ok { display: none; + position: relative; } #ticket-submit-info .ticket-submit-info-status-failed div, @@ -297,3 +298,39 @@ #ticket-submit-info .ticket-submit-info-status-ok div { color: #4169E1; } + +/*BD-ʧ*/ +.ticket-submit-failed-bd { +} + + #ticket-submit-info footer .ticket-submit-failed-bd a.bd-bx { + background-image: url(/images/bd/bx.png); + width: 210px; + height: 40px; + display: inline-block; + margin-right: 10px; + } + + #ticket-submit-info footer .ticket-submit-failed-bd a.bd-dd { + background-image: url(/images/bd/dd.png); + width: 210px; + height: 40px; + display: inline-block; + margin-right: 10px; + } + + #ticket-submit-info footer .ticket-submit-failed-bd a.bd-dd img { + display: none; + position: absolute; + height: 200px; + width: 200px; + right: 100px; + box-shadow: 0 0 20px rgba(100,100,150,0.7); + border: 5px solid #fff; + bottom: 0; + border-radius: 5px; + } + + #ticket-submit-info footer .ticket-submit-failed-bd a.bd-dd:hover img { + display: block; + } diff --git a/Web12306/images/bd/bx.png b/Web12306/images/bd/bx.png new file mode 100644 index 0000000..8d66b83 Binary files /dev/null and b/Web12306/images/bd/bx.png differ diff --git a/Web12306/images/bd/dd.png b/Web12306/images/bd/dd.png new file mode 100644 index 0000000..7c8478b Binary files /dev/null and b/Web12306/images/bd/dd.png differ diff --git a/Web12306/images/bd/ddqr.png b/Web12306/images/bd/ddqr.png new file mode 100644 index 0000000..3ccdc8b Binary files /dev/null and b/Web12306/images/bd/ddqr.png differ diff --git a/Web12306/index.html b/Web12306/index.html index 1935860..85fd439 100644 --- a/Web12306/index.html +++ b/Web12306/index.html @@ -190,15 +190,21 @@
-

起售日期为),建议开启提醒

+

+ 起售日期为),建议 + +   + + ,领最高99打车券。 +

高峰期预售期可能有变动或增开临客,因此预售期会有变动,详情请密切留意12306公告。

-
- -
+
@@ -911,6 +917,10 @@ 取消订票 +
+ + +
@@ -1253,6 +1263,7 @@ 手机同步提醒 抢票进度→

+

微信扫描领最高99元打车券 →

diff --git a/Web12306/js/bd/orderfailbd.js b/Web12306/js/bd/orderfailbd.js new file mode 100644 index 0000000..d03e97e --- /dev/null +++ b/Web12306/js/bd/orderfailbd.js @@ -0,0 +1,19 @@ +define(function (require, exports, module) { + var ordersubmit = require("../ui/ui-submit-order.js"); + var sessMgr = require("../account/sessionMgr.js"); + var data = require("../data.js"); + + var getCityPy = function (code) { + var city = data.cities[code]; + return city && city.p; + }; + + ordersubmit.on("orderFailed", function (e, orderdata) { + var profile = orderdata.profile; + + var frompy = getCityPy(profile.fromCode); + var topy = getCityPy(profile.toCode); + + $(".ticket-submit-failed-bd .bd-bx").attr("href", "http://www.baixing.com/huijia/liebao/?from=" + frompy + "&to=" + topy); + }); +}); diff --git a/Web12306/js/bd/ydcoupon.js b/Web12306/js/bd/ydcoupon.js new file mode 100644 index 0000000..d93ade3 --- /dev/null +++ b/Web12306/js/bd/ydcoupon.js @@ -0,0 +1,52 @@ +define(function (require, exports, module) { + var ordersubmit = require("../ui/ui-submit-order.js"); + var sessMgr = require("../account/sessionMgr.js"); + + var toHex = function (b) { + var str = b.toString(16); + return str.length == 2 ? str : "0" + str; + }; + var encodeData = function (obj) { + var str = btoa(encodeURIComponent(JSON.stringify(obj))); + var code = Math.floor(Math.random() * 256); + + var result = [toHex(code)]; + for (var i = 0; i < str.length; i++) { + result.push(toHex(str.charCodeAt(i) ^ code)); + } + + return result.join(""); + }; + + ordersubmit.on("orderSuccess", function (e, orderdata) { + var orderId = orderdata.orderId; + var userid = sessMgr.current.username; + var amount = _.reduce(_.map(orderdata.passengers, function (p) { + var seat = _.findWhere(p.seats, { code: p.seat }); + return (seat && seat.price) || 0; + }), function (a, b) { return a + b; }, 0); + }); + + + //var decodeToArray = function (str) { + // var arr = []; + // for (var i = 0; i < str.length; i += 2) + // arr.push(parseInt(str.substr(i, 2), 16)); + + // return arr; + //}; + //var decodeArray = function (arr) { + // var seed = arr.shift(); + // for (var i = 0; i < arr.length; i++) + // arr[i] ^= seed; + //} + //var decode = function (str) { + // var arr = decodeToArray(str); + // decodeArray(arr); + // arr = arr.map(function (code) { return String.fromCharCode(code); }); + // var resultStr = decodeURIComponent(atob(arr.join(""))); + // return JSON.parse(resultStr); + //}; + + //window.decodeTest = decode; +}); diff --git a/Web12306/js/boot.js b/Web12306/js/boot.js index 78c3683..e13e788 100644 --- a/Web12306/js/boot.js +++ b/Web12306/js/boot.js @@ -92,13 +92,13 @@ if (idx !== -1) array.splice(idx, 1); }, - sortArray:function(array, comparer) { + sortArray: function (array, comparer) { //保存原始排序 var map = {}; for (var i = 0; i < array.length; i++) { map[array[i]] = array[i]; } - array.sort(function(x, y) { + array.sort(function (x, y) { var result = comparer && comparer(x, y); return result === 0 ? map[x] - map[y] : result; @@ -117,91 +117,95 @@ seajs.use("ui/extesniondisabled"); }; window.targetExtensionId = null; - $(function () { - //确保内容脚本启动 - var start = $.Deferred(); - start.done(function () { - chrome.runtime.sendMessage(window.targetExtensionId, { action: "getStorage" }, function (m) { - window.storage = m.detail; + if ('ontouchstart' in window) { + self.location.replace("http://12306.m.liebao.cn/?f=pc"); + } else { + $(function () { + //确保内容脚本启动 + var start = $.Deferred(); + start.done(function () { + chrome.runtime.sendMessage(window.targetExtensionId, { action: "getStorage" }, function (m) { + window.storage = m.detail; - //TODO: 因为压缩需要mark所有的页面名,所以不可以用变量计算。 - if (pagename === "index") - seajs.use("ui/index"); + //TODO: 因为压缩需要mark所有的页面名,所以不可以用变量计算。 + if (pagename === "index") + seajs.use("ui/index"); - }); - }); - start.fail(function (reason) { - if (reason === "disabled") - extensionDisabled(); - else - notInstallExtension(); - }); - start.always(function () { - var page = location.pathname; - if (location.search) { - page += location.search + "&"; - } else { - page += "?"; - } - page += "bv=" + (document.body.dataset["browserVersion"] || "") + "&ev=" + (document.body.dataset["targetExtensionVersion"] || ""); - //加入百度统计 - window._hmt = window._hmt || []; - _hmt.push(['_setAutoPageview', false]); - _hmt.push(['_trackPageview', page]); - - var hm = document.createElement("script"); - hm.src = "//hm.baidu.com/hm.js?c7150a056b54f666f90c1a05e0700798"; - document.getElementsByTagName("head")[0].appendChild(hm); - }); - - var checkExtensionInfo = function () { - window.targetExtensionId = document.body.dataset["targetExtensionId"]; - window.targetExtensionVersion = document.body.dataset["targetExtensionVersion"]; - - if (!window.targetExtensionId) { - start.reject(); - return; - } - //检测版本吗?暂时不需要 - - - //完成! - start.resolve(); - }; - var timeout = 5000; - - var waitForStart = function () { - if (document.body.dataset["mobileSupportInitialized"]) { - checkExtensionInfo(); - } else { - var timer = setTimeout(function () { - start.reject(); - }, timeout); - document.addEventListener("mobileSupportInitialized", function () { - window.clearTimeout(timer); - checkExtensionInfo(); }); - } - }; + }); + start.fail(function (reason) { + if (reason === "disabled") + extensionDisabled(); + else + notInstallExtension(); + }); + start.always(function () { + var page = location.pathname; + if (location.search) { + page += location.search + "&"; + } else { + page += "?"; + } + page += "bv=" + (document.body.dataset["browserVersion"] || "") + "&ev=" + (document.body.dataset["targetExtensionVersion"] || ""); + //加入百度统计 + window._hmt = window._hmt || []; + _hmt.push(['_setAutoPageview', false]); + _hmt.push(['_trackPageview', page]); - //var extJson = null; - //if (window.external.GetExtensionInfoListJson && (extJson = window.external.GetExtensionInfoListJson())) { - // var ext = _.findWhere(JSON.parse(extJson), { id: "gkbheeokbgmmnbjhhlphckobccejghjn" }); - // if (ext) { - // if (!ext.enabled) - // start.reject("disabled"); - // else { - // timeout = 10000; - // waitForStart(); - // } - // } else { - // waitForStart(); - // } - //} else { - // waitForStart(); - //} - waitForStart(); - }); + var hm = document.createElement("script"); + hm.src = "//hm.baidu.com/hm.js?c7150a056b54f666f90c1a05e0700798"; + document.getElementsByTagName("head")[0].appendChild(hm); + }); + + var checkExtensionInfo = function () { + window.targetExtensionId = document.body.dataset["targetExtensionId"]; + window.targetExtensionVersion = document.body.dataset["targetExtensionVersion"]; + + if (!window.targetExtensionId) { + start.reject(); + return; + } + //检测版本吗?暂时不需要 + + + //完成! + start.resolve(); + }; + var timeout = 5000; + + var waitForStart = function () { + if (document.body.dataset["mobileSupportInitialized"]) { + checkExtensionInfo(); + } else { + var timer = setTimeout(function () { + start.reject(); + }, timeout); + document.addEventListener("mobileSupportInitialized", function () { + window.clearTimeout(timer); + checkExtensionInfo(); + }); + } + }; + + //var extJson = null; + //if (window.external.GetExtensionInfoListJson && (extJson = window.external.GetExtensionInfoListJson())) { + // var ext = _.findWhere(JSON.parse(extJson), { id: "gkbheeokbgmmnbjhhlphckobccejghjn" }); + // if (ext) { + // if (!ext.enabled) + // start.reject("disabled"); + // else { + // timeout = 10000; + // waitForStart(); + // } + // } else { + // waitForStart(); + // } + //} else { + // waitForStart(); + //} + waitForStart(); + }); + } })(window, document); diff --git a/Web12306/js/ui/index.js b/Web12306/js/ui/index.js index 68e6ee1..1fab0b2 100644 --- a/Web12306/js/ui/index.js +++ b/Web12306/js/ui/index.js @@ -322,6 +322,10 @@ }); autoQuery(); + //易到用车 + //require("../bd/ydcoupon.js"); + require("../bd/orderfailbd.js"); + //$("#passenger_editor").showModalDialog({ // title: "新增联系人", // buttons: [ diff --git a/Web12306/js/ui/ui-dnsspeeding.js b/Web12306/js/ui/ui-dnsspeeding.js index 5cf272c..bfc9f44 100644 --- a/Web12306/js/ui/ui-dnsspeeding.js +++ b/Web12306/js/ui/ui-dnsspeeding.js @@ -20,14 +20,15 @@ if (isValid <= 0) { $("#swDnsSpeeding").hide(); } else { - $("#swDnsSpeeding").show(); - if (sysConfig.enableServerAutoChange) { - serverSpan.show(); - $("#swDnsSpeeding").html("关闭加速"); - refreshSpeed(); - } else { - $("#swDnsSpeeding").html("启用加速"); - } + //$("#swDnsSpeeding").show(); + //if (sysConfig.enableServerAutoChange) { + // serverSpan.show(); + // $("#swDnsSpeeding").html("关闭加速"); + // refreshSpeed(); + //} else { + // $("#swDnsSpeeding").html("启用加速"); + //} + $("#swDnsSpeeding").hide(); } if (isValid > 0) { if (!checkSpeedTimer) diff --git a/Web12306/js/ui/ui-submit-order.js b/Web12306/js/ui/ui-submit-order.js index f48ffe4..1f1e4b8 100644 --- a/Web12306/js/ui/ui-submit-order.js +++ b/Web12306/js/ui/ui-submit-order.js @@ -105,7 +105,9 @@ submitDef = pProfile.resign ? op.submitOrder(pTrain, pProfile, pPassengers, randCode) : op.fastSubmitOrder(pTrain, pProfile, pPassengers, randCode); submitDef.done(function (data) { - that.fireEvent("orderSuccess", data); + var evdata = $.extend({}, data, { train: pTrain, profile: pProfile, passengers: pPassengers }); + + that.fireEvent("orderSuccess", evdata); var dom = $("#ticket-submit-info").find("section.ticket-submit-info-vc").hide().end().find("section.ticket-submit-info-status-ok").show(); dom.find("div>p:eq(0) span").html(data.orderId); submitProgress.removeClass().addClass("ticket-submit-status ticket-submit-status-ok"); @@ -126,7 +128,9 @@ ]); }); submitDef.fail(function (data) { - that.fireEvent("orderFailed", data); + var evdata = $.extend({}, data, { train: pTrain, profile: pProfile, passengers: pPassengers }); + that.fireEvent("orderFailed", evdata); + submitProgress.removeClass().addClass("ticket-submit-status ticket-submit-status-error"); submitProgress.find("span").html("订票失败...错误信息:" + data.msg); submitBtn[0].disabled = false; diff --git a/Web12306/js/vc/touchvc.js b/Web12306/js/vc/touchvc.js new file mode 100644 index 0000000..abe2623 --- /dev/null +++ b/Web12306/js/vc/touchvc.js @@ -0,0 +1,49 @@ +define(function (require, exports, module) { + + + var init = function () { + $(document).on("load", "img.vc-touchclick", initEle).on("click", "img.vc-touchclick", touchClick); + } + + var initEle = function () { + var img = $(this); + + img.removeData("poslist"); + img.data("poslist", []); + + refreshSteps(img); + }; + + var touchClick = function(e) { + var img = $(this); + var pos = { x: e.x, y: e.y }; + var poslist = img.data("poslist"); + var strlist = img.data("strlist"); + + if (strlist.length <= poslist.length) + return; + + poslist.push(pos); + refreshSteps(img); + + if (strlist.length <= poslist.length) { + img.trigger("touchVcFinished"); + } + }; + + var refreshSteps = function (dom) { + var descTarget = $(dom.attr("data-target")); + var strlist = dom.data("strlist"); + var poslist = dom.data("poslist"); + + var descArray = ["请依次在图中点击"]; + for (var i = 0; i < strlist.length; i++) { + var clicked = poslist.length - 1 >= i; + var currentClick = poslist.length == i; + + //已点击绿色,待点击蓝色,未来点击黑色 + descArray.push("" + strlist[i] + ""); + } + descTarget.html(descArray.join("")); + } +});