提交最新代码
This commit is contained in:
parent
37ad0c7717
commit
b19d9012a6
@ -1366,6 +1366,93 @@ window.cbl = function (u, h) {
|
||||
//#endregion
|
||||
|
||||
|
||||
//#region 定时提醒
|
||||
|
||||
(function TimerAlerm() {
|
||||
var tasks = JSON.parse(localStorage["alarm"] || "[]");
|
||||
var buttonImgUrl = "/infobar/theme/plus_16.png";
|
||||
var iconLeft = "/icons/icon_n.png";
|
||||
var checkTimer = null;
|
||||
var alarmData = {};
|
||||
|
||||
var saveAlarm = function() {
|
||||
localStorage["alarm"] = JSON.stringify(tasks);
|
||||
};
|
||||
|
||||
var buttonClickCallback = function (btnId, index) {
|
||||
if (!alarmData[btnId])
|
||||
return;
|
||||
|
||||
var task = alarmData[btnId];
|
||||
var data = task.data;
|
||||
|
||||
chrome.tabs.create({
|
||||
active: true,
|
||||
url: "http://12306.liebao.cn/#" + encodeURIComponent(JSON.stringify(data))
|
||||
});
|
||||
};
|
||||
chrome.notifications.onButtonClicked.addListener(buttonClickCallback);
|
||||
|
||||
var checkForAlarm = function () {
|
||||
checkTimer = null;
|
||||
var hasChange = false;
|
||||
while (tasks.length > 0 && tasks[0].time <= new Date().getTime()) {
|
||||
(function (task) {
|
||||
var id = "ALARM-" + task.data.fromCode + "-" + task.data.toCode + new Date().getTime();
|
||||
|
||||
chrome.notifications.create(id, {
|
||||
type: "basic",
|
||||
iconUrl: iconLeft,
|
||||
title: task.group,
|
||||
message: task.text,
|
||||
buttons: [
|
||||
{ title: "立刻打开订票页面", iconUrl: buttonImgUrl }
|
||||
]
|
||||
}, function (_id) {
|
||||
id = _id;
|
||||
alarmData[id] = task;
|
||||
setTimeout(function () {
|
||||
delete alarmData[_id];
|
||||
chrome.notifications.clear(_id, function () { });
|
||||
}, 10000);
|
||||
});
|
||||
})(tasks.shift());
|
||||
hasChange = true;
|
||||
}
|
||||
|
||||
if (tasks.length)
|
||||
checkTimer = setTimeout(checkForAlarm, 30000);
|
||||
if (hasChange)
|
||||
saveAlarm();
|
||||
};
|
||||
|
||||
|
||||
chrome.runtime.onMessageExternal.addListener(function (m, s, r) {
|
||||
if (!m || !m.action || m.action !== 'setAlarmTask')
|
||||
return;
|
||||
|
||||
var newtasks = m.detail;
|
||||
_.each(newtasks, function(t) {
|
||||
tasks.push(t);
|
||||
});
|
||||
tasks.sort(function (x, y) {
|
||||
return x.time - y.time;
|
||||
});
|
||||
|
||||
if (!checkTimer)
|
||||
checkForAlarm();
|
||||
});
|
||||
|
||||
checkForAlarm();
|
||||
})();
|
||||
|
||||
|
||||
|
||||
//#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
////#region conflict extension
|
||||
|
||||
//(function () {
|
||||
|
BIN
RwTicketAssistantV2/app/icons/icon_n.png
Normal file
BIN
RwTicketAssistantV2/app/icons/icon_n.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
@ -35,7 +35,7 @@
|
||||
"exclude_matches": [ ],
|
||||
"include_globs": [ ],
|
||||
"js": [ "libs/jquery.js", "12306/mobileproxy.js" ],
|
||||
"matches": [ "http://test.fishlee.net/*", "http://app.fishlee.net/*" ],
|
||||
"matches": [ "http://test.fishlee.net/*", "http://app.fishlee.net/*", "http://12306.liebao.cn/*" ],
|
||||
"run_at": "document_end"
|
||||
},
|
||||
{
|
||||
|
@ -1,19 +1,226 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Web;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Web12306
|
||||
{
|
||||
public class TrainSuggestion
|
||||
public class TrainSuggestion : IHttpHandler
|
||||
{
|
||||
#region Implementation of IHttpHandler
|
||||
|
||||
/// <summary>
|
||||
/// 通过实现 <see cref="T:System.Web.IHttpHandler"/> 接口的自定义 HttpHandler 启用 HTTP Web 请求的处理。
|
||||
/// </summary>
|
||||
/// <param name="context"><see cref="T:System.Web.HttpContext"/> 对象,它提供对用于为 HTTP 请求提供服务的内部服务器对象(如 Request、Response、Session 和 Server)的引用。</param>
|
||||
public void ProcessRequest(HttpContext context)
|
||||
{
|
||||
var request = context.Request;
|
||||
var data = request.Form["data"];
|
||||
if (string.IsNullOrEmpty(data))
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
var ri = JsonConvert.DeserializeObject<RequestInfo>(data);
|
||||
var suggestion = GetSuggestionResponseContent(ri);
|
||||
|
||||
context.Response.ContentType = "application/json";
|
||||
context.Response.Write(JsonConvert.SerializeObject(suggestion));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取一个值,该值指示其他请求是否可以使用 <see cref="T:System.Web.IHttpHandler"/> 实例。
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// 如果 <see cref="T:System.Web.IHttpHandler"/> 实例可再次使用,则为 true;否则为 false。
|
||||
/// </returns>
|
||||
public bool IsReusable { get { return true; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region 生成建议
|
||||
|
||||
static Dictionary<char, int> _timeRangeLimit = new Dictionary<char, int>()
|
||||
{
|
||||
{'D', 240},
|
||||
{'G', 180},
|
||||
{'*', 300}
|
||||
};
|
||||
|
||||
int GetStopTime(string stopTimeStr)
|
||||
{
|
||||
var m = Regex.Match(stopTimeStr, @"(\d+)分钟");
|
||||
return m.Success ? int.Parse(m.Groups[1].Value) : 0;
|
||||
}
|
||||
|
||||
int GetTimeValue(string time)
|
||||
{
|
||||
var m = Regex.Match(time, @"0?(\d+):0?(\d+)");
|
||||
return m.Success ? int.Parse(m.Groups[1].Value) * 60 + int.Parse(m.Groups[2].Value) : 0;
|
||||
}
|
||||
|
||||
int GetTimeSpace(string time1, string time2)
|
||||
{
|
||||
var x1 = GetTimeValue(time1);
|
||||
var x2 = GetTimeValue(time2);
|
||||
|
||||
return x1 <= x2 ? x2 - x1 : x2 + 24 * 60 - x1;
|
||||
}
|
||||
|
||||
string GetSuggestionResponseContent(RequestInfo ri)
|
||||
{
|
||||
if (ri.CheckIllegal())
|
||||
return string.Empty;
|
||||
|
||||
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
public class SuggestItemComparer : IComparer<SuggestItem>
|
||||
{
|
||||
#region Implementation of IComparer<in StopInfo>
|
||||
|
||||
/// <summary>
|
||||
/// 比较两个对象并返回一个值,指示一个对象是小于、等于还是大于另一个对象。
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// 一个有符号整数,指示 <paramref name="x"/> 与 <paramref name="y"/> 的相对值,如下表所示。 值 含义 小于零 <paramref name="x"/> 小于 <paramref name="y"/>。 零 <paramref name="x"/> 等于 <paramref name="y"/>。 大于零 <paramref name="x"/> 大于 <paramref name="y"/>。
|
||||
/// </returns>
|
||||
/// <param name="x">要比较的第一个对象。</param><param name="y">要比较的第二个对象。</param>
|
||||
public int Compare(SuggestItem x, SuggestItem y)
|
||||
{
|
||||
if (x.EndPoint ^ y.EndPoint)
|
||||
return x.EndPoint ? -1 : 1;
|
||||
|
||||
return x.StopTime - y.StopTime;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class SuggestItem
|
||||
{
|
||||
[JsonProperty("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[JsonProperty("code")]
|
||||
public string Code { get; set; }
|
||||
|
||||
[JsonProperty("ep")]
|
||||
public bool EndPoint { get; set; }
|
||||
|
||||
[JsonProperty("st")]
|
||||
public int StopTime { get; set; }
|
||||
}
|
||||
|
||||
public class RequestInfo
|
||||
{
|
||||
|
||||
public string From { get; set; }
|
||||
|
||||
public string To { get; set; }
|
||||
|
||||
public Dictionary<string, TrainInfo> Stops { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 检测是否有非法请求,有则返回true
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool CheckIllegal()
|
||||
{
|
||||
if (Stops.Values.Any(s => s.from.code == s.start.code && s.to.code == s.end.code))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class StopInfo
|
||||
{
|
||||
public string start_station_name { get; set; }
|
||||
public string arrive_time { get; set; }
|
||||
public string station_train_code { get; set; }
|
||||
public string station_name { get; set; }
|
||||
public string train_class_name { get; set; }
|
||||
public string service_type { get; set; }
|
||||
public string start_time { get; set; }
|
||||
public string stopover_time { get; set; }
|
||||
public string end_station_name { get; set; }
|
||||
public string station_no { get; set; }
|
||||
public bool isEnabled { get; set; }
|
||||
}
|
||||
|
||||
public class SeatTicketInfo
|
||||
{
|
||||
public string code { get; set; }
|
||||
public string name { get; set; }
|
||||
public int price { get; set; }
|
||||
public int count { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class SimpleStationInfo
|
||||
{
|
||||
public string code { get; set; }
|
||||
public string name { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class DetailStationInfo : SimpleStationInfo
|
||||
{
|
||||
public string fromStationNo { get; set; }
|
||||
public bool endpoint { get; set; }
|
||||
public string time { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class TrainInfo
|
||||
{
|
||||
public string id { get; set; }
|
||||
public string code { get; set; }
|
||||
public int available { get; set; }
|
||||
public SimpleStationInfo start { get; set; }
|
||||
public DetailStationInfo from { get; set; }
|
||||
public DetailStationInfo to { get; set; }
|
||||
public Elapsedtime elapsedTime { get; set; }
|
||||
public SimpleStationInfo end { get; set; }
|
||||
public string ypinfo { get; set; }
|
||||
public string ypinfo_ex { get; set; }
|
||||
public string locationCode { get; set; }
|
||||
public int controlDay { get; set; }
|
||||
public string supportCard { get; set; }
|
||||
public string saleTime { get; set; }
|
||||
public string secureStr { get; set; }
|
||||
public object selltime { get; set; }
|
||||
public string date { get; set; }
|
||||
public object limitSellInfo { get; set; }
|
||||
public SeatTicketInfo[] tickets { get; set; }
|
||||
public Dictionary<char, SeatTicketInfo> ticketMap { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class Elapsedtime
|
||||
{
|
||||
public string days { get; set; }
|
||||
public string total { get; set; }
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -151,6 +151,7 @@
|
||||
<Content Include="css\ui\city-selector.css" />
|
||||
<Content Include="css\ui\date-popup.css" />
|
||||
<Content Include="css\ui\date-selector.css" />
|
||||
<Content Include="css\ui\dialogs.css" />
|
||||
<Content Include="css\ui\float-passenger-selector.css" />
|
||||
<Content Include="css\ui\index-search-base.css" />
|
||||
<Content Include="css\ui\options-param.css" />
|
||||
@ -229,6 +230,7 @@
|
||||
<Content Include="js\ui\widget_datebar.js" />
|
||||
<Content Include="js\ui\widget_datedropdown.js" />
|
||||
<Content Include="js\ui\widget_message_popup.js" />
|
||||
<Content Include="js\ui\widget_modalDialog.js" />
|
||||
<Content Include="js\ui\widget_sell_notification.js" />
|
||||
<Content Include="js\ui\widget_verifycode.js" />
|
||||
<None Include="Scripts\_references.js" />
|
||||
|
@ -46,15 +46,15 @@ a.button-primary {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.button-primary:hover {
|
||||
background: linear-gradient(to top, #ff912d, #ffb72e);
|
||||
color: #ffffff;
|
||||
}
|
||||
.button-primary:hover {
|
||||
background: linear-gradient(to top, #ff912d, #ffb72e);
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.button-primary:active {
|
||||
background: linear-gradient(to top, #ee7609, #ff9712);
|
||||
color: #ffffff;
|
||||
}
|
||||
.button-primary:active {
|
||||
background: linear-gradient(to top, #ee7609, #ff9712);
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
|
||||
.button-block {
|
||||
@ -68,7 +68,7 @@ a.button-primary {
|
||||
}
|
||||
|
||||
.button-mini {
|
||||
padding: 5px 15px;
|
||||
padding: 0 15px;
|
||||
}
|
||||
|
||||
.text {
|
||||
@ -93,11 +93,28 @@ select.normal {
|
||||
border: 1px solid #b5b5b5;
|
||||
color: #737373;
|
||||
}
|
||||
select.normal:disabled {
|
||||
color: #bbbbbb;
|
||||
background-color: #f6f6f6;
|
||||
border-color: #d9d9d9;
|
||||
|
||||
select.normal:disabled {
|
||||
color: #bbbbbb;
|
||||
background-color: #f6f6f6;
|
||||
border-color: #d9d9d9;
|
||||
}
|
||||
|
||||
select.normal:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
|
||||
.txt-input {
|
||||
border: 1px solid #b7b7b7;
|
||||
border-radius: 2px;
|
||||
line-height: 16px;
|
||||
background-image: linear-gradient(to bottom, #e7e7e7 0, #fff 20%);
|
||||
font-size: 14px;
|
||||
padding: 4px;
|
||||
}
|
||||
select.normal:focus {
|
||||
outline: none;
|
||||
.txt-input-block {
|
||||
display: block;
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
}
|
@ -17,6 +17,7 @@
|
||||
@import url('ui/ui-autorefresh.css');
|
||||
@import url('ui/chat.css');
|
||||
@import url('ui/widget-selltime-notification.css');
|
||||
@import url('ui/dialogs.css');
|
||||
|
||||
.icon {
|
||||
background: url(../images/icon.png) no-repeat;
|
||||
|
50
Web12306/css/ui/dialogs.css
Normal file
50
Web12306/css/ui/dialogs.css
Normal file
@ -0,0 +1,50 @@
|
||||
#passenger_editor {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#passenger_editor > header {
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#passenger_editor > header > span {
|
||||
font-weight: normal;
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
#passenger_editor > dl {
|
||||
margin-top: 10px;
|
||||
margin-bottom: 10px;
|
||||
line-height: 30px;
|
||||
}
|
||||
|
||||
#passenger_editor > dl > dt {
|
||||
float: left;
|
||||
clear: left;
|
||||
width: 100px;
|
||||
text-align: right;
|
||||
vertical-align: middle;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#passenger_editor > dl > dd {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#passenger_editor input,
|
||||
#passenger_editor select {
|
||||
width: 60%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
#passenger_editor input.txt-input-block {
|
||||
width: 80%;
|
||||
}
|
||||
|
||||
#selltip_selection {
|
||||
display: none;
|
||||
}
|
||||
#selltip_selection li {
|
||||
line-height: 170%;
|
||||
}
|
@ -173,12 +173,10 @@
|
||||
|
||||
.passenger-selector .passenger-selector-editor {
|
||||
float: left;
|
||||
margin-top: 12px;
|
||||
color: #8b8b8b;
|
||||
}
|
||||
|
||||
.passenger-selector .passenger-selector-editor a {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.passenger-selector .passenger-selector-editor a:hover {
|
||||
|
@ -28,7 +28,7 @@
|
||||
border-radius: 0 5px 5px 5px;
|
||||
border: 1px solid #c7c7c7;
|
||||
background-color: #ffffff;
|
||||
padding: 12px;
|
||||
padding: 6px;
|
||||
display: none;
|
||||
}
|
||||
|
||||
@ -43,9 +43,8 @@
|
||||
display: none;
|
||||
}
|
||||
|
||||
.passenger-selector .passenger-selector-add {
|
||||
.passenger-selector button {
|
||||
color: #616161;
|
||||
width: 26px;
|
||||
height: 26px;
|
||||
background: linear-gradient(180deg, #f4f4f4, #e9e8e9);
|
||||
border: 1px solid #d1d1d1;
|
||||
@ -53,23 +52,16 @@
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.passenger-selector .passenger-selector-add:hover {
|
||||
.passenger-selector button:hover {
|
||||
background: linear-gradient(180deg, #fefefe, #f3f3f3);
|
||||
border: 1px solid #e1e1e1;
|
||||
}
|
||||
|
||||
.passenger-selector .passenger-selector-add:active {
|
||||
.passenger-selector button:active {
|
||||
background: linear-gradient(180deg, #e9e8e9, #f4f4f4);
|
||||
border: 1px solid #d1d1d1;
|
||||
}
|
||||
|
||||
.passenger-selector .passenger-selector-add:before {
|
||||
left: 7px;
|
||||
top: 7px;
|
||||
position: relative;
|
||||
color: #616161;
|
||||
}
|
||||
|
||||
.passenger-selector .passenger-search div.fr:before {
|
||||
position: absolute;
|
||||
right: 6px;
|
||||
@ -88,7 +80,7 @@
|
||||
|
||||
.passenger-selector ul {
|
||||
width: 300px;
|
||||
margin-top: 12px;
|
||||
margin-top: 6px;
|
||||
}
|
||||
|
||||
.passenger-selector ul li {
|
||||
@ -160,7 +152,6 @@
|
||||
}
|
||||
|
||||
.passenger-selector .passenger-pager {
|
||||
margin-top: 12px;
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
@ -1,49 +1,102 @@
|
||||
.message-popup {
|
||||
border: 5px solid #ccc;
|
||||
position: fixed;
|
||||
z-index: 100001;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
opacity: 0;
|
||||
box-shadow: 3px 3px 6px rgba(200,200,200,0.6);
|
||||
background: linear-gradient(to bottom, #f7f7f7,#eaebeb);
|
||||
border-radius: 5px;
|
||||
border: 1px solid #DFDFDF;
|
||||
color: #333333;
|
||||
box-shadow: 3px 3px 7px rgba(170, 170, 170, 0.5);
|
||||
font-size: 120%;
|
||||
line-height: 140%;
|
||||
}
|
||||
|
||||
.message-popup .message-popup-inner {
|
||||
padding: 15px 20px;
|
||||
border: 1px solid #aaa;
|
||||
}
|
||||
|
||||
.message-popup-warn {
|
||||
border-color: #fadfbc;
|
||||
/*border-color: #fadfbc;*/
|
||||
}
|
||||
|
||||
.message-popup-warn .message-popup-inner {
|
||||
border-color: #BD8D51;
|
||||
/*border-color: #BD8D51;
|
||||
background: linear-gradient(to bottom, #fff0cf, #fee7c4);
|
||||
color: #b2632b;
|
||||
color: #b2632b;*/
|
||||
}
|
||||
|
||||
.message-popup-warn .message-popup-inner .fa {
|
||||
color: rgb(255, 106, 0);
|
||||
}
|
||||
|
||||
.message-popup-error {
|
||||
border-color: rgb(233, 202, 202);
|
||||
/*border-color: rgb(233, 202, 202);*/
|
||||
}
|
||||
|
||||
.message-popup-error .message-popup-inner {
|
||||
border-color: rgb(175, 94, 94);
|
||||
/*border-color: rgb(175, 94, 94);
|
||||
background: #FFF7F7;
|
||||
color: rgb(134, 77, 77);
|
||||
color: rgb(134, 77, 77);*/
|
||||
}
|
||||
|
||||
.message-popup-error .message-popup-inner .fa {
|
||||
color: rgb(165, 110, 110);
|
||||
}
|
||||
|
||||
.message-popup-ok {
|
||||
border-color: #DCF1DE;
|
||||
/*border-color: #DCF1DE;*/
|
||||
}
|
||||
|
||||
.message-popup-ok .message-popup-inner {
|
||||
border-color: #8FC08D;
|
||||
/*border-color: #8FC08D;
|
||||
background: #F2FFF3;
|
||||
color: #3d6d3d;
|
||||
color: #3d6d3d;*/
|
||||
}
|
||||
|
||||
.message-popup-ok .message-popup-inner .fa {
|
||||
color: rgb(85, 102, 183);
|
||||
}
|
||||
|
||||
|
||||
.message-popup-loading {
|
||||
background: linear-gradient(to bottom, #fff, #fafafa);
|
||||
/*background: linear-gradient(to bottom, #fff, #fafafa);
|
||||
border-color: #cccccc;
|
||||
color: #444;
|
||||
color: #444;*/
|
||||
}
|
||||
|
||||
|
||||
.message-popup-loading .message-popup-inner .fa {
|
||||
color: rgb(119, 85, 183);
|
||||
}
|
||||
|
||||
|
||||
/*浮动框*/
|
||||
.modal-dialog {
|
||||
position: fixed;
|
||||
width: 550px;
|
||||
z-index: 1100;
|
||||
background-color: #fdfbf2;
|
||||
border-radius: 5px;
|
||||
color: #444;
|
||||
box-shadow: 0 0 15px rgba(150,150,150,0.7);
|
||||
display: none;
|
||||
}
|
||||
|
||||
.modal-dialog > header {
|
||||
border-bottom: 1px solid #e3e1d9;
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
padding: 10px 10px 10px 10px;
|
||||
color: #444444;
|
||||
}
|
||||
|
||||
.modal-dialog > div {
|
||||
padding: 20px 50px 25px 50px;
|
||||
}
|
||||
|
||||
.modal-dialog footer {
|
||||
padding-bottom: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
|
@ -137,13 +137,52 @@
|
||||
}
|
||||
|
||||
#ticket-submit-info header {
|
||||
text-align: center;
|
||||
font-weight: bold;
|
||||
line-height: 32px;
|
||||
font-size: 24px;
|
||||
color: #8d5000;
|
||||
text-indent: 0;
|
||||
border-bottom: 1px solid #c6c6c6;
|
||||
color: #333333;
|
||||
text-indent: 30px;
|
||||
font-weight: bold;
|
||||
position: relative;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
#ticket-submit-info header .fa {
|
||||
color: #999;
|
||||
position: absolute;
|
||||
right: 20px;
|
||||
top: 50%;
|
||||
margin-top: -8px;
|
||||
cursor: pointer;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
#ticket-submit-info header .fa:hover {
|
||||
color: #444;
|
||||
}
|
||||
|
||||
|
||||
#ticket-submit-info > section {
|
||||
padding: 10px 20px 5px 20px;
|
||||
}
|
||||
|
||||
#ticket-submit-info > footer {
|
||||
padding: 0 30px 20px 30px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#ticket-submit-info footer button,
|
||||
#ticket-submit-info footer a {
|
||||
margin-right: 10px;
|
||||
width: 150px;
|
||||
}
|
||||
|
||||
#ticket-submit-info footer button:last-child,
|
||||
#ticket-submit-info footer a:last-child {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
|
||||
#ticket-submit-info .ticket-submit-vc {
|
||||
width: 300px;
|
||||
margin: 20px auto 20px auto;
|
||||
@ -229,10 +268,6 @@
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
#ticket-submit-info header .fa {
|
||||
top: 0;
|
||||
}
|
||||
|
||||
/*¶©µ¥½á¹û*/
|
||||
#ticket-submit-info .ticket-submit-info-status-failed,
|
||||
#ticket-submit-info .ticket-submit-info-status-ok {
|
||||
@ -244,7 +279,6 @@
|
||||
color: rgb(180, 76, 50);
|
||||
line-height: 130%;
|
||||
padding-top: 10px;
|
||||
line-height: 130%;
|
||||
font-size: 12px;
|
||||
margin-top: 5px;
|
||||
text-shadow: 0 0 1px rgba(200, 50, 50, 0.4);
|
||||
|
@ -27,47 +27,48 @@
|
||||
background-color: #f6f6f6;
|
||||
}
|
||||
|
||||
.float-dialog header {
|
||||
line-height: 52px;
|
||||
.float-dialog > header {
|
||||
line-height: 32px;
|
||||
font-size: 16px;
|
||||
border-bottom: 1px solid #c6c6c6;
|
||||
color: #333333;
|
||||
text-indent: 30px;
|
||||
font-weight: bold;
|
||||
position: relative;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.float-dialog header .fa {
|
||||
.float-dialog > header .fa {
|
||||
color: #999;
|
||||
position: absolute;
|
||||
right: 20px;
|
||||
top: 50%;
|
||||
margin-top: -5px;
|
||||
margin-top: -8px;
|
||||
cursor: pointer;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.float-dialog header .fa:hover {
|
||||
.float-dialog > header .fa:hover {
|
||||
color: #444;
|
||||
}
|
||||
|
||||
.float-dialog section {
|
||||
.float-dialog > section {
|
||||
padding: 20px 30px 15px 30px;
|
||||
}
|
||||
|
||||
.float-dialog footer {
|
||||
.float-dialog > footer {
|
||||
padding: 0 30px 20px 30px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.float-dialog footer button,
|
||||
.float-dialog footer a {
|
||||
.float-dialog > footer button,
|
||||
.float-dialog > footer a {
|
||||
margin-right: 10px;
|
||||
width: 150px;
|
||||
}
|
||||
|
||||
.float-dialog footer button:last-child,
|
||||
.float-dialog footer a:last-child {
|
||||
.float-dialog > footer button:last-child,
|
||||
.float-dialog > footer a:last-child {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
|
@ -193,7 +193,7 @@
|
||||
<span>需要在起售前提醒您吗?</span>
|
||||
</div>
|
||||
<footer>
|
||||
<button class="button-primary button-mini">
|
||||
<button class="button button-primary button-mini">
|
||||
<i class="fa fa-check"></i>
|
||||
开启提醒
|
||||
</button>
|
||||
@ -304,12 +304,19 @@
|
||||
</li>
|
||||
{{~}}
|
||||
</script>
|
||||
<div>
|
||||
<button class="passenger-selector-add">
|
||||
<i class="fa fa-plus"></i> 添加联系人
|
||||
</button>
|
||||
<button class="passenger-selector-refresh">
|
||||
<i class="fa fa-refresh"></i> 刷新列表
|
||||
</button>
|
||||
</div>
|
||||
<ul class="cl"></ul>
|
||||
<div class="passenger-selector-editor">
|
||||
<a href="javascript:;" style="display:none;"><i class="fa fa-plus"></i> 添加</a>
|
||||
<label>
|
||||
<input type="checkbox" data-profile-key="partialSubmitEnabled" value="1" id="" />
|
||||
部分提交
|
||||
部分提交联系人
|
||||
</label>
|
||||
</div>
|
||||
<div class="passenger-pager">
|
||||
@ -931,8 +938,81 @@
|
||||
</section>
|
||||
</article>
|
||||
|
||||
<script src="js/modules/jquery/jquery.js">
|
||||
</script>
|
||||
<div class="modal-dialog">
|
||||
<header><span></span><i class="fa fa-times close"></i></header>
|
||||
<div>
|
||||
</div>
|
||||
<footer></footer>
|
||||
</div>
|
||||
<section id="passenger_editor">
|
||||
<header>
|
||||
基本信息
|
||||
<span>
|
||||
暂不支持学生票。如果联系人信息无法通过<a target="_blank" href="http://www.12306.cn/mormhweb/zxdt/201402/t20140223_1435.html">实名认证</a>,将无法订票。
|
||||
</span>
|
||||
</header>
|
||||
<dl>
|
||||
<dt>姓名:</dt>
|
||||
<dd>
|
||||
<input type="text" class="txt-input" value="" id="" />
|
||||
</dd>
|
||||
<dt>证件类型:</dt>
|
||||
<dd>
|
||||
<select class="normal">
|
||||
<option value="1">
|
||||
二代身份证
|
||||
</option>
|
||||
<option value="C">
|
||||
港澳通行证
|
||||
</option>
|
||||
<option value="G">
|
||||
台湾通行证
|
||||
</option>
|
||||
<option value="B">
|
||||
护照
|
||||
</option>
|
||||
</select>
|
||||
</dd>
|
||||
<dt>证件号码:</dt>
|
||||
<dd>
|
||||
<input type="text" class="txt-input txt-input-block" value="" />
|
||||
</dd>
|
||||
<dt>乘客类型:</dt>
|
||||
<dd>
|
||||
<select class="pastype normal">
|
||||
<option value="1">成人票</option>
|
||||
<option value="2">儿童票</option>
|
||||
<option value="4">残军票</option>
|
||||
</select>
|
||||
</dd>
|
||||
</dl>
|
||||
</section>
|
||||
<section id="selltip_selection">
|
||||
<ul>
|
||||
<li>
|
||||
<label>
|
||||
<input type="checkbox" /> <strong>全部</strong>:<span></span>趟车
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
<label>
|
||||
<input type="checkbox" /> <strong>高铁</strong>:<span></span>趟车,下午2:00起售
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
<label>
|
||||
<input type="checkbox" /> <strong>动车/城铁</strong>:<span></span>趟车,上午11:00起售
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
<label>
|
||||
<input type="checkbox" /> <strong>普通列车(K/T/Z/其它)</strong>:<span></span>趟车, <time></time>起售
|
||||
</label>
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<script src="js/modules/jquery/jquery.js"></script>
|
||||
<script src="js/modules/underscore/underscore.js"></script>
|
||||
<script src="js/modules/doT.js"></script>
|
||||
<script src="js/modules/seajs/sea.js"></script>
|
||||
|
@ -17,26 +17,34 @@
|
||||
|
||||
var SessionMgr = function () {
|
||||
var that = this;
|
||||
var _passengerInLoad = false;
|
||||
var _passengerInLoad = null;
|
||||
|
||||
ev.apply(this, arguments);
|
||||
|
||||
var loadPassengers = function () {
|
||||
if (!that.isLogined)
|
||||
return;
|
||||
var loadPassengers = function (callback) {
|
||||
if (!that.isLogined) {
|
||||
if (callback)
|
||||
callback(null);
|
||||
|
||||
if (_passengerInLoad)
|
||||
return;
|
||||
_passengerInLoad = true;
|
||||
var def = new $.Deferred();
|
||||
def.reject();
|
||||
return def.promise();
|
||||
}
|
||||
|
||||
if (_passengerInLoad) {
|
||||
_passengerInLoad.done(callback);
|
||||
return _passengerInLoad.promise();
|
||||
}
|
||||
_passengerInLoad = new $.Deferred();
|
||||
_passengerInLoad.done(callback);
|
||||
|
||||
ajax.sendPost("confirmPassenger/getPassengerDTOs", "leftTicket/init", null, "json", function () {
|
||||
_passengerInLoad = false;
|
||||
|
||||
var result = this.model;
|
||||
if (!result || !result.data || !result.data.normal_passengers) {
|
||||
passengers = null;
|
||||
that.fireEvent("passengerLoadFailed");
|
||||
that.fireEvent("passengerLoaded", passengers);
|
||||
_passengerInLoad.reject();
|
||||
} else {
|
||||
var p1 = result.data.normal_passengers;
|
||||
passengers = _.filter(p1, parser.canPassageAddToOrder);
|
||||
@ -48,15 +56,30 @@
|
||||
}
|
||||
sessionStorage["_passenger"] = JSON.stringify(passengers);
|
||||
that.fireEvent("passengerLoaded", passengers);
|
||||
_passengerInLoad.resolve(passengers);
|
||||
}
|
||||
_passengerInLoad = null;
|
||||
}, function () {
|
||||
_passengerInLoad = false;
|
||||
passengers = null;
|
||||
_passengerInLoad.reject();
|
||||
sessionStorage.removeItem("_passenger");
|
||||
that.fireEvent("passengerLoadFailed");
|
||||
that.fireEvent("passengerLoaded", passengers);
|
||||
});
|
||||
|
||||
return _passengerInLoad.promise();
|
||||
};
|
||||
that.savePassengers = function() {
|
||||
if (!passengers)
|
||||
return;
|
||||
|
||||
sessionStorage["_passenger"] = JSON.stringify(passengers);
|
||||
};
|
||||
that.reloadPassengers = function() {
|
||||
sessionStorage.removeItem("_passenger");
|
||||
loadPassengers();
|
||||
};
|
||||
|
||||
|
||||
that.checkLoginState = function (callback) {
|
||||
ajax.sendGet("modifyUser/initQueryUserInfo", "", null, "text", function () {
|
||||
@ -132,10 +155,10 @@
|
||||
if (passengers)
|
||||
callback(passengers);
|
||||
else {
|
||||
that.once("passengerLoaded", function () {
|
||||
callback(passengers);
|
||||
});
|
||||
loadPassengers();
|
||||
//that.once("passengerLoaded", function () {
|
||||
// callback(passengers);
|
||||
//});
|
||||
loadPassengers(callback);
|
||||
}
|
||||
};
|
||||
this.ensureLogined = function(callback) {
|
||||
|
@ -10,33 +10,35 @@
|
||||
passenger_id_type_code: idtype,
|
||||
passenger_id_no: id,
|
||||
passenger_type: type,
|
||||
countryCode: countryCode || "CN"
|
||||
country_code: countryCode || "CN"
|
||||
};
|
||||
|
||||
var request = ajax.sendPost("passengers/realAdd", "confirmPassenger/initDc", p);
|
||||
request.done(function () {
|
||||
if (!this.data) {
|
||||
var modal = this.model;
|
||||
if (!modal.data) {
|
||||
def.reject("网络错误");
|
||||
return;
|
||||
}
|
||||
|
||||
var response = this.data;
|
||||
var response = modal.data;
|
||||
|
||||
if (response.flag) {
|
||||
//成功?
|
||||
parser.processPassenger([p]);
|
||||
p.totalTimes = response.totalTimes;
|
||||
p.total_times = response.totalTimes;
|
||||
if (parser.canPassageAddToOrder(p)) {
|
||||
sessMgr.getPassengers(function (plist) {
|
||||
plist.push(p);
|
||||
sessMgr.savePassengers();
|
||||
sessMgr.fireEvent("addPassenger", p);
|
||||
});
|
||||
def.resolve(def);
|
||||
def.resolve(p);
|
||||
} else {
|
||||
def.reject("联系人添加成功,但是未通过校验,无法订票。");
|
||||
def.reject("联系人添加成功,但是未通过12306实名认证,无法订票。");
|
||||
}
|
||||
} else {
|
||||
def.reject((response.message + '') || "网络错误");
|
||||
def.reject((response && response.message) || "网络错误");
|
||||
}
|
||||
}).fail(function () {
|
||||
def.reject(this + '');
|
||||
@ -46,8 +48,6 @@
|
||||
};
|
||||
|
||||
return {
|
||||
fastAddPassenger: function (p) {
|
||||
|
||||
}
|
||||
fastAddPassenger: fastAddPassenger
|
||||
}
|
||||
});
|
||||
|
@ -16,7 +16,7 @@
|
||||
return /^[A-Z]?\d+$/.test(code);
|
||||
};
|
||||
var getHours = function (t1, t2) {
|
||||
var x1 = /^0?(\d+):(\d)+$/.exec(t1) ? parseInt(RegExp.$1) * 60 + parseInt(RegExp.$2) : null;
|
||||
var x1 = /^0?(\d+):(\d+)$/.exec(t1) ? parseInt(RegExp.$1) * 60 + parseInt(RegExp.$2) : null;
|
||||
var x2 = /^0?(\d+):(\d+)$/.exec(t2) ? parseInt(RegExp.$1) * 60 + parseInt(RegExp.$2) : null;
|
||||
|
||||
if (x1 == null || x2 == null)
|
||||
@ -71,9 +71,15 @@
|
||||
return /^(\d+)分钟$/.exec(stop.stopover_time) && parseInt(RegExp.$1) || 0;
|
||||
};
|
||||
var checkSuggestion = function () {
|
||||
var suggestion = [];
|
||||
var requestData = {
|
||||
from: cp.fromCode,
|
||||
to: cp.toCode,
|
||||
date: cp.depDate,
|
||||
stops: trainStops
|
||||
};
|
||||
console.log(JSON.stringify(requestData));
|
||||
|
||||
console.log(JSON.stringify(trainStops));
|
||||
var suggestion = [];
|
||||
|
||||
for (var ts in trainStops) {
|
||||
var tinfo = trainStops[ts].info;
|
||||
|
@ -44,7 +44,7 @@
|
||||
});
|
||||
|
||||
exports.postMessage = function (message) {
|
||||
port.postMessage(message);
|
||||
exports.port.postMessage(message);
|
||||
};
|
||||
|
||||
exports.sendMessage = function (m, response) {
|
||||
|
@ -21,7 +21,7 @@
|
||||
if (p.passenger_id_type_code === "2")
|
||||
return false;
|
||||
|
||||
return p.total_times === "93" || p.total_times === "95" || p.total_times === "97" || p.total_times === "99";
|
||||
return p.total_times == "93" || p.total_times == "95" || p.total_times == "97" || p.total_times == "99";
|
||||
};
|
||||
exports.getAvailableTicketType = function (p, stu) {
|
||||
var a = [];
|
||||
|
@ -10,6 +10,8 @@
|
||||
var utility = require("../utility.js");
|
||||
var port = require("../platform/extensionPort.js");
|
||||
|
||||
require("./widget_modalDialog.js");
|
||||
|
||||
//会话管理器事件
|
||||
sessMgr.on("notValidPassengerFound", function () {
|
||||
mp.showMessagePopup("warn", "您的账户中有未经验证的联系人,将不可为他们订票。");
|
||||
@ -221,5 +223,19 @@
|
||||
|
||||
//统计报告
|
||||
port.track(param.trackTypes.OPEN_PAGE_INDEX);
|
||||
|
||||
//$("#passenger_editor").showModalDialog({
|
||||
// title: "新增联系人",
|
||||
// buttons: [
|
||||
// {
|
||||
// type: "primary",
|
||||
// text: "确定",
|
||||
// callback: function(e) {
|
||||
// alert("ok!");
|
||||
// e.hide();
|
||||
// }
|
||||
// }
|
||||
// ]
|
||||
//});
|
||||
});
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
var query = require("../otn/queryticket.js");
|
||||
var data = require("../data.js");
|
||||
var passenger = require("../otn/passenger.js");
|
||||
require("./widget_modalDialog.js");
|
||||
|
||||
var initPassengerEditor = function () {
|
||||
//UI组件
|
||||
@ -15,22 +16,33 @@
|
||||
var uiList = uiEditor.parent();
|
||||
var uiListTpl = uiList.find(">script").doT();
|
||||
|
||||
uiInput.focus(function () {
|
||||
uiDlg.show();
|
||||
|
||||
var refrshPasList = function () {
|
||||
uiDlg.addClass("loading");
|
||||
uiDlg.find(".empty-indicator").hide();
|
||||
|
||||
sessmgr.getPassengers(function (plist) {
|
||||
uiDlg.removeClass("loading");
|
||||
allpasseengers = plist;
|
||||
currentSearchKey = null;
|
||||
if (!plist.length) {
|
||||
if (!plist || !plist.length) {
|
||||
uiDlgList.empty();
|
||||
uiDlg.find(".empty-indicator").show();
|
||||
}
|
||||
performSearch();
|
||||
});
|
||||
};
|
||||
|
||||
uiInput.focus(function () {
|
||||
uiDlg.show();
|
||||
|
||||
refrshPasList();
|
||||
uiInput.select();
|
||||
|
||||
if (sessmgr.isLogined) {
|
||||
$(".passenger-selector-add, .passenger-selector-refresh").show();
|
||||
} else {
|
||||
$(".passenger-selector-add, .passenger-selector-refresh").hide();
|
||||
}
|
||||
}).blur(function () {
|
||||
uiDlg.hide();
|
||||
});
|
||||
@ -103,22 +115,67 @@
|
||||
uiDlg.find("button.passenger-pager-prev").prop("disabled", currentPageIndex < 2);
|
||||
uiDlg.find("button.passenger-pager-next").prop("disabled", totalpage - 1 < currentPageIndex);
|
||||
};
|
||||
var addPassenger = function (type, name, idtype, id, countryCode) {
|
||||
var showAddPassengerUi = function () {
|
||||
if (!sessmgr.isLogined) {
|
||||
mp.showMessagePopup("error", "您还没有登录哦!");
|
||||
return;
|
||||
}
|
||||
|
||||
var def = passenger.fastAddPassenger.apply(this, [].slice.call(arguments));
|
||||
def.fail(function (msg) {
|
||||
mp.showMessagePopup("error", msg);
|
||||
});
|
||||
def.done(function (p) {
|
||||
if (exports.addPassengerToList(p))
|
||||
mp.showMessagePopup("error", "联系人已经添加成功!");
|
||||
$("#passenger_editor").find(":text").val("");
|
||||
$("#passenger_editor").showModalDialog({
|
||||
title: "新增联系人",
|
||||
buttons: [
|
||||
{
|
||||
text: "确定",
|
||||
callback: function (e) {
|
||||
var inputs = this.find("input, select");
|
||||
var name = inputs.eq(0).val();
|
||||
var idtype = inputs.eq(1).val();
|
||||
var id = inputs.eq(2).val();
|
||||
var type = inputs.eq(3).val();
|
||||
|
||||
if (!name || !id) {
|
||||
mp.showMessagePopup("error", "请输入完整哦!");
|
||||
return;
|
||||
}
|
||||
var tip = new mp.MessagePopup("loading", "正在添加联系人, 请稍等哦亲...");
|
||||
tip.show();
|
||||
|
||||
var def = passenger.fastAddPassenger(type, name, idtype, id, "CN");
|
||||
|
||||
def.fail(function (msg) {
|
||||
tip.setState("error", "失败:" + msg);
|
||||
tip.delayClose();
|
||||
e.hide();
|
||||
});
|
||||
def.done(function (p) {
|
||||
var msg = exports.addPassengerToList(p, true);
|
||||
if (!msg) {
|
||||
tip.setState("ok", "联系人已经添加成功!");
|
||||
} else {
|
||||
tip.setState("error", "联系人添加成功,但是无法添加到列表中:" + msg);
|
||||
}
|
||||
tip.delayClose();
|
||||
e.hide();
|
||||
});
|
||||
|
||||
},
|
||||
icon: "plus",
|
||||
type: "primary"
|
||||
},
|
||||
{
|
||||
text: "取消",
|
||||
cancel: true
|
||||
}
|
||||
]
|
||||
});
|
||||
};
|
||||
|
||||
uiDlg.find("button.passenger-selector-add").click(showAddPassengerUi);
|
||||
uiDlg.find(".passenger-selector-refresh").click(function () {
|
||||
sessmgr.reloadPassengers();
|
||||
|
||||
});
|
||||
uiDlg.find("button.passenger-pager-prev").click(function () {
|
||||
currentPageIndex--;
|
||||
renderPage();
|
||||
@ -180,12 +237,15 @@
|
||||
|
||||
sessmgr.on("sessionChanged", resetList);
|
||||
sessmgr.on("currentProfileChanged", resetList);
|
||||
sessmgr.on("addPassenger", performSearch);
|
||||
sessmgr.on("addPassenger", function () {
|
||||
performSearch();
|
||||
});
|
||||
|
||||
exports.addPassengerToList = function (p) {
|
||||
exports.addPassengerToList = function (p, noui) {
|
||||
var cp = sessmgr.currentProfile;
|
||||
if (!cp)
|
||||
return false;
|
||||
if (!cp) {
|
||||
return noui ? "未登录" : false;
|
||||
}
|
||||
|
||||
cp.passengers = cp.passengers || [];
|
||||
|
||||
@ -193,18 +253,19 @@
|
||||
if (tmpObj) {
|
||||
uiList.find(".optional-block[data-id='" + p.key + "']").remove();
|
||||
_.removeFromArray(cp.passengers, tmpObj);
|
||||
return false;
|
||||
return noui ? "已经从联系人列表中删除" : false;
|
||||
}
|
||||
if (cp.passengers.length >= 5) {
|
||||
mp.showMessagePopup("error", "只能添加五个人喔。");
|
||||
return false;
|
||||
if (!noui)
|
||||
mp.showMessagePopup("error", "只能添加五个人喔。");
|
||||
return noui ? "只能添加五个人喔" : false;
|
||||
}
|
||||
|
||||
cp.passengers.push(p);
|
||||
uiList.append(uiListTpl([p]));
|
||||
sessmgr.save();
|
||||
|
||||
return true;
|
||||
return noui ? null : true;
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -79,11 +79,9 @@
|
||||
ele.attr("data-masked", 1);
|
||||
ele.css("opacity", "0");
|
||||
maskScreen();
|
||||
{
|
||||
ele.show();
|
||||
ele.animate({ opacity: '1', "margin-top": "+=20px" }, 'fast', 'linear', callback);
|
||||
ele.trigger("openDialog");
|
||||
}
|
||||
ele.show();
|
||||
ele.animate({ opacity: '1', "margin-top": "+=20px" }, 'fast', 'linear', callback);
|
||||
ele.trigger("openDialog");
|
||||
};
|
||||
exports.hideFloatDialog = function (ele, callback) {
|
||||
if (!ele.attr("data-masked")) {
|
||||
|
60
Web12306/js/ui/widget_modalDialog.js
Normal file
60
Web12306/js/ui/widget_modalDialog.js
Normal file
@ -0,0 +1,60 @@
|
||||
define(function (require, exports, module) {
|
||||
var modalTemplate = $("div.modal-dialog");
|
||||
var widget = require("./widget.js");
|
||||
|
||||
$.fn.showModalDialog = function (options) {
|
||||
if (!this.length || this.is(":visible"))
|
||||
return this;
|
||||
|
||||
options = $.extend({}, { buttons: [], cancelConfirm: null, title: "我是对话框", showCloseButton: true }, options);
|
||||
|
||||
var template = modalTemplate.clone();
|
||||
$(document.body).append(template);
|
||||
template.find(">div").append(this);
|
||||
template.find(">header>span").html(options.title);
|
||||
if (!options.showCloseButton) {
|
||||
template.find(">header>i").remove();
|
||||
}
|
||||
this.show();
|
||||
|
||||
var hideModalDialog = function (callback) {
|
||||
if (options.cancelConfirm && !options.cancelConfirm())
|
||||
return;
|
||||
|
||||
widget.hideFloatDialog(template, function () {
|
||||
$(document.body).append(template.find(">div").children().hide());
|
||||
template.remove();
|
||||
callback && callback();
|
||||
});
|
||||
};
|
||||
options.hide = hideModalDialog;
|
||||
//处理按钮
|
||||
var buttonContainer = template.find(">footer");
|
||||
$.each(options.buttons, function () {
|
||||
var btn = $("<button type='button' class='button button-" + (this.type || "default") + "'></button>");
|
||||
buttonContainer.append(btn);
|
||||
btn.text(this.text || "按钮");
|
||||
if (this.icon) {
|
||||
btn.prepend("<i class='fa fa-" + this.icons + "' />");
|
||||
}
|
||||
if (this.callback) {
|
||||
btn.click(function () {
|
||||
this.apply(template, [options]);
|
||||
}.bind(this.callback));
|
||||
}
|
||||
if (this.cancel) {
|
||||
btn.click(function () {
|
||||
hideModalDialog();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
template.find(".close").click(function () {
|
||||
widget.hideFloatDialog(template);
|
||||
});
|
||||
|
||||
widget.showFloatDialog(template);
|
||||
|
||||
return this;
|
||||
};
|
||||
});
|
@ -6,7 +6,12 @@
|
||||
var utility = require("../utility.js");
|
||||
var stationData = require("../station/station_data.js");
|
||||
var lastCheckKey = null;
|
||||
|
||||
var mp = require("./widget_message_popup.js");
|
||||
var query = require("../otn/queryticket.js");
|
||||
var port = require("../platform/extensionPort.js");
|
||||
|
||||
require("./widget_modalDialog.js");
|
||||
|
||||
var checkTime = function () {
|
||||
cp = sessMgr.currentProfile;
|
||||
if (!cp) {
|
||||
@ -41,17 +46,170 @@
|
||||
times.filter(":eq(2)").html(utility.formatDate(bs, "yyyy年MM月dd日") + utility.format24hTo12h(sellTimes));
|
||||
container.find("address").html(cp.fromText + "站");
|
||||
|
||||
container[0].dataset.sellday = bs.getTime();
|
||||
container[0].dataset.timeset = sellTimes;
|
||||
|
||||
container.show();
|
||||
};
|
||||
var init = function() {
|
||||
sessMgr.on("save", function() {
|
||||
var initShowAlarmUi = function () {
|
||||
if (!sessMgr.currentProfile.fromCode || !sessMgr.currentProfile.toCode || !sessMgr.currentProfile.depDate) {
|
||||
mp.showMessagePopup("error", "亲,还没有设置查询的条件哦。");
|
||||
return;
|
||||
}
|
||||
|
||||
var tip = new mp.MessagePopup("loading", "正在查询中,请稍等...");
|
||||
tip.show();
|
||||
query.queryTicket(sessMgr.currentProfile.fromCode, sessMgr.currentProfile.toCode, utility.formatDate(data.maxDate, 'yyyy-MM-dd'), sessMgr.currentProfile.studentTicket, true)
|
||||
.done(function () {
|
||||
tip.setState("ok", "查询成功!");
|
||||
tip.close();
|
||||
|
||||
showAlarmSetUi(this);
|
||||
}).fail(function () {
|
||||
tip.setState("error", "查询失败,请重试");
|
||||
});
|
||||
};
|
||||
var parseSellTime = function (point) {
|
||||
point = point.split('|')[0];
|
||||
var args = /0?(\d+):0?(\d+)/.exec(point);
|
||||
|
||||
return parseInt(args[2]) * 60 * 1000 + parseInt(args[1]) * 3600 * 1000;
|
||||
};
|
||||
var confirmAlarm = function () {
|
||||
var baseTime = new Date(parseInt(container[0].dataset.sellday));
|
||||
var sellTime = parseSellTime(container[0].dataset.timeset);
|
||||
|
||||
baseTime = utility.addDays(utility.trimToDay(new Date()), 1);
|
||||
|
||||
var tasks = [];
|
||||
var p = sessMgr.currentProfile;
|
||||
var taskGroup = utility.formatDate(p.depDate, 'MM月dd日') + p.fromText + "到" + p.toText + "起售提醒";
|
||||
var taskdata = {
|
||||
fromText: p.fromText,
|
||||
fromCode: p.fromCode,
|
||||
toCode: p.toCode,
|
||||
toText: p.toText,
|
||||
date: p.depDate
|
||||
};
|
||||
//当天
|
||||
tasks.push(
|
||||
{
|
||||
time: baseTime.getTime(),
|
||||
text: "今天起售" + utility.formatDate(p.depDate, 'MM月dd日') + p.fromText + "到" + p.toText + "车票 ,请留意哦!",
|
||||
group: taskGroup,
|
||||
data: taskdata
|
||||
}
|
||||
);
|
||||
var assignTimeGroup = function (timepoint, grouptype) {
|
||||
//提前三十分钟提示一次
|
||||
tasks.push(
|
||||
{
|
||||
time: timepoint - 30 * 60 * 1000,
|
||||
text: "三十分钟后起售" + utility.formatDate(p.depDate, 'MM月dd日') + p.fromText + "到" + p.toText + "的" + grouptype + "车票 ,请留意哦!",
|
||||
group: taskGroup,
|
||||
data: taskdata
|
||||
}
|
||||
);
|
||||
|
||||
//提示十五分钟提示一次
|
||||
tasks.push(
|
||||
{
|
||||
time: timepoint - 15 * 60 * 1000,
|
||||
text: "十五分钟后起售" + utility.formatDate(p.depDate, 'MM月dd日') + p.fromText + "到" + p.toText + "的" + grouptype + "车票 ,请留意哦!",
|
||||
group: taskGroup,
|
||||
data: taskdata
|
||||
}
|
||||
);
|
||||
|
||||
//提示五分钟提示一次
|
||||
tasks.push(
|
||||
{
|
||||
time: timepoint - 5 * 60 * 1000,
|
||||
text: "五分钟后起售" + utility.formatDate(p.depDate, 'MM月dd日') + p.fromText + "到" + p.toText + "的" + grouptype + "车票 ,请留意哦!",
|
||||
group: taskGroup,
|
||||
data: taskdata
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if ($("#selltip_selection :checkbox:eq(2)").is(":checked:visible")) {
|
||||
//动车
|
||||
assignTimeGroup(baseTime.getTime() + 11 * 60 * 60 * 1000, "动车/城铁");
|
||||
}
|
||||
if ($("#selltip_selection :checkbox:eq(1)").is(":checked:visible")) {
|
||||
//高铁
|
||||
assignTimeGroup(baseTime.getTime() + 11 * 60 * 60 * 1000, "高铁");
|
||||
}
|
||||
if ($("#selltip_selection :checkbox:eq(3)").is(":checked:visible")) {
|
||||
//普通车次
|
||||
assignTimeGroup(baseTime.getTime() + sellTime, "普通车次");
|
||||
}
|
||||
|
||||
|
||||
port.sendMessage({ action: "setAlarmTask", detail: tasks });
|
||||
return true;
|
||||
};
|
||||
var showAlarmSetUi = function (result) {
|
||||
var hasDc = 0, hasG = 0, hasC = 0, total = 0;
|
||||
_.each(result.original, function (t) {
|
||||
if (t.code[0] === 'D' || t.code[0] === 'C')
|
||||
hasDc++;
|
||||
else if (t.code[0] === 'G')
|
||||
hasG++;
|
||||
else hasC++;
|
||||
total++;
|
||||
});
|
||||
|
||||
var p = sessMgr.currentProfile;
|
||||
var date = new Date(parseInt(container[0].dataset.sellday));
|
||||
var dlg = $("#selltip_selection");
|
||||
dlg.find("span:eq(0)").html(total);
|
||||
dlg.find("span:eq(1)").html(hasG);
|
||||
dlg.find("span:eq(2)").html(hasDc);
|
||||
dlg.find("span:eq(3)").html(hasC);
|
||||
dlg.find("time").html(utility.format24hTo12h(container[0].dataset.timeset));
|
||||
|
||||
if (!hasG)
|
||||
dlg.find("li:eq(1)").hide();
|
||||
if (!hasDc)
|
||||
dlg.find("li:eq(2)").hide();
|
||||
if (!hasC)
|
||||
dlg.find("li:eq(3)").hide();
|
||||
dlg.find(":checkbox").prop("checked", true);
|
||||
dlg.showModalDialog({
|
||||
title: utility.formatDate(p.depDate, 'MM月dd日') + p.fromText + "到" + p.toText + "车票 " + utility.formatDate(date, 'MM月dd日') + "起售",
|
||||
buttons: [
|
||||
{
|
||||
text: "订阅提醒",
|
||||
callback: function (e) {
|
||||
if (confirmAlarm()) {
|
||||
mp.showMessagePopup("ok", "提醒设置成功!");
|
||||
e.hide();
|
||||
}
|
||||
},
|
||||
type: "primary"
|
||||
}
|
||||
]
|
||||
});
|
||||
};
|
||||
var init = function () {
|
||||
sessMgr.on("save", function () {
|
||||
checkTime();
|
||||
});
|
||||
if (cp)
|
||||
checkTime();
|
||||
container.find(">header>a").click(function() {
|
||||
container.find(">header>a").click(function () {
|
||||
container.hide();
|
||||
});
|
||||
container.find(".button-primary").click(function () {
|
||||
initShowAlarmUi();
|
||||
});
|
||||
$("#selltip_selection :checkbox:eq(0)").change(function () {
|
||||
$("#selltip_selection :checkbox:gt(0)").prop("checked", this.checked);
|
||||
});
|
||||
$("#selltip_selection :checkbox:gt(0)").change(function () {
|
||||
$("#selltip_selection :checkbox:eq(0)").prop("checked", !$("#selltip_selection li:visible :checkbox:gt(0):not(:checked)").length);
|
||||
});
|
||||
};
|
||||
init();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user