61 lines
1.5 KiB
JavaScript
61 lines
1.5 KiB
JavaScript
define(function (require, exports, module) {
|
|
var sessMgr = require("../account/sessionMgr.js");
|
|
var data = require("../data.js");
|
|
var cp = sessMgr.currentProfile;
|
|
var container = $("#book_sell_tip");
|
|
var utility = require("../utility.js");
|
|
var stationData = require("../station/station_data.js");
|
|
var lastCheckKey = null;
|
|
|
|
var checkTime = function () {
|
|
cp = sessMgr.currentProfile;
|
|
if (!cp) {
|
|
container.hide();
|
|
return;
|
|
}
|
|
|
|
var time = cp.depDate;
|
|
var code = cp.fromCode;
|
|
if (!time || !code) {
|
|
container.hide();
|
|
return;
|
|
}
|
|
if (lastCheckKey === time + code)
|
|
return;
|
|
|
|
container.hide();
|
|
lastCheckKey = time + code;
|
|
|
|
var days = utility.getDaysDifference(new Date(), time);
|
|
if (days <= data.maxSellDays)
|
|
return; //预售期内
|
|
if (cp.studentTicket && data.isStudentTicketEnabled(time))
|
|
return; //学生票
|
|
|
|
//起售期
|
|
var bs = utility.addDays(time, -data.maxSellDays);
|
|
var sellTimes = stationData.sellTime[code] || "----";
|
|
|
|
var times = container.find("time");
|
|
times.filter(":lt(2)").html(utility.formatDate(time, "yyyy年MM月dd日"));
|
|
times.filter(":eq(2)").html(utility.formatDate(bs, "yyyy年MM月dd日") + utility.format24hTo12h(sellTimes));
|
|
container.find("address").html(cp.fromText + "站");
|
|
|
|
container.show();
|
|
};
|
|
|
|
return {
|
|
init: function () {
|
|
sessMgr.on("save", function () {
|
|
checkTime();
|
|
});
|
|
if (cp)
|
|
checkTime();
|
|
container.find(">header>a").click(function() {
|
|
container.hide();
|
|
});
|
|
},
|
|
check: checkTime
|
|
};
|
|
});
|