You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

1175 lines
31 KiB

  1. $(document).ready(function(){
  2. $(".fancybox").fancybox({
  3. helpers : {
  4. overlay : {
  5. css : {'background':'rgba(000,000,000,0.3)'}
  6. }
  7. },
  8. openEffect:'elastic',
  9. openSpeed : 150,
  10. closeEffect:'elastic',
  11. transitionIn:'elastic',
  12. transitionOut:'elastic'
  13. });
  14. // $(".fancybox").click(function(){
  15. // })
  16. if($(".timeinfo").hasClass("disney")){
  17. $(".pay").on("click",function(){
  18. var judge = false ;
  19. $.each($(".aticket"),function(){
  20. if($(this).val()>0){judge=true;}
  21. });
  22. var num = 0;
  23. $.each($(".aticket"),function(){
  24. num+=parseInt($(this).val());
  25. });
  26. if(judge!=true){
  27. // $("#inline").html("请选择票种");
  28. // $(".fancybox").click();
  29. alert("请选择票种")
  30. return
  31. }else if(num>5){
  32. // $("#inline").html("单次购买不能超过5张");
  33. // $(".fancybox").click();
  34. alert("单次购买不能超过5张")
  35. return
  36. }else if( $(".hide").length!=0 ){
  37. // $("#inline").html("请选择日期");
  38. // $(".fancybox").click();
  39. alert("请选择日期");
  40. return
  41. }else if( $(".hidestation").length!=0 ){
  42. // $("#inline").html("请选择日期");
  43. // $(".fancybox").click();
  44. alert("请选择上下站点");
  45. return
  46. }else if($(".name").val()==""){
  47. // $("#inline").html("请填写姓名")
  48. // $(".fancybox").click();
  49. alert("请填写姓名")
  50. return
  51. }else if($(".phone").val()==""||$(".phone").val().length!=11){
  52. // $("#inline").html("请填写正确的手机号码")
  53. // $(".fancybox").click();
  54. alert("请填写正确的手机号码")
  55. return
  56. }else if($(".idcard").val()==""){
  57. // $("#inline").html("请填写身份证号码")
  58. // $(".fancybox").click();
  59. alert("请填写身份证号码")
  60. return
  61. }
  62. document.pay_form.submit();
  63. })
  64. }else{
  65. $(".pay").on("click",function(){
  66. var judge = false ;
  67. $.each($(".aticket"),function(){
  68. if($(this).val()>0){judge=true;}
  69. });
  70. if(judge!=true){
  71. // $("#inline").html("请选择票种");
  72. // $(".fancybox").click();
  73. alert("请选择票种")
  74. return
  75. }else if( $(".hide").length!=0 ){
  76. // $("#inline").html("日期");
  77. // $(".fancybox").click();
  78. alert("请选择日期")
  79. return
  80. }else if( $(".hidestation").length!=0 ){
  81. // $("#inline").html("请选择日期");
  82. // $(".fancybox").click();
  83. alert("请选择上下站点");
  84. return
  85. }else if($(".name").val()==""){
  86. // $("#inline").html("请填写姓名")
  87. // $(".fancybox").click();
  88. alert("请填写姓名")
  89. return
  90. }else if($(".phone").val()==""||$(".phone").val().length!=11){
  91. // $("#inline").html("请填写正确的手机号码")
  92. // $(".fancybox").click();
  93. alert("请填写正确的手机号码")
  94. return
  95. }else if($("idcard").val()==""){
  96. // $("#inline").html("请填写身份证号码")
  97. // $(".fancybox").click();
  98. alert("请填写身份证号码")
  99. return
  100. }
  101. document.pay_form.submit();
  102. })
  103. }
  104. // $(".packagelist").on("touchstart",function(){
  105. // var index = $(this).index();
  106. // $(".packagelist").removeClass("on");
  107. // $(this).addClass("on");
  108. // $(".disneylistgrid").hide();
  109. // $(".disneylistgrid").eq(index).fadeIn();
  110. // })
  111. var tomonth = new Date();
  112. atimehtml = $(".atime").outerHTML();
  113. $(".atime").remove();
  114. atimehtml2 = $(".atime2").outerHTML();
  115. $(".atime2").remove();
  116. atimehtml3 = $(".atime3").outerHTML();
  117. $(".atime3").remove();
  118. atimehtml4 = $(".atime4").outerHTML();
  119. $(".atime4").remove();
  120. astationhtml = $(".astation").outerHTML();
  121. $(".astation").remove();
  122. console.log(atimehtml)
  123. var timeinfo = $(".timeinfo").outerHTML();
  124. //addmouth($(".month"),tomonth.getFullYear(),13);
  125. $(".sel_goback").on("click",function(){
  126. addmouth($(".month"),tomonth.getFullYear(),tomonth.getMonth());
  127. $(".month").show();
  128. $(".asell_list").hide();
  129. disney()
  130. });
  131. $(".sel_station").on("click",function(){
  132. $(".station").show();
  133. $(".asell_list").hide();
  134. });
  135. $(".station").find("li").click(function(){
  136. var astation = [];
  137. $(this).siblings("li").removeClass("selects");
  138. $(this).addClass("selects");
  139. $.each($(".station").find(".selects"),function(){
  140. astation.push($(this).html());
  141. })
  142. if(astation.length==2){
  143. var html = astationhtml.replace(/star_station|end_station/g,function(match){
  144. switch(match){
  145. case "star_station":
  146. return astation[0];
  147. case "end_station":
  148. return astation[1];
  149. }
  150. })
  151. // $(".cartime li").removeClass("selects")
  152. $(".sel_station").html(html);
  153. $(".station").hide();
  154. $(".asell_list").show();
  155. }
  156. })
  157. $(".add").on("click",function(){
  158. if($(".timeinfo").hasClass("disney")){
  159. var num =0;
  160. $.each($(".aticket"),function(){
  161. num += parseInt($(this).val());
  162. })
  163. if(num==5){}else{
  164. var num = $(this).siblings("input").val();
  165. $(this).siblings("input").val(++num);
  166. }
  167. }else{
  168. var num = parseInt($(this).siblings("input").val());
  169. $(this).siblings("input").val(++num);
  170. }
  171. //var price = parseInt($(this).parent().siblings(".ticket_price").html().replace("¥",""))*num
  172. var allprice = 0;
  173. for(var i = 0 ;i<$(".aticket").length;i++){
  174. var thisone = $(".aticket").eq(i).val();
  175. var price = parseInt($(".aticket").eq(i).parent().siblings(".ticket_price").html().replace("¥",""))
  176. var aprice = thisone*price;
  177. allprice+=aprice
  178. }
  179. $(".buyprice").html("¥"+allprice)
  180. })
  181. $(".cut").on("click",function(){
  182. var num = parseInt($(this).siblings("input").val());
  183. if(num==0){
  184. }else{
  185. $(this).siblings("input").val(--num);
  186. var allprice = 0;
  187. for(var i = 0 ;i<$(".aticket").length;i++){
  188. var thisone = $(".aticket").eq(i).val();
  189. var price = parseInt($(".aticket").eq(i).parent().siblings(".ticket_price").html().replace("¥",""))
  190. var aprice = thisone*price;
  191. allprice+=aprice
  192. }
  193. $(".buyprice").html("¥"+allprice)
  194. }
  195. })
  196. $(".aticket").on("change",function(){
  197. $(".buyprice").html();
  198. var price = parseInt($(this).parent().siblings(".ticket_price").html().replace("¥",""))*$(this).val();
  199. })
  200. var doubletime = [];
  201. var atime = [];
  202. });
  203. function addmouth(dom,year,month){
  204. //console.log(atimehtml)
  205. var current_time = $("#current_time").val();
  206. !dom.hasClass("amonth")&&dom.addClass("amonth");
  207. var date = new Date(year,month);
  208. var year = current_time.substring(0,4);
  209. year = parseInt(year)-1;
  210. var tomonth = current_time.substring(5,7);
  211. var today = current_time.substring(8,10);
  212. tomonth = parseInt(tomonth)-1;
  213. today = parseInt(today);
  214. // var tomonth = new Date().getMonth();
  215. //
  216. // var today = new Date().getDate();
  217. var tomorrow = today+1;
  218. var todayhours = current_time.substring(11,13);;
  219. todayhours = parseInt(todayhours);
  220. //var todayhours = new Date().getHours();
  221. // window.localStorage.setItem("carTodayhours",carTodayhours);
  222. // window.localStorage.setItem("carTodayMin",carTodayMin);
  223. var ticketType = window.localStorage.getItem("ticketType");
  224. var dayhtml = [];
  225. var week = ["一","二","三","四","五","六","日"];
  226. dayhtml.push('<div class="showdate fire borderbot"><span class="monthleft">&lt;</span><span class="currentdate">'+date.getFullYear()+'年'+(date.getMonth()+1)+'</span><span>月</span><span class="monthright">&gt;</span></div>')
  227. $.each(week,function(i,v){
  228. dayhtml.push('<div class="aweek">'+week[i]+'</div>')
  229. });
  230. var firstweek = date.getDay();
  231. console.log(date)
  232. var first = date.getDate();
  233. var allday = new Date(parseInt(year),(parseInt(month)+1),0).getDate();
  234. //console.log(allday)
  235. //console.log(parseInt(year)+","+(parseInt(month)+1))
  236. // console.log(new Date(year,month+1,0))
  237. for(var i = 0;i<firstweek-1;i++){
  238. dayhtml.push('<div class="aday"></div>')
  239. };
  240. if (month==tomonth){
  241. for(i=1;i<=allday;i++){
  242. if(i==today){
  243. if($(".timeinfo").hasClass("oneday")||$(".timeinfo").hasClass("twoday")){
  244. dayhtml.push('<div class="aday disday">今天</div>')
  245. }else if($(".timeinfo").hasClass("oneway")){
  246. if(todayhours<17){
  247. dayhtml.push('<div class="aday canday">今天</div>')
  248. }else{
  249. dayhtml.push('<div class="aday disday">今天</div>')
  250. }
  251. }else if($(".timeinfo").hasClass("lion")||$(".timeinfo").hasClass("disney")){
  252. if((type_id==16)||(type_id==18)){
  253. if(todayhours<14){
  254. dayhtml.push('<div class="aday canday">今天</div>')
  255. }else{
  256. dayhtml.push('<div class="aday disday">今天</div>')
  257. }
  258. }else{
  259. if(todayhours>8&&todayhours<22){
  260. dayhtml.push('<div class="aday canday">今天</div>')
  261. }else{
  262. dayhtml.push('<div class="aday disday">今天</div>')
  263. }
  264. }
  265. }
  266. }else if(i==tomorrow){
  267. if($(".timeinfo").hasClass("oneday")||$(".timeinfo").hasClass("twoday")){
  268. if(todayhours<22){
  269. dayhtml.push('<div class="aday canday">'+i+'</div>')
  270. }else{
  271. dayhtml.push('<div class="aday disday">'+i+'</div>')
  272. }
  273. }else if($(".timeinfo").hasClass("oneway")){
  274. dayhtml.push('<div class="aday canday">'+i+'</div>')
  275. }else if($(".timeinfo").hasClass("lion")||$(".timeinfo").hasClass("disney")){
  276. if((type_id==16)||(type_id==18)){
  277. dayhtml.push('<div class="aday canday">'+i+'</div>')
  278. }else{
  279. if(todayhours>21){
  280. dayhtml.push('<div class="aday disday">'+i+'</div>')
  281. }else{
  282. dayhtml.push('<div class="aday canday">'+i+'</div>')
  283. }
  284. }
  285. }
  286. }else if(i<tomorrow){
  287. dayhtml.push('<div class="aday disday">'+i+'</div>')
  288. }else{
  289. dayhtml.push('<div class="aday canday">'+i+'</div>')
  290. }
  291. }
  292. }else if(month<tomonth){
  293. for(i=1;i<=allday;i++){
  294. dayhtml.push('<div class="aday disday">'+i+'</div>')
  295. }
  296. }else{
  297. for(i=1;i<=allday;i++){
  298. dayhtml.push('<div class="aday canday">'+i+'</div>')
  299. }
  300. }
  301. dom.html(dayhtml.join(""))
  302. $(".monthleft").unbind();
  303. $(".monthright").unbind();
  304. $(".monthleft").on("click",function(){
  305. var currentdate = $(".currentdate").html();
  306. currentdate = currentdate.split("年");
  307. addmouth($(".month"),currentdate[0],(currentdate[1]-2));
  308. $(".cartime").removeClass("sel")
  309. $(".aweekday").hide();
  310. disney()
  311. //console.log(new Date(currentdate[0],(currentdate[1]-2)))
  312. })
  313. $(".monthright").on("click",function(){
  314. var currentdate = $(".currentdate").html();
  315. currentdate = currentdate.split("年");
  316. //console.log(currentdate);
  317. addmouth($(".month"),currentdate[0],(currentdate[1]));
  318. $(".cartime li").removeClass("sel")
  319. $(".aweekday").hide();
  320. disney()
  321. //console.log(new Date(currentdate[0],(currentdate[1])))
  322. })
  323. }
  324. function disney(){
  325. $(".canday").unbind();
  326. if($(".timeinfo").hasClass("disney")){
  327. $(".canday").on("click",function(){
  328. if($(this).html()=="今天"){
  329. var seldate = new Date().getDate();
  330. }else{
  331. var seldate =$(this).html();
  332. }
  333. var yearmonth = $(".currentdate").html().split("年")
  334. var thisdata = yearmonth[0]+"年"+addzero(yearmonth[1])+"月"+addzero(seldate)+"日";
  335. var html = atimehtml4.replace(/mydata|star_time|time_val/g,function(match){
  336. switch(match){
  337. case "star_time":
  338. return "star_time";
  339. case "time_val":
  340. return thisdata;
  341. case "mydata":
  342. return thisdata;
  343. }
  344. })
  345. $(this).addClass("thisday");
  346. $(".sel_goback").html(html);
  347. $(".month").hide();
  348. $(".asell_list").show();
  349. })
  350. }
  351. else if($(".timeinfo").hasClass("oneday")){
  352. $(".canday").on("click",function(){
  353. $(".canday").removeClass("thisday");
  354. $(this).addClass("thisday");
  355. $(".timeinfo").find("li").removeClass("sel")
  356. atime = [];
  357. var thisdate = $(".currentdate").html().split("年");
  358. var thisday = $(this).html();
  359. console.log(thisday);
  360. if($(this).html()=="今天"){
  361. var selday = new Date().getDay();
  362. var seldate = new Date().getDate();
  363. }else{
  364. var seldate = $(this).html();
  365. var selday = new Date(parseInt(thisdate[0]),(parseInt(thisdate[1])-1),parseInt(thisday)).getDay();
  366. console.log(selday)
  367. }
  368. var index = null;
  369. if(selday==0){
  370. $(".aweekday").hide();
  371. $(".aweekday").eq(0).show();
  372. }
  373. else{
  374. $(".aweekday").hide();
  375. $(".aweekday").eq(selday).show();
  376. }
  377. $(".timeinfo").show();
  378. $(".timeinfo").find("li").unbind();
  379. $(".timeinfo").find("li").on("click",function(){
  380. atime = [];
  381. console.log(atime)
  382. if(!($(this).hasClass("disable"))){
  383. $(this).siblings("li").removeClass("sel");
  384. $(this).addClass("sel");
  385. $.each($(".timeinfo").find(".sel"),function(){
  386. atime.push($(this).children(".time").html());
  387. })
  388. if(atime.length==2){
  389. var yearmonth = $(".currentdate").html().split("年")
  390. var thisdata = yearmonth[0]+"年"+addzero(yearmonth[1])+"月"+addzero(seldate)+"日";
  391. var html = atimehtml.replace(/mydata|mytime1|mytime2|star_time|time_val/g,function(match){
  392. switch(match){
  393. case "star_time":
  394. return "star_time";
  395. case "time_val":
  396. return thisdata+atime[0]+"-"+thisdata+atime[1];
  397. case "mydata":
  398. return thisdata;
  399. case "mytime1":
  400. return atime[0];
  401. case "mytime2":
  402. return atime[1];
  403. }
  404. })
  405. $(".cartime li").removeClass("sel")
  406. $(".sel_goback").html(html);
  407. $(".month").hide();
  408. $(".timeinfo").hide();
  409. $(".asell_list").show();
  410. }
  411. }
  412. })
  413. //判断车票开车4小时内不能买票
  414. if($(".thisday").html()=="今天"){
  415. var carTodayhours = new Date().getHours()+4;
  416. var carTodayMin = new Date().getMinutes();
  417. if(carTodayMin<10){
  418. carTodayMin="0"+carTodayMin;
  419. }else{
  420. carTodayMin=carTodayMin;
  421. }
  422. var NowTime = carTodayhours.toString()+carTodayMin.toString();
  423. var objGo = $("input[name=check_go_time]").val();
  424. var objBack = $("input[name=check_back_time]").val()
  425. var objGoArr = objGo.split(",");
  426. var objBackArr = objBack.split(",");
  427. for(var i=0;i<objGoArr.length;i++){
  428. if(Number(NowTime)>objGoArr[i]){
  429. $(".carticketGo"+i).unbind("click");//去掉事件
  430. $(".carticketGo"+i).css("background-color","#bbb");
  431. }
  432. }
  433. for(var i=0;i<objBackArr.length;i++){
  434. if(Number(NowTime)>objBackArr[i]){
  435. $(".carticketBack"+i).unbind("click");//去掉事件
  436. $(".carticketBack"+i).css("background-color","#bbb");
  437. }
  438. }
  439. }else{
  440. var objGo = $("input[name=check_go_time]").val();
  441. var objBack = $("input[name=check_back_time]").val()
  442. var objGoArr = objGo.split(",");
  443. var objBackArr = objBack.split(",");
  444. for(var i=0;i<objGoArr.length;i++){
  445. $(".carticketGo"+i).removeAttr("style");
  446. }
  447. for(var i=0;i<objBackArr.length;i++){
  448. $(".carticketBack"+i).removeAttr("style");
  449. }
  450. $(".timeinfo").find("li").on("click",function(){
  451. atime = [];
  452. console.log(atime)
  453. if(!($(this).hasClass("disable"))){
  454. $(this).siblings("li").removeClass("sel");
  455. $(this).addClass("sel");
  456. $.each($(".timeinfo").find(".sel"),function(){
  457. atime.push($(this).children(".time").html());
  458. })
  459. if(atime.length==2){
  460. var yearmonth = $(".currentdate").html().split("年")
  461. var thisdata = yearmonth[0]+"年"+addzero(yearmonth[1])+"月"+addzero(seldate)+"日";
  462. var html = atimehtml.replace(/mydata|mytime1|mytime2|star_time|time_val/g,function(match){
  463. switch(match){
  464. case "star_time":
  465. return "star_time";
  466. case "time_val":
  467. return thisdata+atime[0]+"-"+thisdata+atime[1];
  468. case "mydata":
  469. return thisdata;
  470. case "mytime1":
  471. return atime[0];
  472. case "mytime2":
  473. return atime[1];
  474. }
  475. })
  476. $(".cartime li").removeClass("sel")
  477. $(".sel_goback").html(html);
  478. $(".month").hide();
  479. $(".timeinfo").hide();
  480. $(".asell_list").show();
  481. }
  482. }
  483. })
  484. }
  485. })
  486. }else if($(".timeinfo").hasClass("twoday")){
  487. addsel()
  488. }else if($(".timeinfo").hasClass("lion")){
  489. $(".canday").on("click",function(){
  490. $(".canday").removeClass("thisday");
  491. $(this).addClass("thisday");
  492. $(".timeinfo").find("li").removeClass("sel")
  493. atime = [];
  494. var thisdate = $(".currentdate").html().split("年");
  495. var thisday = $(this).html();
  496. console.log(thisday);
  497. if($(this).html()=="今天"){
  498. var selday = new Date().getDay();
  499. var seldate = new Date().getDate();
  500. }else{
  501. var seldate = $(this).html();
  502. var selday = new Date(parseInt(thisdate[0]),(parseInt(thisdate[1])-1),parseInt(thisday)).getDay();
  503. console.log(selday)
  504. }
  505. var index = null;
  506. if(selday==0){
  507. $(".aweekday").hide();
  508. $(".aweekday").eq(0).show();
  509. }
  510. else{
  511. $(".aweekday").hide();
  512. $(".aweekday").eq(selday).show();
  513. }
  514. $(".timeinfo").show();
  515. $(".timeinfo").find("li").unbind();
  516. $(".timeinfo").find("li").on("click",function(){
  517. atime = [];
  518. console.log(atime)
  519. if(!($(this).hasClass("disable"))){
  520. $(this).siblings("li").removeClass("sel");
  521. $(this).addClass("sel");
  522. $.each($(".timeinfo").find(".sel"),function(){
  523. atime.push($(this).children(".time").html());
  524. })
  525. if(atime.length==1){
  526. var yearmonth = $(".currentdate").html().split("年")
  527. var thisdata = yearmonth[0]+"年"+addzero(yearmonth[1])+"月"+addzero(seldate)+"日";
  528. var html = atimehtml3.replace(/mydata|gotime|star_time|time_val/g,function(match){
  529. switch(match){
  530. case "star_time":
  531. return "star_time";
  532. case "time_val":
  533. return thisdata+atime[0];
  534. case "mydata":
  535. return thisdata;
  536. case "gotime":
  537. return atime[0];
  538. }
  539. })
  540. $(".cartime li").removeClass("sel")
  541. $(".sel_goback").html(html);
  542. $(".month").hide();
  543. $(".timeinfo").hide();
  544. $(".asell_list").show();
  545. }
  546. }
  547. })
  548. //判断狮子王演出半小时内不能买票
  549. if($(".thisday").html()=="今天"){
  550. var NowTime;
  551. var carTodayhours = new Date().getHours();
  552. var carTodayMin = new Date().getMinutes()+30;
  553. if(carTodayMin<10){
  554. carTodayMin="0"+carTodayMin;
  555. NowTime = carTodayhours.toString()+carTodayMin.toString();
  556. }else if(carTodayMin>60){
  557. carTodayMin = carTodayMin%60;
  558. if(carTodayMin<11){
  559. NowTime = (carTodayhours+1).toString()+("0"+carTodayMin).toString();
  560. }else{
  561. NowTime = (carTodayhours+1).toString()+carTodayMin.toString();
  562. }
  563. }else{
  564. NowTime = carTodayhours.toString()+carTodayMin.toString();
  565. }
  566. var objGo = $("input[name=check_go_time]").val();
  567. var objGoArr = objGo.split(",");
  568. for(var i=0;i<objGoArr.length;i++){
  569. if(Number(NowTime)>objGoArr[i]){
  570. $(".carticketGo"+i).unbind("click");//去掉事件
  571. $(".carticketGo"+i).css("background-color","#bbb");
  572. }
  573. }
  574. }else{
  575. var objGo = $("input[name=check_go_time]").val();
  576. var objGoArr = objGo.split(",");
  577. for(var i=0;i<objGoArr.length;i++){
  578. $(".carticketGo"+i).removeAttr("style");
  579. }
  580. $(".timeinfo").find("li").on("click",function(){
  581. atime = [];
  582. console.log(atime)
  583. if(!($(this).hasClass("disable"))){
  584. $(this).siblings("li").removeClass("sel");
  585. $(this).addClass("sel");
  586. $.each($(".timeinfo").find(".sel"),function(){
  587. atime.push($(this).children(".time").html());
  588. })
  589. if(atime.length==1){
  590. var yearmonth = $(".currentdate").html().split("年")
  591. var thisdata = yearmonth[0]+"年"+addzero(yearmonth[1])+"月"+addzero(seldate)+"日";
  592. var html = atimehtml3.replace(/mydata|gotime|star_time|time_val/g,function(match){
  593. switch(match){
  594. case "star_time":
  595. return "star_time";
  596. case "time_val":
  597. return thisdata+atime[0];
  598. case "mydata":
  599. return thisdata;
  600. case "gotime":
  601. return atime[0];
  602. }
  603. })
  604. $(".cartime li").removeClass("sel")
  605. $(".sel_goback").html(html);
  606. $(".month").hide();
  607. $(".timeinfo").hide();
  608. $(".asell_list").show();
  609. }
  610. }
  611. })
  612. }
  613. })
  614. }else if($(".timeinfo").hasClass("oneway")){
  615. $(".canday").on("click",function(){
  616. $(".canday").removeClass("thisday");
  617. $(this).addClass("thisday");
  618. $(".timeinfo").find("li").removeClass("sel")
  619. atime = [];
  620. var thisdate = $(".currentdate").html().split("年");
  621. var thisday = $(this).html();
  622. console.log(thisday);
  623. if($(this).html()=="今天"){
  624. var selday = new Date().getDay();
  625. var seldate = new Date().getDate();
  626. }else{
  627. var seldate = $(this).html();
  628. var selday = new Date(parseInt(thisdate[0]),(parseInt(thisdate[1])-1),parseInt(thisday)).getDay();
  629. console.log(selday)
  630. }
  631. var index = null;
  632. if(selday==0){
  633. $(".aweekday").hide();
  634. $(".aweekday").eq(0).show();
  635. }
  636. else{
  637. $(".aweekday").hide();
  638. $(".aweekday").eq(selday).show();
  639. }
  640. $(".timeinfo").show();
  641. $(".timeinfo").find("li").unbind();
  642. $(".timeinfo").find("li").on("click",function(){
  643. atime = [];
  644. console.log(atime)
  645. if(!($(this).hasClass("disable"))){
  646. $(this).siblings("li").removeClass("sel");
  647. $(this).addClass("sel");
  648. $.each($(".timeinfo").find(".sel"),function(){
  649. atime.push($(this).children(".time").html());
  650. })
  651. if(atime.length==1){
  652. var yearmonth = $(".currentdate").html().split("年")
  653. var thisdata = yearmonth[0]+"年"+addzero(yearmonth[1])+"月"+addzero(seldate)+"日";
  654. var html = atimehtml3.replace(/mydata|gotime|star_time|time_val/g,function(match){
  655. switch(match){
  656. case "star_time":
  657. return "star_time";
  658. case "time_val":
  659. return thisdata+atime[0];
  660. case "mydata":
  661. return thisdata;
  662. case "gotime":
  663. return atime[0];
  664. }
  665. })
  666. $(".cartime li").removeClass("sel")
  667. $(".sel_goback").html(html);
  668. $(".month").hide();
  669. $(".timeinfo").hide();
  670. $(".asell_list").show();
  671. }
  672. }
  673. })
  674. //判断车票开车4小时内不能买票
  675. if($(".thisday").html()=="今天"){
  676. var carTodayhours = new Date().getHours()+4;
  677. var carTodayMin = new Date().getMinutes();
  678. if(carTodayMin<10){
  679. carTodayMin="0"+carTodayMin;
  680. }else{
  681. carTodayMin=carTodayMin;
  682. }
  683. var NowTime = carTodayhours.toString()+carTodayMin.toString();
  684. var objGo = $("input[name=check_go_time]").val();
  685. var objBack = $("input[name=check_back_time]").val()
  686. var objGoArr = objGo.split(",");
  687. var objBackArr = objBack.split(",");
  688. for(var i=0;i<objGoArr.length;i++){
  689. if(Number(NowTime)>objGoArr[i]){
  690. $(".carticketGo"+i).unbind("click");//去掉事件
  691. $(".carticketGo"+i).css("background-color","#bbb");
  692. }
  693. }
  694. for(var i=0;i<objBackArr.length;i++){
  695. if(Number(NowTime)>objBackArr[i]){
  696. $(".carticketBack"+i).unbind("click");//去掉事件
  697. $(".carticketBack"+i).css("background-color","#bbb");
  698. }
  699. }
  700. }else{
  701. var objGo = $("input[name=check_go_time]").val();
  702. var objBack = $("input[name=check_back_time]").val()
  703. var objGoArr = objGo.split(",");
  704. var objBackArr = objBack.split(",");
  705. for(var i=0;i<objGoArr.length;i++){
  706. $(".carticketGo"+i).removeAttr("style");
  707. }
  708. for(var i=0;i<objBackArr.length;i++){
  709. $(".carticketBack"+i).removeAttr("style");
  710. }
  711. $(".timeinfo").find("li").on("click",function(){
  712. atime = [];
  713. console.log(atime)
  714. if(!($(this).hasClass("disable"))){
  715. $(this).siblings("li").removeClass("sel");
  716. $(this).addClass("sel");
  717. $.each($(".timeinfo").find(".sel"),function(){
  718. atime.push($(this).children(".time").html());
  719. })
  720. if(atime.length==1){
  721. var yearmonth = $(".currentdate").html().split("年")
  722. var thisdata = yearmonth[0]+"年"+addzero(yearmonth[1])+"月"+addzero(seldate)+"日";
  723. var html = atimehtml3.replace(/mydata|gotime|star_time|time_val/g,function(match){
  724. switch(match){
  725. case "star_time":
  726. return "star_time";
  727. case "time_val":
  728. return thisdata+atime[0];
  729. case "mydata":
  730. return thisdata;
  731. case "gotime":
  732. return atime[0];
  733. }
  734. })
  735. $(".cartime li").removeClass("sel")
  736. $(".sel_goback").html(html);
  737. $(".month").hide();
  738. $(".timeinfo").hide();
  739. $(".asell_list").show();
  740. }
  741. }
  742. })
  743. }
  744. })
  745. }
  746. }
  747. var dayinfo=[];
  748. var week1= {};
  749. var week2= {};
  750. function addsel(){
  751. $(".canday").unbind();
  752. var mymonth = $(".currentdate").html().split("年");
  753. var allday = new Date(mymonth[0],(parseInt(mymonth[1])),0).getDate();
  754. var twoday = [];
  755. $(".canday").on("click",function(){
  756. //$(this).html()==new Date(mymonth[0],(parseInt(mymonth[1]))).getDate()||($(this).html()=="今天"&&new Date().getDate()==new Date(mymonth[0],(parseInt(mymonth[1]))).getDate())
  757. if(typeof week1.go!="undefined"&&($(this).html()==new Date(mymonth[0],(parseInt(mymonth[1]))).getDate()||($(this).html()=="今天"&&new Date().getDate()==new Date(mymonth[0],(parseInt(mymonth[1]))).getDate()))){
  758. console.log(12)
  759. var aweek = 2 ;
  760. var thisdate = $(".currentdate").html().split("年");
  761. var thisday = $(this).html();
  762. $(this).addClass("thisday");
  763. $(this).removeClass("placesel");
  764. }else if($(this).hasClass("placesel")){
  765. var thisdate = $(".currentdate").html().split("年");
  766. var thisday = $(this).html();
  767. $(this).addClass("thisday");
  768. $(this).removeClass("placesel");
  769. var aweek = 2;
  770. }else{
  771. var aweek = 1 ;
  772. $(".canday").removeClass("thisday");
  773. $(".canday").removeClass("placesel");
  774. var thisdate = $(".currentdate").html().split("年");
  775. var thisday = $(this).html();
  776. if(thisday=="今天"){
  777. thisday=new Date().getDate();
  778. }
  779. $(this).next().addClass("placesel");
  780. $(this).addClass("thisday");
  781. $(".timeinfo").find("li").removeClass("sel");
  782. week1= {};
  783. week2= {};
  784. };
  785. if($(this).html()==allday||($(this).html()=="今天"&&new Date().getDate()==allday)){
  786. week1= {};
  787. week2= {};
  788. var thisdate = $(".currentdate").html().split("年");
  789. var thisday = allday;
  790. //addmouth($(".month"),mymonth[0],mymonth[1]);
  791. //$(".canday:eq(0)").addClass("placesel");
  792. //addsel()
  793. }
  794. console.log(thisday)
  795. if($(this).html()=="今天"){
  796. var selday = new Date().getDay();
  797. var seldate = new Date().getDate();
  798. console.log(seldate)
  799. }else{
  800. var seldate = $(this).html();
  801. //console.log(seldate)
  802. var selday = new Date(parseInt(thisdate[0]),(parseInt(thisdate[1])-1),parseInt(thisday)).getDay();
  803. };
  804. //console.log(seldate)
  805. if(selday==0){
  806. $(".aweekday").hide();
  807. $(".aweekday").eq(0).show();
  808. }else{
  809. $(".aweekday").hide();
  810. $(".aweekday").eq(selday).show();
  811. };
  812. $(".timeinfo").show();
  813. $(".timeinfo").find("li").unbind();
  814. $(".timeinfo").find("li").on("click",function(){
  815. $(this).parent().find("li").removeClass("sel");
  816. $(this).addClass("sel");
  817. var time = $(this).children(".time").html();
  818. dayinfo=[];
  819. Array.prototype.push.apply(dayinfo,thisdate);
  820. //console.log(selday+","+time)
  821. dayinfo.push(seldate);
  822. dayinfo.push(time);
  823. if($(this).parent().hasClass("go")){
  824. var goback="go";
  825. }else{
  826. var goback="back";
  827. };
  828. if(judge(aweek,dayinfo,goback)){
  829. if(typeof week1.back=="undefined"){
  830. var yearmonth = $(".currentdate").html().split("年");
  831. var thisdata = yearmonth[0]+"年"+addzero(yearmonth[1])+"月"+addzero($(".thisday").html())+"日";
  832. var html = [];
  833. var ahtml = atimehtml2.replace(/mydata|gotime|star_time|time_val/g,function(match){
  834. switch(match){
  835. case "star_time":
  836. return "star_time";
  837. case "time_val":
  838. return week1.go[0]+"年"+ addzero(week1.go[1])+"月"+ addzero(week1.go[2])+"日"+week1.go[3];
  839. case "mydata":
  840. return week1.go[0]+"年"+ addzero(week1.go[1])+"月"+ addzero(week1.go[2]);
  841. case "gotime":
  842. return week1.go[3];
  843. }
  844. });
  845. html.push(ahtml);
  846. ahtml = atimehtml3.replace(/mydata|gotime|star_time|time_val/g,function(match){
  847. switch(match){
  848. case "star_time":
  849. return "end_time";
  850. case "time_val":
  851. return week2.back[0]+"年"+ addzero(week2.back[1])+"月"+ addzero(week2.back[2])+"日"+week2.back[3];
  852. case "mydata":
  853. return week2.back[0]+"年"+ addzero(week2.back[1])+"月"+ addzero(week2.back[2]);
  854. case "gotime":
  855. return week2.back[3];
  856. }
  857. });
  858. //$(".aaaa").val(thisdata);
  859. //console.log($(".aaaa").val());
  860. html.push(ahtml);
  861. $(".cartime li").removeClass("sel");
  862. $(".sel_goback").html(html);
  863. $(".month").hide();
  864. $(".timeinfo").hide();
  865. $(".asell_list").show();
  866. }else{
  867. var yearmonth = $(".currentdate").html().split("年");
  868. var thisdata = yearmonth[0]+"年"+addzero(yearmonth[1])+"月"+addzero($(".thisday").html())+"日";
  869. var html = [];
  870. //<input type="text" value="time_val" name="star_time">
  871. var ahtml = atimehtml.replace(/mydata|mytime1|mytime2|time_val|star_time/g,function(match){
  872. switch(match){
  873. case "star_time":
  874. return "star_time";
  875. case "time_val":
  876. return week1.go[0]+"年"+ addzero(week1.go[1])+"月"+ addzero(week1.go[2])+"日"+week1.go[3]+"-"+week1.go[0]+"年"+ addzero(week1.go[1])+"月"+ addzero(week1.go[2])+"日"+week1.back[3];
  877. case "mydata":
  878. return week1.go[0]+"年"+ addzero(week1.go[1])+"月"+ addzero(week1.go[2])+"日";
  879. case "mytime1":
  880. return week1.go[3];
  881. case "mytime2":
  882. return week1.back[3]
  883. }
  884. });
  885. // console.log(week1.go[0]+"."+ week1.go[1]+"."+ week1.go[2]);
  886. // console.log(".aaaa");
  887. // $(".aaaa").val(week1.go[0]+"."+ week1.go[1]+"."+ week1.go[2]);
  888. //console.log($(".aaaa").val());
  889. // console.log($(".aaaa"));
  890. html.push(ahtml);
  891. var ahtml = atimehtml.replace(/mydata|mytime1|mytime2|time_val|star_time/g,function(match){
  892. switch(match){
  893. case "star_time":
  894. return "end_time";
  895. case "time_val":
  896. return week2.go[0]+"年"+addzero(week2.go[1])+"月"+ addzero(week2.go[2])+"日"+week2.go[3]+"-"+week2.go[0]+"年"+ addzero(week2.go[1])+"月"+ addzero(week2.go[2])+"日"+week2.back[3];
  897. case "time_val":
  898. return week2.go[0]+"年"+ addzero(week2.go[1])+"月"+ addzero(week2.go[2])+"日"+week2.back[3];
  899. case "mydata":
  900. return week2.go[0]+"年"+ addzero(week2.go[1])+"月"+ addzero(week2.go[2])+"日";
  901. case "mytime1":
  902. return week2.go[3];
  903. case "mytime2":
  904. return week2.back[3]
  905. }
  906. });
  907. html.push(ahtml);
  908. // console.log($(".aaaa").val());
  909. $(".cartime li").removeClass("sel");
  910. $(".sel_goback").html(html);
  911. //console.log($(".aaaa").val())
  912. $(".month").hide();
  913. $(".timeinfo").hide();
  914. $(".asell_list").show();
  915. week1={};
  916. week2={};
  917. }
  918. }
  919. })
  920. })
  921. }
  922. function judge(week,time,goback){
  923. console.log(goback);
  924. if(week==1){
  925. week1[goback]=time;
  926. }else{
  927. week2[goback]=time;
  928. };
  929. console.log(week1)
  930. console.log(week2)
  931. if(typeof week1.go!="undefined"&&typeof week2.back!="undefined"){
  932. return true
  933. }
  934. }
  935. function disney2(){
  936. }
  937. function leftright(){
  938. }
  939. //得到url上的参数,并反映线路名称
  940. function getPar(par){
  941. var local_url = document.location.href;
  942. local_url = decodeURI(local_url);
  943. var get = local_url.indexOf(par +"=");
  944. if(get == -1){
  945. return false;
  946. }
  947. var get_par = local_url.slice(par.length + get + 1);
  948. var nextPar = get_par.indexOf("&");
  949. if(nextPar != -1){
  950. get_par = get_par.slice(0, nextPar);
  951. }
  952. return get_par;
  953. }
  954. var type_id = getPar("id");
  955. function addzero(num){
  956. if(num.length<2){
  957. return "0"+num;
  958. }else{
  959. return num;
  960. }
  961. }
  962. jQuery.fn.outerHTML = function(s) {
  963. return (s) ? this.before(s).remove() : $("<Hill_man>").append(this.eq(0).clone()).html();
  964. }