define(function (require, exports, module) { var citydata = require("./station/station_data.js"); var utility = require("./utility.js"); exports.sysNoticeUrl = "/systemNotice.json"; exports.sysNoticeLoadInterval = 30 * 60 * 1800; exports.sysNoticeMaxShowCount = 3; exports.citydata = citydata; exports.cities = _(_.flatten(_.map(_.values(citydata.data), function (e) { return _.values(e); }))).mapObject(function (e) { return e.c; });; exports.citynameMap = _.mapObject(exports.cities, function (c) { return c.n; }); exports.identityCardTypes = { }; exports.passengerTypes = { "1": "成人", "2": "儿童", "3": "学生", "4": "残军" }; exports.tagOtnMap = { "9": "SWZ", "P": "TZ", "M": "ZY", "O": "ZE", "6": "GR", "4": "RW", "3": "YW", "2": "RZ", "1": "YZ", "0": "WZ", "*": "QT", "B": "HB" }; exports.tagRevMap = _.invert(exports.tagOtnMap); exports.seatNameMap = { "商务座": "SWZ", "特等座": "TZ", "一等座": "ZY", "二等座": "ZE", "高级软卧": "GR", "软卧": "RW", "硬卧": "YW", "软座": "RZ", "硬座": "YZ", "无座": "WZ", "混编硬座": "HB" }; exports.tagMap = { "动车或高铁或城铁": "[DGC].*", "特快或直达": "[TZ].*", "快车": "K.*", "高铁": "G.*", "动车": "D.*", "城铁": "C.*", "直达": "Z.*", "特快": "T.*", "任意车次": ".*" }; exports.translateTrain = function (array) { /// 将列车编号翻译为实际的检查序列 return array.map(function (e) { return exports.tagMap[e] || e; }); }; exports.seatNameInvMap = _.invert(exports.seatNameMap); exports.baseUri = "https://kyfw.12306.cn/otn/"; exports.queryBaseUri = "https://dynamic.12306.cn/otsquery/"; exports.toSeatTypeName = function (code) { return exports.seatNameInvMap[exports.tagOtnMap[code]]; }; exports.seatDisplayOrder = 'O219PM6430'.split(''); exports.isDebug = ((function () { return false; }) + '').indexOf("false;") != -1; exports.log = function () { if (!exports.isDebug) return; console.log.apply(console, Array.prototype.slice.call(arguments)); }; exports.showMoreOptRange = [ [new Date(2014, 9, 5), new Date(2014, 9, 20)], [new Date(2015, 1, 20), new Date(2014, 2, 18)] ]; exports.startTrainStationSuggestQueryLimit = 10; exports.maxSuggestStationTimeRange = { "": 300, "G": 180, "D": 180 } exports.maxSellDays = 19; exports.minDate = utility.trimToDay(new Date()); exports.maxDate = utility.addDays(exports.minDate, exports.maxSellDays); exports.isStudentTicketEnabled = function (date) { /// 判断指定的日期学生票是否可以买 date = utility.toDate(date); var tag = (date.getMonth() + 1) * 10 + date.getDate(); return _.any(exports.stuDate, function (e) { return tag >= e[0] && tag <= e[1]; }); }; exports.stuDate = [ [101, 331], [601, 930], [1201, 1231] ]; exports.isValidDate = function (date) { date = utility.trimToDay(date); return date >= exports.minDate; }; exports.isAutoBookEnabled = function (profile) { return profile.selectedTrain && profile.selectedTrain.length && profile.selectedSeatType && profile.selectedSeatType.length; }; //查找默认的日期 (function () { var d = exports.minDate; var day = d.getDay(); if (day < 5) { //星期1-5,则取星期五 exports.defaultDate = utility.addDays(d, 5 - day); } else if (day > 0) { //取周日 exports.defaultDate = utility.addDays(d, 7 - day); } })(); exports.trackTypes = { OPEN_PAGE_INDEX: 100, LOGIN: 101, QUERY_TICKET: 102, QUERY_SUGGESTION: 103, SELLTIME_SUGGEST: 104, SUBMIT_ORDER: 105, SUBMIT_ORDER_FAILED: 106, SUBMIT_ORDER_SUCCESS: 107, LOGOUT: 108, SHOW_TRAIN_STOP: 109, SUBMIT_AUTO: 110, START_AUTOREFRESH: 111, STOP_AUTOREFRESH: 112, VALID_AUTOREFRESH: 113, JOIN_CHAT: 114, EXIT_CHAT: 115 }; exports.chatSendMsgDelay = 5000; Object.defineProperty(exports, "moreOptDefault", { get: function () { var d = exports.minDate; return _.any(exports.showMoreOptRange, function (v) { return v[0] <= d && d <= v[1]; }); } }); });