BUG修正。
This commit is contained in:
parent
c1eef404d9
commit
1c21bf6592
@ -106,19 +106,19 @@
|
||||
callback({ logined: false });
|
||||
});
|
||||
};
|
||||
that.loadProfile = function (username, checkData) {
|
||||
that.loadProfile = function (dispname, checkData, username) {
|
||||
//备份当前的查询,并取代为默认的查询
|
||||
var cp = that.currentProfile;
|
||||
if (cp) {
|
||||
cp.passengers = null; //不保留乘客
|
||||
}
|
||||
if (cp && (!cp.fromText || !cp.toText || !cp.depDate))
|
||||
cp = null;
|
||||
|
||||
var profile = storage.obj("12306_user_" + username) || { hasNotVerifyedPassenger: false, username: username, passengers: [], savedProfile: { list: [] }, currentProfile: {}, rawPassenger: [], options: { soundPrompt: true } };
|
||||
var profile = storage.obj("12306_user_" + dispname) || { hasNotVerifyedPassenger: false, dispname: dispname, passengers: [], savedProfile: { list: [] }, currentProfile: {}, rawPassenger: [], options: { soundPrompt: true } };
|
||||
profile.currentProfile = $.extend({}, that.defaultProfile, profile.currentProfile, cp);
|
||||
if (!profile.currentProfile.autoRefreshDelay)
|
||||
profile.currentProfile.autoRefreshDelay = 5;
|
||||
if (username)
|
||||
profile.username = username;
|
||||
//有预置参数?加载
|
||||
if (location.hash && location.hash.indexOf("#ALARM-") === 0) {
|
||||
try {
|
||||
@ -128,26 +128,34 @@
|
||||
console.log("unable to restore parameter: " + e);
|
||||
}
|
||||
}
|
||||
that.current = profile;
|
||||
that.save();
|
||||
|
||||
if (username) {
|
||||
if (dispname) {
|
||||
if (checkData) {
|
||||
that.current.dispname = checkData.realName;
|
||||
that.current.username = checkData.username;
|
||||
that.fireEvent("userInfoUpdated");
|
||||
|
||||
if (!checkData.isChecked)
|
||||
that.fireEvent("userNotChecked");
|
||||
} else {
|
||||
that.checkLoginState(function (data) {
|
||||
that.current.dispname = data.realName;
|
||||
that.fireEvent("userInfoUpdated");
|
||||
if (!data.logined) {
|
||||
//被强退了
|
||||
that.loadProfile("");
|
||||
that.fireEvent("loginInvalid");
|
||||
} else {
|
||||
that.current.dispname = data.realName;
|
||||
that.current.username = data.username;
|
||||
that.fireEvent("userInfoUpdated");
|
||||
|
||||
if (!data.isChecked)
|
||||
that.fireEvent("userNotChecked");
|
||||
if (!data.isChecked)
|
||||
that.fireEvent("userNotChecked");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
that.current = profile;
|
||||
that.save();
|
||||
};
|
||||
that.resetProfile = function () {
|
||||
sessionStorage.removeItem("_currentuser");
|
||||
@ -158,7 +166,7 @@
|
||||
if (!that.current)
|
||||
return;
|
||||
|
||||
var key = "12306_user_" + that.current.username;
|
||||
var key = "12306_user_" + that.current.dispname;
|
||||
storage.put(key, that.current);
|
||||
that.fireEvent("save");
|
||||
};
|
||||
@ -216,6 +224,7 @@
|
||||
if (v) {
|
||||
if (v.username !== currentuser) {
|
||||
sessionStorage["_currentuser"] = v.username;
|
||||
sessionStorage["_currentuserName"] = v.dispname;
|
||||
sessionStorage.removeItem("_passenger");
|
||||
passengers = null;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
define(function (require, exports, module) {
|
||||
var ajax = require("../platform/webRequest.js");
|
||||
var parser = require("../platform/parser.js");
|
||||
var vc = require("./vc.js");
|
||||
|
||||
var submitToken;
|
||||
var formData;
|
||||
@ -150,6 +151,16 @@
|
||||
pas1 = pas1.join("_");
|
||||
pas2 = pas2.join("_") + "_";
|
||||
|
||||
var checkVc = function () {
|
||||
def.notify({ msg: "正在检查验证码..." });
|
||||
|
||||
var xdef = vc.checkLoginVc(randcode);
|
||||
xdef.done(function () {
|
||||
submitOrder();
|
||||
}).fail(function (msg) {
|
||||
def.reject({ msg: msg });
|
||||
});
|
||||
};
|
||||
|
||||
var submitOrder = function () {
|
||||
def.notify({ msg: "正在提交订单..." });
|
||||
@ -220,7 +231,7 @@
|
||||
|
||||
sendRequest();
|
||||
};
|
||||
submitOrder();
|
||||
checkVc();
|
||||
|
||||
return def.promise();
|
||||
};
|
||||
|
@ -61,6 +61,9 @@
|
||||
data: entry
|
||||
};
|
||||
data.auto.passengers.forEach(function (p) { p.seat = data.auto.seat; });
|
||||
if (currentProfile.submitStuAsCommon && !currentProfile.studentTicket) {
|
||||
data.auto.passengers.forEach(function (p) { if (p.passenger_type == "3") p.passenger_type = "1"; });
|
||||
}
|
||||
} else {
|
||||
data.auto = null;
|
||||
}
|
||||
|
@ -136,9 +136,10 @@
|
||||
//TODO 没有保存密码的选项!
|
||||
storage.put("12306_lastUser", {
|
||||
name: un,
|
||||
pwd: pwd
|
||||
pwd: pwd,
|
||||
rname: realName
|
||||
});
|
||||
sessionMgr.loadProfile(un);
|
||||
sessionMgr.loadProfile(realName, null, un);
|
||||
that.dispatchEvent("loginSuccess");
|
||||
that.closeLoginDialog();
|
||||
|
||||
|
@ -146,6 +146,7 @@
|
||||
var id = this.dataset.traincode;
|
||||
var seatcode = this.dataset.seatcode;
|
||||
var train;
|
||||
var cp = sessMgr.currentProfile;
|
||||
|
||||
if (this.dataset.suggest) {
|
||||
train = trainSuggest.findTrain(this.dataset.sec);
|
||||
@ -158,11 +159,14 @@
|
||||
return;
|
||||
|
||||
var ticketCount = _.findWhere(train.tickets, { code: seatcode }).count;
|
||||
var pcount = Math.min(ticketCount, sessMgr.currentProfile.passengers ? sessMgr.currentProfile.passengers.length : 0);
|
||||
var pas = _.first(sessMgr.currentProfile.passengers || [], pcount);
|
||||
var pcount = Math.min(ticketCount, cp.passengers ? cp.passengers.length : 0);
|
||||
var pas = _.first(cp.passengers || [], pcount);
|
||||
seatcode = seatcode === "0" ? (train.ticketMap['1'] ? "1" : "O") : seatcode;
|
||||
|
||||
pas.forEach(function (p) { p.seat = seatcode; });
|
||||
if (cp.submitStuAsCommon && !cp.studentTicket) {
|
||||
pas.forEach(function (p) { if (p.passenger_type == "3") p.passenger_type = "1"; });
|
||||
}
|
||||
|
||||
__.dispatchEvent("requireSubmitOrder", {
|
||||
train: train,
|
||||
|
Loading…
Reference in New Issue
Block a user