2014-06-12 21:36:05 +08:00
|
|
|
|
define(function (require, exports) {
|
|
|
|
|
|
|
|
|
|
exports.getError = function (data) {
|
|
|
|
|
/// <summary>获得指定返回数据中的错误信息</summary>
|
|
|
|
|
|
|
|
|
|
if (data.messages && data.messages instanceof Array) {
|
|
|
|
|
return { message: data.messages.join(";") };
|
|
|
|
|
}
|
|
|
|
|
if (data.data && data.data.isRelogin) {
|
|
|
|
|
return { message: "登录状态异常,请重新登录。", relogin: true };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return { message: "未知错误信息" };
|
|
|
|
|
};
|
2014-06-20 20:55:14 +08:00
|
|
|
|
exports.formatDate = function (date, format) {
|
|
|
|
|
/// <summary>格式化指定日期</summary>
|
|
|
|
|
/// <param name="format" type="String">格式化字符串</param>
|
|
|
|
|
format = format || "yyyy-MM-dd";
|
|
|
|
|
var o = {
|
|
|
|
|
"M+": date.getMonth() + 1, //month
|
|
|
|
|
"d+": date.getDate(), //day
|
|
|
|
|
"h+": date.getHours(), //hour
|
|
|
|
|
"m+": date.getMinutes(), //minute
|
|
|
|
|
"s+": date.getSeconds(), //second
|
|
|
|
|
"q+": Math.floor((date.getMonth() + 3) / 3), //quarter
|
|
|
|
|
"S": date.getMilliseconds() //millisecond
|
|
|
|
|
};
|
2014-06-12 21:36:05 +08:00
|
|
|
|
|
2014-06-20 20:55:14 +08:00
|
|
|
|
if (/(y+)/i.test(format)) {
|
|
|
|
|
format = format.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
|
|
|
|
|
}
|
2014-06-12 21:36:05 +08:00
|
|
|
|
|
2014-06-20 20:55:14 +08:00
|
|
|
|
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));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return format;
|
|
|
|
|
};
|
2014-06-26 22:24:54 +08:00
|
|
|
|
|
|
|
|
|
exports.canPassageAddToOrder = function (p) {
|
|
|
|
|
if (p.passenger_id_type_code === "C" || p.passenger_id_type_code === "G" || p.passenger_id_type_code === "B")
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
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";
|
|
|
|
|
};
|
|
|
|
|
exports.getAvailableTicketType = function (p, stu) {
|
|
|
|
|
var a = [];
|
|
|
|
|
var pt = p.passenger_type;
|
|
|
|
|
|
|
|
|
|
if (pt === "3" && stu) {
|
|
|
|
|
a.push({ id: 3, name: "学生票" });
|
|
|
|
|
} else {
|
|
|
|
|
a.push({ id: 1, name: "成人票" });
|
|
|
|
|
a.push({ id: 2, name: "儿童票" });
|
|
|
|
|
}
|
|
|
|
|
if (pt === "4") {
|
|
|
|
|
a.push({ id: 4, name: "残军票" });
|
|
|
|
|
}
|
|
|
|
|
return a;
|
|
|
|
|
};
|
|
|
|
|
exports.processPassenger = function(list) {
|
|
|
|
|
list.forEach(function(e) {
|
|
|
|
|
e.key = e.passenger_type + "$" + e.passenger_name + "$" + e.passenger_id_type_code + "$" + e.passenger_id_no;
|
|
|
|
|
});
|
|
|
|
|
};
|
2014-06-12 21:36:05 +08:00
|
|
|
|
});
|