同步提交
This commit is contained in:
parent
3941afa58a
commit
1e5c679a48
@ -175,6 +175,8 @@
|
||||
<Content Include="css\fa\fonts\FontAwesome.otf" />
|
||||
<None Include="js\docs\chrome-api-vsdoc.js" />
|
||||
<Content Include="js\data.js" />
|
||||
<Content Include="js\modules\doT.js" />
|
||||
<Content Include="js\otn\queryticket.js" />
|
||||
<Content Include="js\platform\EventObject.js" />
|
||||
<Content Include="js\platform\extensionPort.js" />
|
||||
<Content Include="js\platform\parser.js" />
|
||||
@ -204,7 +206,6 @@
|
||||
<ItemGroup>
|
||||
<Folder Include="App_Data\" />
|
||||
<Folder Include="js\order\" />
|
||||
<Folder Include="js\query\" />
|
||||
<Folder Include="js\vc\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -8,8 +8,7 @@
|
||||
display: none;
|
||||
}
|
||||
|
||||
#city_selector.open,
|
||||
#city_selector:hover {
|
||||
#city_selector.open {
|
||||
display: block;
|
||||
}
|
||||
|
||||
|
@ -1,124 +1,124 @@
|
||||
/*搜索结果*/
|
||||
.result {
|
||||
margin-bottom: 55px;
|
||||
background: #fffefa;
|
||||
border-top: 1px solid #c6701a;
|
||||
}
|
||||
|
||||
.result table {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
color: #444444;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.result table thead {
|
||||
background: #f5f5f5;
|
||||
color: #777777;
|
||||
line-height: 30px;
|
||||
font-size: 14px;
|
||||
border-left: 1px solid #dcdcdc;
|
||||
border-right: 1px solid #dcdcdc;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.result table thead tr th:nth-child(1) {
|
||||
padding-left: 40px;
|
||||
}
|
||||
|
||||
.result table thead tr th:nth-child(2) {
|
||||
padding-left: 38px;
|
||||
}
|
||||
|
||||
.result table thead tr th:nth-child(4) {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.result .train-num {
|
||||
padding: 18px 4px 18px 40px;
|
||||
font-family: tahoma;
|
||||
color: #4D5873;
|
||||
font-size: 24px;
|
||||
text-align: left;
|
||||
line-height: 19px;
|
||||
border: 1px solid #dcdcdc;
|
||||
border-right: 1px solid #ccc7ba;
|
||||
background: #fff9e8;
|
||||
}
|
||||
|
||||
.result .train-seats {
|
||||
padding: 20px 0;
|
||||
border: 1px solid #cccccc;
|
||||
border-left: none;
|
||||
line-height: 18px;
|
||||
}
|
||||
|
||||
.result .train-seats .row2 {
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.result .train-info {
|
||||
width: 120px;
|
||||
padding: 0 45px 0 38px;
|
||||
border-top: 1px solid #cccccc;
|
||||
border-bottom: 1px solid #cccccc;
|
||||
}
|
||||
|
||||
.result .train-city {
|
||||
width: 110px;
|
||||
border-top: 1px solid #cccccc;
|
||||
border-bottom: 1px solid #cccccc;
|
||||
padding: 0 60px 0 5px;
|
||||
}
|
||||
|
||||
.result .ticket-block {
|
||||
display: inline-block;
|
||||
border: 1px solid rgba(0, 0, 0, 0.2);
|
||||
background: linear-gradient(to bottom, #ffffff, #ffffff 5%, #f5f5f5);
|
||||
border-radius: 4px;
|
||||
padding: 11px 16px;
|
||||
color: #4e4e4e;
|
||||
box-shadow: 0 1px 8px rgba(155, 155, 155, 0.2);
|
||||
}
|
||||
|
||||
.result .ticket-block-selected {
|
||||
border-color: #e3c69b;
|
||||
background: linear-gradient(to bottom, #ffffff, #ffffff 5%, #fcf6e1 );
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.result .ticket-block:hover {
|
||||
border-color: #dec496;
|
||||
background: linear-gradient(to bottom, #ffffff, #ffffff 5%, #fcf6e1);
|
||||
}
|
||||
|
||||
.result .ticket-num {
|
||||
color: #e00000;
|
||||
}
|
||||
|
||||
.result .train-station-type {
|
||||
font-size: 12px;
|
||||
margin-top: 5px;
|
||||
color: #888;
|
||||
}
|
||||
|
||||
.result .train-station-type:after {
|
||||
content: '';
|
||||
border-top: 5px solid #888;
|
||||
border-left: 5px solid transparent;
|
||||
border-right: 5px solid transparent;
|
||||
top: 13px;
|
||||
position: relative;
|
||||
left: 2px;
|
||||
}
|
||||
|
||||
/*始发终到标记*/
|
||||
.result .train-city .start:after {
|
||||
content: ' [始]';
|
||||
color: #c23825;
|
||||
}
|
||||
|
||||
.result .train-city .end:after {
|
||||
content: ' [终]';
|
||||
color: #c23825;
|
||||
}
|
||||
/*搜索结果*/
|
||||
.result {
|
||||
margin-bottom: 55px;
|
||||
background: #fffefa;
|
||||
border-top: 1px solid #c6701a;
|
||||
}
|
||||
|
||||
.result table {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
color: #444444;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.result table thead {
|
||||
background: #f5f5f5;
|
||||
color: #777777;
|
||||
line-height: 30px;
|
||||
font-size: 14px;
|
||||
border-left: 1px solid #dcdcdc;
|
||||
border-right: 1px solid #dcdcdc;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.result table thead tr th:nth-child(1) {
|
||||
padding-left: 40px;
|
||||
}
|
||||
|
||||
.result table thead tr th:nth-child(2) {
|
||||
padding-left: 38px;
|
||||
}
|
||||
|
||||
.result table thead tr th:nth-child(4) {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.result .train-num {
|
||||
padding: 18px 25px 18px 25px;
|
||||
font-family: tahoma;
|
||||
color: #4D5873;
|
||||
font-size: 24px;
|
||||
text-align: left;
|
||||
line-height: 19px;
|
||||
border: 1px solid #dcdcdc;
|
||||
border-right: 1px solid #ccc7ba;
|
||||
background: #fff9e8;
|
||||
}
|
||||
|
||||
.result .train-seats {
|
||||
padding: 20px 0;
|
||||
border: 1px solid #cccccc;
|
||||
border-left: none;
|
||||
line-height: 18px;
|
||||
}
|
||||
|
||||
.result .train-seats .row2 {
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.result .train-info {
|
||||
width: 120px;
|
||||
padding: 0 25px 0 25px;
|
||||
border-top: 1px solid #cccccc;
|
||||
border-bottom: 1px solid #cccccc;
|
||||
}
|
||||
|
||||
.result .train-city {
|
||||
width: 110px;
|
||||
border-top: 1px solid #cccccc;
|
||||
border-bottom: 1px solid #cccccc;
|
||||
padding: 0 0 0 5px;
|
||||
}
|
||||
|
||||
.result .ticket-block {
|
||||
display: inline-block;
|
||||
border: 1px solid rgba(0, 0, 0, 0.2);
|
||||
background: linear-gradient(to bottom, #ffffff, #ffffff 5%, #f5f5f5);
|
||||
border-radius: 4px;
|
||||
padding: 11px 16px;
|
||||
color: #4e4e4e;
|
||||
box-shadow: 0 1px 8px rgba(155, 155, 155, 0.2);
|
||||
}
|
||||
|
||||
.result .ticket-block-selected {
|
||||
border-color: #e3c69b;
|
||||
background: linear-gradient(to bottom, #ffffff, #ffffff 5%, #fcf6e1 );
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.result .ticket-block:hover {
|
||||
border-color: #dec496;
|
||||
background: linear-gradient(to bottom, #ffffff, #ffffff 5%, #fcf6e1);
|
||||
}
|
||||
|
||||
.result .ticket-num {
|
||||
color: #e00000;
|
||||
}
|
||||
|
||||
.result .train-station-type {
|
||||
font-size: 12px;
|
||||
margin-top: 5px;
|
||||
color: #888;
|
||||
}
|
||||
|
||||
.result .train-station-type:after {
|
||||
content: '';
|
||||
border-top: 5px solid #888;
|
||||
border-left: 5px solid transparent;
|
||||
border-right: 5px solid transparent;
|
||||
top: 13px;
|
||||
position: relative;
|
||||
left: 2px;
|
||||
}
|
||||
|
||||
/*始发终到标记*/
|
||||
.result .train-city .start:after {
|
||||
content: ' [始]';
|
||||
color: #c23825;
|
||||
}
|
||||
|
||||
.result .train-city .end:after {
|
||||
content: ' [终]';
|
||||
color: #c23825;
|
||||
}
|
||||
|
@ -73,27 +73,27 @@
|
||||
<ul class="search-form">
|
||||
<li>
|
||||
<label class="label-desc">出发城市</label>
|
||||
<div class="input-wrap"><input class="search-form-city ui-cityselector" autocomplete="off" type="text" name="from_city" placeholder="请填写出发城市" /></div>
|
||||
<div class="input-wrap"><input class="search-form-city ui-cityselector" id="from_city" autocomplete="off" type="text" name="from_city" placeholder="请填写出发城市" /></div>
|
||||
</li>
|
||||
<li class="transfer-city">
|
||||
<div class="transfer-city-btn"></div>
|
||||
</li>
|
||||
<li>
|
||||
<label class="label-desc">到达城市</label>
|
||||
<div class="input-wrap"><input class="search-form-city ui-cityselector" autocomplete="off" type="text" name="to_city" placeholder="请填写到达城市" /></div>
|
||||
<div class="input-wrap"><input class="search-form-city ui-cityselector" id="to_city" autocomplete="off" type="text" name="to_city" placeholder="请填写到达城市" /></div>
|
||||
</li>
|
||||
<li class="select-date">
|
||||
<label class="label-desc">乘车日期</label>
|
||||
<div class="input-wrap"><input class="search-form-date ui-date" type="text" name="to_city" placeholder="请选择乘车日期" /></div>
|
||||
<div class="input-wrap"><input class="search-form-date ui-date" data-profile-key="depDate" type="text" name="dep_date" id="dep_date" placeholder="请选择乘车日期" /></div>
|
||||
</li>
|
||||
<li>
|
||||
<div class="identity fl">
|
||||
<label><input type="radio" name="ticket_type" checked="checked" id="ticket_type_common" />普通</label>
|
||||
<label><input type="radio" name="ticket_type" checked="checked" id="ticket_type_stu" />学生</label>
|
||||
<label><input type="radio" name="ticket_type" data-profile-key="studentTicket" value="0" checked="checked" id="ticket_type_common" />普通</label>
|
||||
<label><input type="radio" name="ticket_type" data-profile-key="studentTicket" value="1" checked="checked" id="ticket_type_stu" />学生</label>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<input class="submit-btn" type="submit" value="开始刷票" />
|
||||
<input class="submit-btn" id="btnQuery" type="button" value="查询余票" />
|
||||
</li>
|
||||
</ul>
|
||||
</form>
|
||||
@ -257,136 +257,53 @@
|
||||
</div>
|
||||
</div>
|
||||
<!-- 搜索结果 -->
|
||||
<div class="result">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>车次</th>
|
||||
<th>发/到时间</th>
|
||||
<th>发/到站</th>
|
||||
<th>余票信息</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="train-num">
|
||||
<p>T190</p>
|
||||
<a class="train-station-type" href="javascript:;">经停站</a>
|
||||
</td>
|
||||
<td class="train-info">
|
||||
<p>07:00-12:36</p>
|
||||
<p>历时5小时36分</p>
|
||||
</td>
|
||||
<td class="train-city">
|
||||
<p>北京西</p>
|
||||
<p>南昌</p>
|
||||
</td>
|
||||
<td class="train-seats">
|
||||
<a href="javascript:void(0);" class="ticket-block">
|
||||
<p><span>二等座</span></p>
|
||||
<p class="row2">
|
||||
<span class="ticket-num">115张 </span>
|
||||
<span>¥657</span>
|
||||
</p>
|
||||
</a>
|
||||
<a href="javascript:void(0);" class="ticket-block">
|
||||
<p><span>二等座</span></p>
|
||||
<p class="row2">
|
||||
<span class="ticket-num">115张 </span>
|
||||
<span>¥657</span>
|
||||
</p>
|
||||
</a>
|
||||
<a href="javascript:void(0);" class="ticket-block">
|
||||
<p><span>二等座</span></p>
|
||||
<p class="row2">
|
||||
<span class="ticket-num">115张 </span>
|
||||
<span>¥657</span>
|
||||
</p>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="train-num">
|
||||
<p>T190</p>
|
||||
<a class="train-station-type" href="javascript:;">经停站</a>
|
||||
</td>
|
||||
<td class="train-info">
|
||||
<p>07:00-12:36</p>
|
||||
<p>历时5小时36分</p>
|
||||
</td>
|
||||
<td class="train-city">
|
||||
<p class="start">北京西</p>
|
||||
<p>南昌</p>
|
||||
</td>
|
||||
<td class="train-seats">
|
||||
<a href="javascript:void(0);" class="ticket-block ticket-block-selected">
|
||||
<p><span>二等座</span></p>
|
||||
<p class="row2">
|
||||
<span class="ticket-num">115张 </span>
|
||||
<span>¥657</span>
|
||||
</p>
|
||||
</a>
|
||||
<a href="javascript:void(0);" class="ticket-block">
|
||||
<p><span>二等座</span></p>
|
||||
<p class="row2">
|
||||
<span class="ticket-num">115张 </span>
|
||||
<span>¥657</span>
|
||||
</p>
|
||||
</a>
|
||||
<a href="javascript:void(0);" class="ticket-block">
|
||||
<p><span>二等座</span></p>
|
||||
<p class="row2">
|
||||
<span class="ticket-num">115张 </span>
|
||||
<span>¥657</span>
|
||||
</p>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="train-num">
|
||||
<p>T190</p>
|
||||
<a class="train-station-type" href="javascript:;">经停站</a>
|
||||
</td>
|
||||
<td class="train-info">
|
||||
<p>07:00-12:36</p>
|
||||
<p>历时5小时36分</p>
|
||||
</td>
|
||||
<td class="train-city">
|
||||
<p>北京西</p>
|
||||
<p class="end">南昌</p>
|
||||
</td>
|
||||
<td class="train-seats">
|
||||
<a href="javascript:void(0);" class="ticket-block">
|
||||
<p><span>二等座</span></p>
|
||||
<p class="row2">
|
||||
<span class="ticket-num">115张 </span>
|
||||
<span>¥657</span>
|
||||
</p>
|
||||
</a>
|
||||
<a href="javascript:void(0);" class="ticket-block">
|
||||
<p><span>二等座</span></p>
|
||||
<p class="row2">
|
||||
<span class="ticket-num">115张 </span>
|
||||
<span>¥657</span>
|
||||
</p>
|
||||
</a>
|
||||
<a href="javascript:void(0);" class="ticket-block">
|
||||
<p><span>二等座</span></p>
|
||||
<p class="row2">
|
||||
<span class="ticket-num">115张 </span>
|
||||
<span>¥657</span>
|
||||
</p>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
<div class="result" id="result">
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</div>
|
||||
<script type="text/x-dot-template" id="train_table">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>车次</th>
|
||||
<th>发/到时间</th>
|
||||
<th>发/到站</th>
|
||||
<th>余票信息</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{~it.original:t:index}}
|
||||
<tr>
|
||||
<td class="train-num">
|
||||
<p>{{=t.code}}</p>
|
||||
<a class="train-station-type" href="javascript:;">经停站</a>
|
||||
</td>
|
||||
<td class="train-info">
|
||||
<p>{{=t.from.time}}-{{=t.to.time}}</p>
|
||||
<p>历时{{=t.elapsedTime.total.replace(':',"小时")}}分</p>
|
||||
</td>
|
||||
<td class="train-city">
|
||||
<p>{{=t.from.name}}</p>
|
||||
<p>{{=t.to.name}}</p>
|
||||
</td>
|
||||
<td class="train-seats">
|
||||
{{for(var code in t.tickets){}}
|
||||
<a href="javascript:void(0);" class="ticket-block">
|
||||
<p><span>{{=ext.param.toSeatTypeName(code)}}</span></p>
|
||||
<p class="row2">
|
||||
<span class="ticket-num">{{=(t.tickets[code]?t.tickets[code]+"张":"无票")}} </span>
|
||||
<span>¥{{=t.price["_"+code]/10}}</span>
|
||||
</p>
|
||||
</a>
|
||||
{{}}}
|
||||
</td>
|
||||
</tr>
|
||||
{{~}}
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
</script>
|
||||
|
||||
<article id="save-travel-method" class="float-dialog">
|
||||
<header>
|
||||
@ -502,10 +419,11 @@
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
<script src="js/modules/jquery/jquery.js"></script>
|
||||
<script src="js/modules/underscore/underscore.js"></script>
|
||||
<script src="js/boot.js"></script>
|
||||
<script src="js/modules/doT.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -36,26 +36,28 @@
|
||||
var profile = storage.obj("12306_user_" + username) || { username: username, passengers: [], savedProfile: {}, currentProfile: {}, rawPassenger: [], options: {} };
|
||||
that.current = profile;
|
||||
|
||||
if (checkData) {
|
||||
that.current.dispname = checkData.realName;
|
||||
that.fireEvent("userInfoUpdated");
|
||||
|
||||
if (!checkData.isChecked)
|
||||
that.fireEvent("userNotChecked");
|
||||
} else {
|
||||
that.checkLoginState(function (data) {
|
||||
that.current.dispname = data.realName;
|
||||
if (username) {
|
||||
if (checkData) {
|
||||
that.current.dispname = checkData.realName;
|
||||
that.fireEvent("userInfoUpdated");
|
||||
|
||||
if (!data.isChecked)
|
||||
if (!checkData.isChecked)
|
||||
that.fireEvent("userNotChecked");
|
||||
});
|
||||
} else {
|
||||
that.checkLoginState(function (data) {
|
||||
that.current.dispname = data.realName;
|
||||
that.fireEvent("userInfoUpdated");
|
||||
|
||||
if (!data.isChecked)
|
||||
that.fireEvent("userNotChecked");
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
that.resetProfile = function () {
|
||||
session = null;
|
||||
that.loadProfile("");
|
||||
};
|
||||
that.loadPassengers = function(force) {
|
||||
that.loadPassengers = function (force) {
|
||||
if (!that.isLogined)
|
||||
return;
|
||||
|
||||
@ -81,7 +83,6 @@
|
||||
}
|
||||
that.fireEvent("sessionChanged");
|
||||
|
||||
|
||||
(that.isLogined && keepAlive.start()) || keepAlive.stop();
|
||||
}
|
||||
});
|
||||
@ -95,6 +96,8 @@
|
||||
that.checkLoginState(function (data) {
|
||||
if (data.logined) {
|
||||
that.loadProfile(data.username, data);
|
||||
} else {
|
||||
that.loadProfile("");
|
||||
}
|
||||
});
|
||||
document.addEventListener("loginInvalid", function () {
|
||||
@ -104,6 +107,7 @@
|
||||
}
|
||||
that.resetProfile();
|
||||
});
|
||||
this.loadProfile("");
|
||||
|
||||
return this;
|
||||
};
|
||||
|
@ -45,7 +45,7 @@
|
||||
});
|
||||
});
|
||||
start.fail(function() {
|
||||
alert("没有安装扩展!");
|
||||
alert("提示" ,"没有安装扩展!");
|
||||
});
|
||||
|
||||
if (document.body.dataset["mobileSupportInitialized"]) {
|
||||
|
@ -37,5 +37,8 @@
|
||||
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]];
|
||||
};
|
||||
|
||||
});
|
148
Web12306/js/modules/doT.js
Normal file
148
Web12306/js/modules/doT.js
Normal file
@ -0,0 +1,148 @@
|
||||
// doT.js
|
||||
// 2011, Laura Doktorova, https://github.com/olado/doT
|
||||
// Licensed under the MIT license.
|
||||
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
var doT = {
|
||||
version: '1.0.1',
|
||||
templateSettings: {
|
||||
evaluate: /\{\{([\s\S]+?(\}?)+)\}\}/g,
|
||||
interpolate: /\{\{=([\s\S]+?)\}\}/g,
|
||||
encode: /\{\{!([\s\S]+?)\}\}/g,
|
||||
use: /\{\{#([\s\S]+?)\}\}/g,
|
||||
useParams: /(^|[^\w$])def(?:\.|\[[\'\"])([\w$\.]+)(?:[\'\"]\])?\s*\:\s*([\w$\.]+|\"[^\"]+\"|\'[^\']+\'|\{[^\}]+\})/g,
|
||||
define: /\{\{##\s*([\w\.$]+)\s*(\:|=)([\s\S]+?)#\}\}/g,
|
||||
defineParams: /^\s*([\w$]+):([\s\S]+)/,
|
||||
conditional: /\{\{\?(\?)?\s*([\s\S]*?)\s*\}\}/g,
|
||||
iterate: /\{\{~\s*(?:\}\}|([\s\S]+?)\s*\:\s*([\w$]+)\s*(?:\:\s*([\w$]+))?\s*\}\})/g,
|
||||
varname: 'it',
|
||||
extvarname: 'ext',
|
||||
strip: true,
|
||||
append: true,
|
||||
selfcontained: false
|
||||
},
|
||||
template: undefined, //fn, compile template
|
||||
compile: undefined //fn, for express
|
||||
}, global;
|
||||
|
||||
if (typeof module !== 'undefined' && module.exports) {
|
||||
module.exports = doT;
|
||||
} else if (typeof define === 'function' && define.amd) {
|
||||
define(function () { return doT; });
|
||||
} else {
|
||||
global = (function () { return this || (0, eval)('this'); }());
|
||||
global.doT = doT;
|
||||
}
|
||||
|
||||
function encodeHTMLSource() {
|
||||
var encodeHTMLRules = { "&": "&", "<": "<", ">": ">", '"': '"', "'": ''', "/": '/' },
|
||||
matchHTML = /&(?!#?\w+;)|<|>|"|'|\//g;
|
||||
return function () {
|
||||
return this ? this.replace(matchHTML, function (m) { return encodeHTMLRules[m] || m; }) : this;
|
||||
};
|
||||
}
|
||||
String.prototype.encodeHTML = encodeHTMLSource();
|
||||
|
||||
var startend = {
|
||||
append: { start: "'+(", end: ")+'", endencode: "||'').toString().encodeHTML()+'" },
|
||||
split: { start: "';out+=(", end: ");out+='", endencode: "||'').toString().encodeHTML();out+='" }
|
||||
}, skip = /$^/;
|
||||
|
||||
function resolveDefs(c, block, def) {
|
||||
return ((typeof block === 'string') ? block : block.toString())
|
||||
.replace(c.define || skip, function (m, code, assign, value) {
|
||||
if (code.indexOf('def.') === 0) {
|
||||
code = code.substring(4);
|
||||
}
|
||||
if (!(code in def)) {
|
||||
if (assign === ':') {
|
||||
if (c.defineParams) value.replace(c.defineParams, function (m, param, v) {
|
||||
def[code] = { arg: param, text: v };
|
||||
});
|
||||
if (!(code in def)) def[code] = value;
|
||||
} else {
|
||||
new Function("def", "def['" + code + "']=" + value)(def);
|
||||
}
|
||||
}
|
||||
return '';
|
||||
})
|
||||
.replace(c.use || skip, function (m, code) {
|
||||
if (c.useParams) code = code.replace(c.useParams, function (m, s, d, param) {
|
||||
if (def[d] && def[d].arg && param) {
|
||||
var rw = (d + ":" + param).replace(/'|\\/g, '_');
|
||||
def.__exp = def.__exp || {};
|
||||
def.__exp[rw] = def[d].text.replace(new RegExp("(^|[^\\w$])" + def[d].arg + "([^\\w$])", "g"), "$1" + param + "$2");
|
||||
return s + "def.__exp['" + rw + "']";
|
||||
}
|
||||
});
|
||||
var v = new Function("def", c.extvarname, "return " + code)(def);
|
||||
return v ? resolveDefs(c, v, def) : v;
|
||||
});
|
||||
}
|
||||
|
||||
function unescape(code) {
|
||||
return code.replace(/\\('|\\)/g, "$1").replace(/[\r\t\n]/g, ' ');
|
||||
}
|
||||
|
||||
doT.template = function (tmpl, c, def) {
|
||||
c = c || doT.templateSettings;
|
||||
var cse = c.append ? startend.append : startend.split, needhtmlencode, sid = 0, indv,
|
||||
str = (c.use || c.define) ? resolveDefs(c, tmpl, def || {}) : tmpl;
|
||||
|
||||
str = ("var out='" + (c.strip ? str.replace(/(^|\r|\n)\t* +| +\t*(\r|\n|$)/g, ' ')
|
||||
.replace(/\r|\n|\t|\/\*[\s\S]*?\*\//g, '') : str)
|
||||
.replace(/'|\\/g, '\\$&')
|
||||
.replace(c.interpolate || skip, function (m, code) {
|
||||
return cse.start + unescape(code) + cse.end;
|
||||
})
|
||||
.replace(c.encode || skip, function (m, code) {
|
||||
needhtmlencode = true;
|
||||
return cse.start + unescape(code) + cse.endencode;
|
||||
})
|
||||
.replace(c.conditional || skip, function (m, elsecase, code) {
|
||||
return elsecase ?
|
||||
(code ? "';}else if(" + unescape(code) + "){out+='" : "';}else{out+='") :
|
||||
(code ? "';if(" + unescape(code) + "){out+='" : "';}out+='");
|
||||
})
|
||||
.replace(c.iterate || skip, function (m, iterate, vname, iname) {
|
||||
if (!iterate) return "';} } out+='";
|
||||
sid += 1; indv = iname || "i" + sid; iterate = unescape(iterate);
|
||||
return "';var arr" + sid + "=" + iterate + ";if(arr" + sid + "){var " + vname + "," + indv + "=-1,l" + sid + "=arr" + sid + ".length-1;while(" + indv + "<l" + sid + "){"
|
||||
+ vname + "=arr" + sid + "[" + indv + "+=1];out+='";
|
||||
})
|
||||
.replace(c.evaluate || skip, function (m, code) {
|
||||
return "';" + unescape(code) + "out+='";
|
||||
})
|
||||
+ "';return out;")
|
||||
.replace(/\n/g, '\\n').replace(/\t/g, '\\t').replace(/\r/g, '\\r')
|
||||
.replace(/(\s|;|\}|^|\{)out\+='';/g, '$1').replace(/\+''/g, '')
|
||||
.replace(/(\s|;|\}|^|\{)out\+=''\+/g, '$1out+=');
|
||||
|
||||
if (needhtmlencode && c.selfcontained) {
|
||||
str = "String.prototype.encodeHTML=(" + encodeHTMLSource.toString() + "());" + str;
|
||||
}
|
||||
try {
|
||||
return new Function(c.varname, c.extvarname, str);
|
||||
} catch (e) {
|
||||
if (typeof console !== 'undefined') console.log("Could not create a template function: " + str);
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
|
||||
doT.compile = function (tmpl, def) {
|
||||
return doT.template(tmpl, null, def);
|
||||
};
|
||||
|
||||
//add jquery support
|
||||
if (window.jQuery) {
|
||||
window.jQuery.fn.extend({
|
||||
doT: function () {
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
args.unshift(this.text());
|
||||
return doT.template.apply(this, args);
|
||||
}
|
||||
});
|
||||
}
|
||||
}());
|
149
Web12306/js/otn/queryticket.js
Normal file
149
Web12306/js/otn/queryticket.js
Normal file
@ -0,0 +1,149 @@
|
||||
define(function (require, exports, module) {
|
||||
var ajax = require("../platform/webRequest.js");
|
||||
|
||||
var getTicketInfo = function (v) {
|
||||
var data = {}, info = v.indexOf("#") === -1 ? v : /getSelected\(['"](.*?)['"]\)/i.exec(v)[1].split('#')[11],
|
||||
match = info.match(/([A-Z\d])0*?([\*\d]{5})0*?(\d{4})/gi);
|
||||
|
||||
for (var j in match) {
|
||||
var m = /([A-Z\d])0*?([\*\d]{5})0*?(\d{4})/i.exec(match[j]);
|
||||
var sc = m[1];
|
||||
var sp = m[2][0] == '*' ? null : parseInt(m[2], 10);
|
||||
var st = parseInt(m[3], 10);
|
||||
if (st < 3000) {
|
||||
data[sc] = st;
|
||||
data["_" + sc] = sp;
|
||||
|
||||
//一等软座 7, 二等软座 8
|
||||
if (sc == "7") {
|
||||
data['M'] = st;
|
||||
data["_M"] = sp;
|
||||
}
|
||||
else if (sc == "8") {
|
||||
data['O'] = st;
|
||||
data['_O'] = sp;
|
||||
}
|
||||
} else {
|
||||
data['0'] = st - 3000;
|
||||
data['_0'] = sp;
|
||||
}
|
||||
};
|
||||
return data;
|
||||
};
|
||||
|
||||
var transferData = function (data) {
|
||||
var result = data;
|
||||
if (!Array.isArray(result.data) || !result.data.length || !result.data[0].queryLeftNewDTO) return null;
|
||||
|
||||
var trainData = { raw: result, rawTrainMap: {}, trainMap: {}, auto: null, nextTime: null };
|
||||
|
||||
_.each(result.data, function (t) {
|
||||
var train = {
|
||||
id: t.queryLeftNewDTO.train_no,
|
||||
code: t.queryLeftNewDTO.station_train_code,
|
||||
available: t.queryLeftNewDTO.canWebBuy === 'Y' ? 1 : 0,
|
||||
start: {
|
||||
code: t.queryLeftNewDTO.start_station_telecode,
|
||||
name: t.queryLeftNewDTO.start_station_name,
|
||||
},
|
||||
from: {
|
||||
code: t.queryLeftNewDTO.from_station_telecode,
|
||||
fromStationNo: t.queryLeftNewDTO.from_station_no,
|
||||
name: t.queryLeftNewDTO.from_station_name,
|
||||
endpoint: t.queryLeftNewDTO.from_station_telecode == t.queryLeftNewDTO.start_station_telecode,
|
||||
time: t.queryLeftNewDTO.start_time
|
||||
},
|
||||
to: {
|
||||
code: t.queryLeftNewDTO.to_station_telecode,
|
||||
toStationNo: t.queryLeftNewDTO.to_station_no,
|
||||
name: t.queryLeftNewDTO.to_station_name,
|
||||
endpoint: t.queryLeftNewDTO.end_station_telecode == t.queryLeftNewDTO.to_station_telecode,
|
||||
time: t.queryLeftNewDTO.arrive_time
|
||||
},
|
||||
elapsedTime: {
|
||||
days: t.queryLeftNewDTO.day_difference,
|
||||
total: t.queryLeftNewDTO.lishi
|
||||
},
|
||||
end: {
|
||||
code: t.queryLeftNewDTO.end_station_telecode,
|
||||
name: t.queryLeftNewDTO.end_station_name,
|
||||
},
|
||||
ypinfo: t.queryLeftNewDTO.yp_info,
|
||||
ypinfo_ex: t.queryLeftNewDTO.yp_ex,
|
||||
locationCode: t.queryLeftNewDTO.location_code,
|
||||
controlDay: t.queryLeftNewDTO.control_day,
|
||||
supportCard: t.queryLeftNewDTO.is_support_card,
|
||||
saleTime: t.queryLeftNewDTO.sale_time,
|
||||
secureStr: t.secretStr,
|
||||
selltime: null
|
||||
};
|
||||
var kp = _.pairs(getTicketInfo(t.queryLeftNewDTO.yp_info));
|
||||
train.price = _.object(_.filter(kp, function (p) { return p[0][0] === '_'; }));
|
||||
train.tickets = _.object(_.filter(kp, function (p) { return p[0][0] !== '_'; }));
|
||||
|
||||
//起售时间
|
||||
var selltimem = /(0*(\d+)月0*(\d+)日)?(\d+)\s*点\s*((\d+)分)?\s*起售/i.exec(t.buttonTextInfo.replace(/<.*?>/g, ''));
|
||||
if (selltimem) {
|
||||
train.available = -1;
|
||||
train.selltime = new Date();
|
||||
train.selltime.setHours(parseInt(selltimem[4]));
|
||||
train.selltime.setMinutes(parseInt(selltimem[6] || "0", 10));
|
||||
train.selltime.setSeconds(0);
|
||||
if (selltimem[1]) {
|
||||
//带日期
|
||||
train.selltime.setMonth(parseInt(selltimem[2]) - 1);
|
||||
train.selltime.setDate(parseInt(selltimem[3]));
|
||||
if (train.selltime.getMonth() < new Date().getMonth()) {
|
||||
train.selltime.setFullYear(train.selltime.getFullYear() + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
trainData.rawTrainMap[train.id] = t;
|
||||
trainData.trainMap[train.id] = train;
|
||||
});
|
||||
trainData.original = _.values(trainData.trainMap);
|
||||
trainData.available = trainData.original;
|
||||
trainData.trainCodes = _.pluck(trainData.original, "code");
|
||||
trainData.filtered = [];
|
||||
trainData.include = trainData.available;
|
||||
|
||||
//执行车次预过滤。过滤内容:出发地,目标地,时间
|
||||
$(document).trigger("filterTrains", trainData);
|
||||
//处理车次
|
||||
$(document).trigger("processTrains", trainData);
|
||||
|
||||
//过滤数据
|
||||
if (trainData.filtered && trainData.filtered.length) {
|
||||
//从原始数据中删除
|
||||
var orgMap = _.toMap(result.data, function (e) {
|
||||
return e.queryLeftNewDTO.train_no;
|
||||
});
|
||||
var filtered = _.map(trainData.filtered, function (t) {
|
||||
return orgMap[t.id];
|
||||
});
|
||||
trainData.rawDataFiltered = _.without.apply(null, [result.data].concat(filtered));
|
||||
result.data = trainData.rawDataFiltered;
|
||||
}
|
||||
|
||||
return trainData;
|
||||
};
|
||||
|
||||
exports.queryTicket = function (from, to, date, student) {
|
||||
var def = new $.Deferred();
|
||||
|
||||
ajax.sendGet("leftTicket/query", "leftTicket/init", {
|
||||
"leftTicketDTO.train_date": date,
|
||||
"leftTicketDTO.from_station": from,
|
||||
"leftTicketDTO.to_station": to,
|
||||
"purpose_codes": student ? "0X00" : "ADULT"
|
||||
}, "json", function () {
|
||||
var data = transferData(this.model);
|
||||
def.resolveWith(data);
|
||||
}, function () {
|
||||
def.reject();
|
||||
});
|
||||
|
||||
return def;
|
||||
};
|
||||
});
|
@ -12,6 +12,29 @@
|
||||
|
||||
return { message: "未知错误信息" };
|
||||
};
|
||||
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
|
||||
};
|
||||
|
||||
if (/(y+)/i.test(format)) {
|
||||
format = format.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
|
||||
}
|
||||
|
||||
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;
|
||||
};
|
||||
});
|
@ -16,7 +16,10 @@
|
||||
value = JSON.stringify(value);
|
||||
}
|
||||
st[key] = value + '';
|
||||
extension.sendMessage({ action: "setStorage", detail: { key: value } });
|
||||
|
||||
var messageDetail = {};
|
||||
messageDetail[key] = value;
|
||||
extension.sendMessage({ action: "setStorage", detail: messageDetail });
|
||||
};
|
||||
this.remove = function (key) {
|
||||
delete st[key];
|
||||
|
File diff suppressed because one or more lines are too long
@ -78,7 +78,7 @@
|
||||
"userDTO.password": pwd,
|
||||
"randCode": randcode
|
||||
}, "json", function () {
|
||||
if (this.model.data === null || this.model.data.loginCheck !== 'Y') {
|
||||
if (!this.model.data || this.model.data.loginCheck !== 'Y') {
|
||||
loginFailed(parser.getError(this.model).message);
|
||||
} else {
|
||||
submitLoginInfo();
|
||||
@ -146,7 +146,7 @@
|
||||
|
||||
|
||||
sessionMgr.on("sessionChanged", function () {
|
||||
if (sessionMgr.current) {
|
||||
if (sessionMgr.isLogined) {
|
||||
$(".non-login").hide();
|
||||
$(".user-logined").show();
|
||||
$("div.user-nav-user").html(sessionMgr.current.dispname);
|
||||
@ -160,7 +160,7 @@
|
||||
$("div.user-nav-user").html(sessionMgr.current.dispname);
|
||||
});
|
||||
sessionMgr.on("userNotChecked", function () {
|
||||
mp.alert("用户尚未通过审核!");
|
||||
mp.alert("提示", "用户尚未通过审核!");
|
||||
});
|
||||
|
||||
//界面事件绑定
|
||||
|
@ -15,6 +15,7 @@
|
||||
var target = null;
|
||||
var prevTab = null;
|
||||
var searchKey;
|
||||
var blockClose = false;
|
||||
|
||||
that.findExtractCity = function (val) {
|
||||
if (!val)
|
||||
@ -34,8 +35,9 @@
|
||||
};
|
||||
|
||||
that.focusOnText = function () {
|
||||
if (target)
|
||||
if (target) {
|
||||
target[0].focus();
|
||||
}
|
||||
};
|
||||
that.getSelectedCity = function () {
|
||||
var ele = $(this);
|
||||
@ -114,7 +116,22 @@
|
||||
that.focusOnText();
|
||||
};
|
||||
that.hidePopup = function (force) {
|
||||
dom.removeClass("open");
|
||||
if (!blockClose) {
|
||||
dom.removeClass("open");
|
||||
|
||||
//验证
|
||||
var str = target.val();
|
||||
var city = that.findExtractCity(str);
|
||||
if (!city) {
|
||||
target.val("");
|
||||
target.attr("data-code", "");
|
||||
} else {
|
||||
target.val(city.n);
|
||||
target.attr("data-code", city.c);
|
||||
}
|
||||
target[0].dispatchEvent(new UIEvent("change"));
|
||||
}
|
||||
|
||||
|
||||
if (force) {
|
||||
dom.css("top", "-2000px");
|
||||
@ -188,13 +205,14 @@
|
||||
//当前的列表
|
||||
var eles = dom.find("div.recent-city-list:visible dd[data-code], ul.city-list-container:visible li[data-code]");
|
||||
var current = eles.filter(".selected");
|
||||
var nextSelect = null;
|
||||
if (!current.length) {
|
||||
//尚没有选择
|
||||
if (offset > 0) {
|
||||
//向下移动,则默认选择第一个
|
||||
eles.first().addClass("selected");
|
||||
(nextSelect = eles.first()).addClass("selected");
|
||||
} else {
|
||||
eles.last().addClass("selected");
|
||||
(nextSelect = eles.last()).addClass("selected");
|
||||
}
|
||||
} else {
|
||||
var index = eles.index(current);
|
||||
@ -203,18 +221,21 @@
|
||||
if (index < 0) {
|
||||
if (currentPage > 1) {
|
||||
that.showPrevPage();
|
||||
dom.find("div.city-search ul.city-list-container li[data-code]:last").addClass("selected");
|
||||
(nextSelect = dom.find("div.city-search ul.city-list-container li[data-code]:last")).addClass("selected");
|
||||
}
|
||||
} else if (index >= eles.length) {
|
||||
if (currentPage < totalPage) {
|
||||
that.showNextPage();
|
||||
dom.find("div.city-search ul.city-list-container li[data-code]:first").addClass("selected");
|
||||
(nextSelect = dom.find("div.city-search ul.city-list-container li[data-code]:first")).addClass("selected");
|
||||
}
|
||||
} else {
|
||||
current.removeClass("selected");
|
||||
eles.eq(index).addClass("selected");
|
||||
nextSelect = eles.eq(index).addClass("selected");
|
||||
}
|
||||
}
|
||||
if (nextSelect) {
|
||||
that.selectToTarget(nextSelect.attr("data-code"));
|
||||
}
|
||||
that.focusOnText();
|
||||
};
|
||||
|
||||
@ -261,12 +282,22 @@
|
||||
|
||||
ele.data("data-code", city.c);
|
||||
ele.val(city.n);
|
||||
ele[0].blur();
|
||||
|
||||
var ce = new UIEvent("change");
|
||||
ele[0].dispatchEvent(ce);
|
||||
};
|
||||
$(document).on("click", ".recent-city-list dd[data-code], .city-list-container li[data-code]", function () {
|
||||
//选定城市
|
||||
that.selectToTarget(this.dataset.code);
|
||||
that.hidePopup(true);
|
||||
if (target) {
|
||||
target[0].blur();
|
||||
}
|
||||
});
|
||||
$("#city_selector").mousedown(function () {
|
||||
blockClose = true;
|
||||
}).mouseup(function () {
|
||||
blockClose = false;
|
||||
});
|
||||
|
||||
return this;
|
||||
@ -329,12 +360,18 @@
|
||||
case 13:
|
||||
//选定
|
||||
selector.selectToTarget();
|
||||
this.blur();
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}).on("keyup", eleSelector, selector.performSearch);
|
||||
}).on("keyup", eleSelector, function (e) {
|
||||
var code = e.key || e.keyCode;
|
||||
|
||||
if ((code >= 65 && code <= 90) || code === 8 || e.ctrlKey)
|
||||
selector.performSearch.call(this);
|
||||
});
|
||||
}
|
||||
});
|
@ -99,6 +99,10 @@
|
||||
};
|
||||
exports.alert = function (title, content, callback) {
|
||||
//TODO 确认界面
|
||||
if (!content) {
|
||||
content = title || "提示";
|
||||
title = "提示";
|
||||
}
|
||||
alert(content);
|
||||
callback && callback();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user