diff --git a/ChatRoomServer.Main/ChatServer.cs b/ChatRoomServer.Main/ChatServer.cs
index da38cf1..3cfec7c 100644
--- a/ChatRoomServer.Main/ChatServer.cs
+++ b/ChatRoomServer.Main/ChatServer.cs
@@ -200,6 +200,9 @@ namespace ChatRoomServer.Main
private void ChatServer_NewSessionConnected(ChatSession session)
{
+ if (session.IsSessionBlocked)
+ return;
+
var cmd = session.Command;
if (cmd == "room" && session.PathSegements.Length >= 4)
diff --git a/ChatRoomServer.Main/ChatSession.cs b/ChatRoomServer.Main/ChatSession.cs
index ecedca1..52d67e9 100644
--- a/ChatRoomServer.Main/ChatSession.cs
+++ b/ChatRoomServer.Main/ChatSession.cs
@@ -46,6 +46,7 @@ namespace ChatRoomServer.Main
if ((AppServer as ChatServer).BlockUsers?.TryGetValue(UserName, out dt) == true)
{
+ IsSessionBlocked = true;
Block(dt);
return true;
}
@@ -101,13 +102,10 @@ namespace ChatRoomServer.Main
db.SaveChanges();
_connectId = ucl.Id;
- //已经封锁?
- if (user.Status == UserStatus.Blocked)
- {
- Block(blockRule.UnblockTime);
- }
}
+ public bool IsSessionBlocked { get; private set; }
+
public void Block(DateTime? unblockTime)
{
TrySend(new MessageItem(SystemMessageType.OperationBlocked, content: "很抱歉,您的账户已经被封锁,暂时无法在聊天室暂住。封锁解除时间:" + (unblockTime == null ? "无限期" : unblockTime.Value.ToString())));
@@ -212,7 +210,7 @@ namespace ChatRoomServer.Main
Content = item.Content,
Ip = RemoteEndPoint.ToString(),
RoomId = PathSegements[1],
- SendTime = DateTime.Now,
+ SendTime = item.Time,
UserName = UserName
};
db.MsgLogs.Add(msg);
diff --git a/ChatRoomServer.Main/Room/RoomContainer.cs b/ChatRoomServer.Main/Room/RoomContainer.cs
index 2f18ae7..9ddbd9c 100644
--- a/ChatRoomServer.Main/Room/RoomContainer.cs
+++ b/ChatRoomServer.Main/Room/RoomContainer.cs
@@ -56,7 +56,8 @@ namespace ChatRoomServer.Main.Room
public void Remove(ChatSession session)
{
RoomSessionContext context;
- _contexts.TryRemove(session, out context);
+ if (!_contexts.TryRemove(session, out context))
+ return;
var count = _contexts.Count;
var enumerator = _contexts.GetEnumerator();
diff --git a/ChatRoomServer.Www/Controllers/AnnouncementController.cs b/ChatRoomServer.Www/Controllers/AnnouncementController.cs
index ffea4a5..7e63b62 100644
--- a/ChatRoomServer.Www/Controllers/AnnouncementController.cs
+++ b/ChatRoomServer.Www/Controllers/AnnouncementController.cs
@@ -15,9 +15,30 @@ namespace ChatRoomServer.Www.Controllers
using FSLib.MvcWeb;
using FSLib.Network.Http;
- [EnableCors("http://12306.liebao.cn,http://test.fishlee.net", "*", "*", "")]
public class AnnouncementController : Controller
{
+ ///
+ /// Called when authorization occurs.
+ ///
+ /// Information about the current request and action.
+ protected override void OnAuthorization(AuthorizationContext filterContext)
+ {
+ base.OnAuthorization(filterContext);
+
+ var origin = filterContext.RequestContext.HttpContext.Request.Headers["Origin"];
+ if (!origin.IsNullOrEmpty())
+ {
+ if (!Regex.IsMatch(origin, @"^https?://.*?\.(fishlee\.net|liebao\.cn)$", RegexOptions.IgnoreCase))
+ {
+ filterContext.Result = new EmptyResult();
+ return;
+ }
+
+ filterContext.HttpContext.Response.AppendHeader("Access-Control-Allow-Origin", origin);
+ }
+ }
+
+
[AllowAnonymous]
[HttpGet, OutputCache(Duration = 1200, VaryByHeader = "Origin")]
public async Task List()
diff --git a/ChatRoomServer.Www/Controllers/UsersController.cs b/ChatRoomServer.Www/Controllers/UsersController.cs
index 8e262eb..8d4d7fc 100644
--- a/ChatRoomServer.Www/Controllers/UsersController.cs
+++ b/ChatRoomServer.Www/Controllers/UsersController.cs
@@ -6,27 +6,27 @@ using System.Web.Mvc;
namespace ChatRoomServer.Www.Controllers
{
- public class UsersController : Controller
- {
- // GET: Users
- public ActionResult AbuseList()
- {
- return View();
- }
+ public class UsersController : Controller
+ {
+ // GET: Users
+ public ActionResult AbuseList()
+ {
+ return View();
+ }
- public ActionResult ConnectionLog()
- {
- return View();
- }
+ public ActionResult ConnectionLog()
+ {
+ return View();
+ }
- public ActionResult UserList()
- {
- return View();
- }
+ public ActionResult UserList()
+ {
+ return View();
+ }
- public ActionResult BlockList()
- {
- return View();
- }
- }
+ public ActionResult BlockList()
+ {
+ return View();
+ }
+ }
}
\ No newline at end of file
diff --git a/Web12306/css/ui/query-result.css b/Web12306/css/ui/query-result.css
index 46ab394..bfd7616 100644
--- a/Web12306/css/ui/query-result.css
+++ b/Web12306/css/ui/query-result.css
@@ -75,10 +75,27 @@
}
.result .train-seats .train-notontime {
- font-size: 20px;
+ font-size: 16px;
color: #999;
}
+ .result .train-seats .train-nostarttip {
+ display: block;
+ margin-top: 5px;
+ }
+
+ .result .train-seats .train-nostarttip-insell {
+ color: #7F7FE0;
+ }
+
+ .result .train-seats .train-nostarttip-early {
+ color: #7F7FE0;
+ }
+
+ .result .train-seats .train-nostarttip-later {
+ color: green;
+ }
+
.result .train-seats .row2 {
}
diff --git a/Web12306/index.html b/Web12306/index.html
index 02bf5d9..7a5f291 100644
--- a/Web12306/index.html
+++ b/Web12306/index.html
@@ -725,6 +725,7 @@
{{?(t.available==0||t.available==-1)&&!hasSeat}}
{{?t.selltime}}
{{=ext.utility.formatSellDate(t.selltime)}} 起售
+ {{=t.preStationInfo||""}}
{{??t.limitSellInfo}}
本车次{{!t.limitSellInfo}}
{{??}}
diff --git a/Web12306/js/otn/queryticket.js b/Web12306/js/otn/queryticket.js
index 3854b70..9ebcd23 100644
--- a/Web12306/js/otn/queryticket.js
+++ b/Web12306/js/otn/queryticket.js
@@ -5,6 +5,8 @@
var ev = require("../platform/EventObject.js");
var dynamicjs = require("../otn/dynamicjs.js");
var sessmgr = require("../account/sessionMgr.js");
+ var stationData = require("../station/station_data.js");
+ var utility = require('../utility.js');
var extensionVersion = parseInt(document.body.dataset["targetExtensionVersion"].replace(/\./g, ""));
@@ -68,20 +70,20 @@
available: t.queryLeftNewDTO.canWebBuy === 'Y' ? 1 : 0,
start: {
code: t.queryLeftNewDTO.start_station_telecode,
- name: t.queryLeftNewDTO.start_station_name,
+ name: t.queryLeftNewDTO.start_station_name
},
from: {
code: t.queryLeftNewDTO.from_station_telecode,
fromStationNo: t.queryLeftNewDTO.from_station_no,
name: t.queryLeftNewDTO.from_station_name,
- endpoint: t.queryLeftNewDTO.from_station_telecode == t.queryLeftNewDTO.start_station_telecode,
+ endpoint: t.queryLeftNewDTO.from_station_telecode === t.queryLeftNewDTO.start_station_telecode,
time: t.queryLeftNewDTO.start_time
},
to: {
code: t.queryLeftNewDTO.to_station_telecode,
toStationNo: t.queryLeftNewDTO.to_station_no,
name: t.queryLeftNewDTO.to_station_name,
- endpoint: t.queryLeftNewDTO.end_station_telecode == t.queryLeftNewDTO.to_station_telecode,
+ endpoint: t.queryLeftNewDTO.end_station_telecode === t.queryLeftNewDTO.to_station_telecode,
time: t.queryLeftNewDTO.arrive_time
},
elapsedTime: {
@@ -154,6 +156,41 @@
}
}
+ //处理跨站购票预售提醒
+ _.each(trainData.available, function (t) {
+ //非预售,或预售的非当天的,始发站的,则跳过
+ if (!t.selltime || Math.floor(new Date().getTime() / 86400000) !== Math.floor(t.selltime.getTime() / 86400000))
+ return;
+ //查询始发站起售时间
+ var firstStationSellTime = stationData.sellTime[t.start.code];
+ if (!firstStationSellTime)
+ return;
+
+ //判断始发站和当前站时间间隔。如果间隔超过指定的时间,则放弃建议
+ var spanSellCurrent = Math.floor((t.selltime.getTime() % 86400000) / 1000) + 8 * 3600; //需要加上时区
+ var spanSellNow = Math.floor((new Date().getTime() % 86400000) / 1000) + 8 * 3600;
+ var spanSellStart = utility.toTimeSpan(firstStationSellTime, true);
+ var timeDifference = Math.abs((spanSellCurrent - spanSellStart) / 60);
+ var isEarly = spanSellStart < spanSellCurrent;
+ var isStartInSell = spanSellNow >= spanSellStart;
+ var tCode = t.code[0];
+
+ //if (
+ // (tCode === 'G' && timeDifference > 120) //高铁,超过2小时
+ // ||
+ // (tCode === 'D' && timeDifference > 180) //动车,超过3小时
+ // ||
+ // ((tCode === 'Z' || tCode === 'T') && timeDifference > 360) //直达/特快,超过6小时
+ // ||
+ // timeDifference > 600 //其它类型车次大于10小时
+ // )
+ // return;
+
+ t.preStationInfo = "";
+ t.preStationInfo += "始发站【" + t.start.name + "】起售时间为【" + firstStationSellTime + "】," + (isStartInSell ? "已经在售" : isEarly ? "比当前车站起售时间早,可先去看看" : "可稍后留意");
+ t.preStationInfo += "";
+ });
+
return trainData;
};
@@ -272,7 +309,7 @@
def.reject("网络错误");
});
};
- var postFetchTicketUrl = function() {
+ var postFetchTicketUrl = function () {
//加载查询页之后,必须要加载一次联系人,否则妥妥地出票失败。这傻逼逻辑啊。。
if (sessmgr.isLogined) {
sessmgr.reloadPassengers();
diff --git a/Web12306/js/ui/ui-autosubmitform.js b/Web12306/js/ui/ui-autosubmitform.js
index 8edbac9..60baab3 100644
--- a/Web12306/js/ui/ui-autosubmitform.js
+++ b/Web12306/js/ui/ui-autosubmitform.js
@@ -410,7 +410,7 @@
}).blur(function () {
queryTable.hide();
}).keydown(function (e) {
- if (e.keyCode == 13) {
+ if (e.keyCode === 13) {
var s = this.value;
if (s)
exports.addTrainToList(s);
@@ -666,6 +666,23 @@
initDateLoop();
initSeatOrder();
initProfileOperation();
+
+ //自动切换选项
+ $(document).on("click", "a[data-command='suggest-swtichrelate']", function () {
+ var code = this.dataset.tsCode;
+ var trainCode = this.dataset.trainCode;
+
+ //自动显示高级选项
+ if (!$("div.options-param").is(":visible")) {
+ $("div.options-param").click();
+ }
+ exports.addTrainToList(trainCode);
+
+ var ipt = $("#from_city");
+ ipt[0].dataset.code = code;
+ ipt[0].value = $.trim($(this).text());
+ ipt.change();
+ });
};
init();
});
diff --git a/Web12306/js/ui/ui-sysnotice.js b/Web12306/js/ui/ui-sysnotice.js
index afc2d53..1b9dd77 100644
--- a/Web12306/js/ui/ui-sysnotice.js
+++ b/Web12306/js/ui/ui-sysnotice.js
@@ -9,7 +9,7 @@
var port = require("../platform/extensionPort.js");
var loadSystemNotice = function () {
- $.get(loadUrl).done(function (json) {
+ $.getJSON(loadUrl).done(function (json) {
var nowDate = new Date().getTime();
json.lastLoad = new Date().getTime();
if (savedNotice.lastReadId) {
diff --git a/Web12306/js/utility.js b/Web12306/js/utility.js
index d5a23de..3ccc187 100644
--- a/Web12306/js/utility.js
+++ b/Web12306/js/utility.js
@@ -53,8 +53,10 @@
}
for (var k in o) {
- if (new RegExp("(" + k + ")").test(format)) {
- format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
+ if (o.hasOwnProperty(k)) {
+ if (new RegExp("(" + k + ")").test(format)) {
+ format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
+ }
}
}
return format;
@@ -149,6 +151,22 @@
return encodeHTMLRules[m] || m;
});
};
+ /*
+ * 分析时间字符串,并转换为相当于当天的秒数
+ */
+ exports.toTimeSpan = function (str, includeHour) {
+
+ includeHour = typeof includeHour === 'undefined' ? true : includeHour;
+
+ var m = /(\d{1,2}):(\d{1,2})(:(\d{1,2}))?/i.exec(str);
+ if (!m) return null;
+
+ var th = m[4] || includeHour ? parseInt(m[1], 10) : 0;
+ var tm = parseInt(m[2], 10);
+ var ts = m[4] && !includeHour ? parseInt(m[4], 10) : 0;
+
+ return th * 3600 + tm * 60 + ts;
+ };
$.fn.toBase64Data = function () {
var arr = [];
this.each(function () {