diff --git a/Web12306/js/ui/ui-oncetrainsitquery.js b/Web12306/js/ui/ui-oncetrainsitquery.js index 6ad8d81..7db00ce 100644 --- a/Web12306/js/ui/ui-oncetrainsitquery.js +++ b/Web12306/js/ui/ui-oncetrainsitquery.js @@ -211,7 +211,6 @@ loadTime = 1000; queuedcount = queryKeyQueue.length; startQueryTimer(); - }; var getCalcBasedTime = function () { @@ -306,15 +305,15 @@ var date = trains[0].queryData[4]; var from = trains[0].from; var to = trains[0].to; - var trainCodes = _.groupBy(trains, function (x) { - return x.train.code; + var trainIds = _.groupBy(trains, function (x) { + return x.train.id; }); var processResponse = function (loaded, result) { queryLoopTimer = null; - _.each(_.keys(trainCodes), function (code) { - var ele = listTarget.find("tr.ticket-container td[data-date='" + date + "'][data-traincode='" + code + "'][data-fromcode='" + from + "'][data-tocode='" + to + "']"); + _.each(_.keys(trainIds), function (tid) { + var ele = listTarget.find("tr.ticket-container td[data-date='" + date + "'][data-trainid='" + tid + "'][data-fromcode='" + from + "'][data-tocode='" + to + "']"); ele.empty(); if (!loaded) { ele.append("未能查询余票信息,等待重新查询"); @@ -326,21 +325,21 @@ ele.append("" + utility.format + ""); } else { //显示余票信息 - var train = _.findWhere(result.original, { code: code }); + var train = _.findWhere(result.original, { id: tid }); if (!train) { //车次不存在,可能是过程中会自动变号的车次 ele.closest("tr").prevUntil(".header, .ticket-container").andSelf().remove(); //从列表中移除 - var args = _.clone(trainCodes[code]); + var args = _.clone(trainIds[tid]); args.unshift(trains); queryQueue[key] = _.without.apply(this, args); //从缓存的信息中移除。 var matchedLines = _.filter(currentTransit.lines, function (line) { - return _.some(trainCodes[code], function (t) { return t === line.first || t === line.second; }); + return _.some(trainIds[tid], function (t) { return t === line.first || t === line.second; }); }); - delete trainCodes[code]; + delete trainIds[tid]; if (matchedLines && matchedLines.length) { matchedLines.unshift(currentTransit.lines); currentTransit.lines = _.without.apply(this, matchedLines); @@ -351,7 +350,7 @@ } else if (train.limitSellInfo) { //限售信息 ele.append("" + train.limitSellInfo + ""); - delete trainCodes[code]; + delete trainIds[tid]; ele.attr("data-available", 1); } else if (train.selltime) { ele.append("" + utility.formatSellDate(train.selltime) + "起售"); @@ -360,7 +359,7 @@ ele.append("本车次暂无可售票"); ele.attr("data-available", 0); } else { - _.each(trainCodes[code], function (t) { + _.each(trainIds[tid], function (t) { t.secureStr = train.secureStr; t.rtrain = train; }); @@ -374,7 +373,7 @@ var selected = cp && $.inArray(seat, cp.selectedSeatType) !== -1; hasSelected |= selected; - tickets.push("" + seatinfo.name + " " + seatinfo.count + "张 " + (seatinfo.price > 0 ? "¥" + (seatinfo.price / 10) : "") + ""); + tickets.push("" + seatinfo.name + " " + seatinfo.count + "张 " + (seatinfo.price > 0 ? "¥" + (seatinfo.price / 10) : "") + ""); }); ele.append(tickets.join("")); ele.attr("data-available", hasSelected ? 3 : 2); @@ -382,7 +381,7 @@ } }); - if (result.notInSellTime || !_.keys(trainCodes).length && queryQueue[key]) { + if (result.notInSellTime || !_.keys(trainIds).length && queryQueue[key]) { //从列表中移除,这个车次之后不用再查了。 delete queryQueue[key]; queryKeyQueue.pop();