No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 

847 líneas
26 KiB

  1. //上下车信息html()
  2. var HTML = '';
  3. //数量html()
  4. var count_html = '';
  5. //返程的html()
  6. var back_info_html = '';
  7. //返程数量的html()
  8. var count_back_html = '';
  9. //乘客人信息html()
  10. var pass_info_html = '';
  11. //去程提交信息html()
  12. var gosuccessHTML = '';
  13. //返程提交信息html()
  14. var backsuccessHTML = '';
  15. //返程相关
  16. var back_line_id = '';
  17. var back_run_id = '';
  18. var back_ticket = '';
  19. var back_ticket_id = '';
  20. var line_id = '';
  21. var run_id = '';
  22. var ticket = '';
  23. var bus_type = '';
  24. var ticket_id = '';
  25. //checkbox选中状态
  26. var ifcheck = 0;
  27. //记录乘车人个数
  28. var passenger = 0;
  29. //去程和往返的交集库存
  30. var stockCount = 0;
  31. //定义一个 只记录去程库存 一般取消返程选中时 重置去程库存
  32. var stockCountTemp = 0;
  33. window.onload = function(){
  34. var run_id = getPar('run_id');
  35. var start_area_id = getPar('start_area_id');
  36. var end_area_id = getPar('end_area_id');
  37. HTML = $('#tabbable').html();
  38. count_html = $('#list').html();
  39. back_info_html = $('#back_info').html();
  40. count_back_html = $('#list_info_back').html();
  41. pass_info_html = $('#all_passenger').html();
  42. gosuccessHTML = $('#commit_ticket_go_success').html();
  43. backsuccessHTML = $('#commit_ticket_back_success').html();
  44. //展示去程信息
  45. showGoInfo(run_id,start_area_id,end_area_id);
  46. }
  47. //展示去程信息
  48. function showGoInfo(run_id,start_area_id,end_area_id){
  49. $.ajax({
  50. url:'./zz-fx/control.php',
  51. type: "post",
  52. data: {
  53. run_id:run_id,
  54. start_area_id:start_area_id,
  55. end_area_id:end_area_id,
  56. back:1,
  57. type:"retrieval_site"
  58. },
  59. dataType: "json",
  60. success: function (data) {
  61. if(data.code == 0){
  62. console.log(data);
  63. //去程信息的数据交互
  64. goInfoReloadData(data.list);
  65. }
  66. },
  67. fail: function (data) {
  68. // 此处放失败后执行的代码
  69. }
  70. });
  71. }
  72. //去程信息的数据交互
  73. function goInfoReloadData(data){
  74. var time_html = $('#go_time').html();
  75. time_html = time_html.replace('[出发日期]',data.date);
  76. $('#go_time').html(time_html);
  77. var up_down_html = $('#up_and_down_station').html();
  78. up_down_html = up_down_html.replace('[出发地]',data.start_area_name);
  79. up_down_html = up_down_html.replace('[目的地]',data.end_area_name);
  80. $('#up_and_down_station').html(up_down_html);
  81. // var html = '';
  82. // var temp = HTML;
  83. // //出发地、目的地、时间
  84. // temp = temp.replace('[出发地]',data.start_area_name);
  85. // temp = temp.replace('[目的地]',data.end_area_name);
  86. // temp = temp.replace('[出发日期]',data.date);
  87. //出发地站点、目的地站点
  88. var start_station_list = data.start_order;
  89. var end_station_list = data.end_order;
  90. //
  91. // html += temp;
  92. // $('#tabbable').html(html);
  93. var start_station_html = '';
  94. for (var i = 0 ; i < start_station_list.length; i ++) {
  95. var tempHTML = '<option value="0">[出发地站点]</option>';
  96. tempHTML = tempHTML.replace('[出发地站点]',start_station_list[i].name);
  97. tempHTML = tempHTML.replace('0',start_station_list[i].id);
  98. start_station_html += tempHTML;
  99. }
  100. $('#start_area_station').html(start_station_html);
  101. var end_station_html = '';
  102. for (var i = 0 ; i < end_station_list.length; i ++) {
  103. var tempHTML = '<option value="0">[出发地站点]</option>';
  104. tempHTML = tempHTML.replace('[出发地站点]',end_station_list[i].name);
  105. tempHTML = tempHTML.replace('0',end_station_list[i].id);
  106. end_station_html += tempHTML;
  107. }
  108. $('#end_area_station').html(end_station_html);
  109. run_id = data.run_id;
  110. line_id = data.line_id;
  111. var start_id = $('#start_area_station').val();
  112. var end_id = $('#end_area_station').val();
  113. ticket = data.ticket;
  114. bus_type = data.bus_type;
  115. //犹豫异步加载的问题 所以只能在展示数据后 继续调用票种价格等相关信息
  116. $.ajax({
  117. url:'./zz-fx/control.php',
  118. type: "post",
  119. data: {
  120. run_id:run_id,
  121. line_id:line_id,
  122. start_id:start_id,
  123. end_id:end_id,
  124. tickets:ticket,
  125. back:1,
  126. type:"retrieval_tickets"
  127. },
  128. dataType: "json",
  129. success: function (data) {
  130. if(data.code == 0){
  131. console.log(data);
  132. //替换去程票种数量信息
  133. showCountInfoByGo(data.list);
  134. }
  135. },
  136. fail: function (data) {
  137. // 此处放失败后执行的代码
  138. }
  139. });
  140. }
  141. //选择出发站点
  142. function selectStartStationID(){
  143. var start_id = $('#start_area_station').val();
  144. var end_id = $('#end_area_station').val();
  145. $.ajax({
  146. url:'./zz-fx/control.php',
  147. type: "post",
  148. data: {
  149. run_id:run_id,
  150. line_id:line_id,
  151. start_id:start_id,
  152. end_id:end_id,
  153. tickets:ticket,
  154. back:1,
  155. type:"retrieval_tickets"
  156. },
  157. dataType: "json",
  158. success: function (data) {
  159. if(data.code == 0){
  160. console.log(data);
  161. $("#ifback").attr("checked",false);
  162. ifbackSelected(0);
  163. //替换去程票种数量信息
  164. showCountInfoByGo(data.list);
  165. }
  166. },
  167. fail: function (data) {
  168. // 此处放失败后执行的代码
  169. }
  170. });
  171. }
  172. //选择到达站点
  173. function selectEndStationID(){
  174. var start_id = $('#start_area_station').val();
  175. var end_id = $('#end_area_station').val();
  176. $.ajax({
  177. url:'./zz-fx/control.php',
  178. type: "post",
  179. data: {
  180. run_id:run_id,
  181. line_id:line_id,
  182. start_id:start_id,
  183. end_id:end_id,
  184. tickets:ticket,
  185. back:1,
  186. type:"retrieval_tickets"
  187. },
  188. dataType: "json",
  189. success: function (data) {
  190. if(data.code == 0){
  191. console.log(data);
  192. $("#ifback").attr("checked",false);
  193. ifbackSelected(0);
  194. //替换去程票种数量信息
  195. showCountInfoByGo(data.list);
  196. }
  197. },
  198. fail: function (data) {
  199. // 此处放失败后执行的代码
  200. }
  201. });
  202. }
  203. //替换去程票种数量信息
  204. function showCountInfoByGo(data){
  205. var html1 = '';
  206. var temp1 = count_html;
  207. temp1 = temp1.replace('[座位等级]',data.site_type);
  208. temp1 = temp1.replace('[价格]',data.price);
  209. //数量
  210. var maxCount = data.num > 20 ? 20 : data.num;
  211. maxCount = maxCount>0 ? maxCount : 0;
  212. stockCount = maxCount;
  213. stockCountTemp = maxCount;
  214. html1 += temp1;
  215. $('#list').html(html1);
  216. if (stockCount == 0) {
  217. var count_replace = '';
  218. $('#ifback').attr('disabled','disabled');
  219. for (var i = 0 ; i <= stockCount; i ++) {
  220. var tempHTML2 = '<option value="[0]">[-]</option>';
  221. tempHTML2 = tempHTML2.replace('[0]',i);
  222. tempHTML2 = tempHTML2.replace('[-]','无库存');
  223. count_replace += tempHTML2;
  224. }
  225. $('#count_station').html(count_replace);
  226. } else{
  227. var count_replace = '';
  228. for (var i = 0 ; i <= stockCount; i ++) {
  229. var tempHTML2 = '<option value="[0]">[-]</option>';
  230. tempHTML2 = tempHTML2.replace('[0]',i);
  231. tempHTML2 = tempHTML2.replace('[-]',i);
  232. count_replace += tempHTML2;
  233. }
  234. $('#count_station').html(count_replace);
  235. }
  236. var select_count = $('#count_station').val();
  237. var totalPrice = parseFloat(select_count)*parseFloat(data.price);
  238. $('#total').html(totalPrice);
  239. ticket_id = data.ticket_id;
  240. }
  241. //随票种数量改变总价格
  242. function changeTotalPrice(){
  243. var select_count = $('#count_station').val();
  244. var price = $('#price').html();
  245. var totalPrice = parseFloat(select_count)*parseFloat(price);
  246. $('#total').html(totalPrice);
  247. passenger = select_count;
  248. var count_replace = '';
  249. for (var i = 0;i < passenger; i ++) {
  250. var tempHTML2 = pass_info_html;
  251. tempHTML2 = tempHTML2.replace('passenger_info','passenger_info'+i);
  252. tempHTML2 = tempHTML2.replace('乘客1','乘客'+(i+1));
  253. tempHTML2 = tempHTML2.replace('pass_name','pass_name'+i);
  254. tempHTML2 = tempHTML2.replace('pass_tel','pass_tel'+i);
  255. count_replace += tempHTML2;
  256. }
  257. $('#all_passenger').html(count_replace);
  258. }
  259. //随票种数量改变总价格---针对往返票
  260. function changeBackTotalPrice(){
  261. var select_count = $('#back_count_station').val();
  262. var price = $('#back_price').html();
  263. var totalPrice = parseFloat(select_count)*parseFloat(price);
  264. $('#back_total').html(totalPrice);
  265. passenger = select_count;
  266. var count_replace = '';
  267. for (var i = 0;i < passenger; i ++) {
  268. var tempHTML2 = pass_info_html;
  269. tempHTML2 = tempHTML2.replace('passenger_info','passenger_info'+i);
  270. tempHTML2 = tempHTML2.replace('乘客1','乘客'+(i+1));
  271. count_replace += tempHTML2;
  272. }
  273. $('#all_passenger').html(count_replace);
  274. }
  275. //返程信息选中
  276. function ifbackSelected(value) {
  277. if(value == true) {
  278. $('#ifback').val('1');
  279. $('#calendar').show();
  280. // $('#select_shift').show();
  281. // $('#select_shift').show();
  282. $('#has_noback').hide();
  283. $('#has_back').show();
  284. $('#list_info_back').show();
  285. $('#list_info').hide();
  286. $('#list_info_back').hide();
  287. ifcheck = 1;
  288. // var adate = $('#id-date-picker-1').val();
  289. // selectBackDate(adate);
  290. passenger = 1;
  291. var count_replace = '';
  292. for (var i = 0;i < passenger; i ++) {
  293. var tempHTML2 = pass_info_html;
  294. tempHTML2 = tempHTML2.replace('passenger_info','passenger_info'+i);
  295. tempHTML2 = tempHTML2.replace('乘客1','乘客'+(i+1));
  296. count_replace += tempHTML2;
  297. }
  298. $('#all_passenger').html(count_replace);
  299. } else {
  300. $('#ifback').val('0');
  301. $('#calendar').hide();
  302. $('#select_shift').hide();
  303. $('#back_info').hide();
  304. $('#has_noback').show();
  305. $('#has_back').hide();
  306. $('#list_info_back').hide();
  307. $('#list_info').show();
  308. ifcheck = 0;
  309. $('#select_shift_div').show();
  310. $('.no_info_atten').hide();
  311. //重置库存量
  312. stockCount = stockCountTemp;
  313. if ($('#count_station').val()==0) {
  314. passenger = 1;
  315. } else{
  316. passenger = $('#count_station').val()
  317. }
  318. var count_replace = '';
  319. for (var i = 0;i < passenger; i ++) {
  320. var tempHTML2 = pass_info_html;
  321. tempHTML2 = tempHTML2.replace('passenger_info','passenger_info'+i);
  322. tempHTML2 = tempHTML2.replace('乘客1','乘客'+(i+1));
  323. count_replace += tempHTML2;
  324. }
  325. $('#all_passenger').html(count_replace);
  326. }
  327. }
  328. //选中返程时间 获取返程班次
  329. function selectBackDate(value){
  330. //返程出发地
  331. var back_start_area_id = getPar('end_area_id');
  332. //返程目的地
  333. var back_end_area_id = getPar('start_area_id');
  334. $.ajax({
  335. url:'./zz-fx/control.php',
  336. type: "post",
  337. data: {
  338. bus_type:bus_type,
  339. start_id:back_start_area_id,
  340. end_id:back_end_area_id,
  341. back_time:value,
  342. back:2,
  343. type:"retrieval_backthrough"
  344. },
  345. dataType: "json",
  346. success: function (data) {
  347. if(data.code == 0){
  348. console.log(data);
  349. var barlist = data.list;
  350. if (barlist.length == 0) {
  351. // $('#select_shift_div').show();
  352. // $('#select_shift_div').html('无相关班次信息!');
  353. // $('#select_shift_div').addClass('has_no_bus');
  354. $('#select_shift_div').hide();
  355. $('.no_info_atten').show();
  356. $('#back_info').hide();
  357. $('#list_info_back').hide();
  358. } else{
  359. $('#select_shift_div').show();
  360. $('#select_shift').show();
  361. $('.no_info_atten').hide();
  362. var select_shift_html = '';
  363. for (var i = 0 ; i < data.list.length; i ++) {
  364. var tempHTML = '<option value="1">请选择</option>';
  365. tempHTML = tempHTML.replace('请选择',data.list[i].start_time);
  366. tempHTML = tempHTML.replace('1',data.list[i].run_id);
  367. select_shift_html += tempHTML;
  368. }
  369. $('#select_shift').html(select_shift_html);
  370. //==================选中班次,显示返程信息
  371. //继续调用显示 返程票价和数量等相关信息
  372. var bar_content = $('#select_shift').val();
  373. showBackTicketInfo(bar_content,back_start_area_id,back_end_area_id);
  374. }
  375. }
  376. },
  377. fail: function (data) {
  378. // 此处放失败后执行的代码
  379. }
  380. });
  381. }
  382. //选中返程班次 选择返程相关的信息
  383. function showBackTicketInfo(bar_content,back_area_start,back_area_end){
  384. $.ajax({
  385. url:'./zz-fx/control.php',
  386. type: "post",
  387. data: {
  388. run_id:bar_content,
  389. start_area_id:back_area_start,
  390. end_area_id:back_area_end,
  391. back:2,
  392. type:"retrieval_site"
  393. },
  394. dataType: "json",
  395. success: function (data) {
  396. if(data.code == 0){
  397. console.log(data);
  398. if (data.list=="") {
  399. $('#back_info').show();
  400. $('#back_info').html('无相关的票种信息!');
  401. $('#back_info').addClass('has_no_bus');
  402. $('#list_info_back').hide();
  403. }else{
  404. $('#back_info').show();
  405. $('#back_info').removeClass('has_no_bus');
  406. $('#list_info_back').show();
  407. var html = '';
  408. var temp = back_info_html;
  409. //出发地、目的地、时间
  410. temp = temp.replace('[返程出发地]',data.list.start_area_name);
  411. temp = temp.replace('[返程目的地]',data.list.end_area_name);
  412. //出发地站点、目的地站点
  413. var start_station_list = data.list.start_order;
  414. var end_station_list = data.list.end_order;
  415. html += temp;
  416. $('#back_info').html(html);
  417. var start_station_back_html = '';
  418. for (var i = 0 ; i < start_station_list.length; i ++) {
  419. var tempHTML = '<option value="0">[返程出发地站点]</option>';
  420. tempHTML = tempHTML.replace('[返程出发地站点]',start_station_list[i].name);
  421. tempHTML = tempHTML.replace('0',start_station_list[i].id);
  422. start_station_back_html += tempHTML;
  423. }
  424. $('#start_area_station_back').html(start_station_back_html);
  425. var end_station_back_html = '';
  426. for (var i = 0 ; i < end_station_list.length; i ++) {
  427. var tempHTML = '<option value="0">[返程目的地站点]</option>';
  428. tempHTML = tempHTML.replace('[返程目的地站点]',end_station_list[i].name);
  429. tempHTML = tempHTML.replace('0',end_station_list[i].id);
  430. end_station_back_html += tempHTML;
  431. }
  432. $('#end_area_station_back').html(end_station_back_html);
  433. back_line_id = data.list.line_id;
  434. back_run_id = data.list.run_id;
  435. back_ticket = data.list.ticket;
  436. //============展示返程的票种价格数量信息
  437. showBackCountInfo(data.list.run_id,data.list.line_id,data.list.ticket);
  438. }
  439. }
  440. },
  441. fail: function (data) {
  442. // 此处放失败后执行的代码
  443. }
  444. });
  445. }
  446. //展示返程的票种价格数量信息
  447. function showBackCountInfo(run_id,line_id,ticket){
  448. var start_id = $('#start_area_station_back').val();
  449. var end_id = $('#end_area_station_back').val();
  450. $.ajax({
  451. url:'./zz-fx/control.php',
  452. type: "post",
  453. data: {
  454. run_id:run_id,
  455. line_id:line_id,
  456. start_id:start_id,
  457. end_id:end_id,
  458. tickets:ticket,
  459. back:2,
  460. type:"retrieval_tickets"
  461. },
  462. dataType: "json",
  463. success: function (data) {
  464. if(data.code == 0){
  465. console.log(data);
  466. //替换返程票种数量信息
  467. showCountInfoByBack(data.list);
  468. }
  469. },
  470. fail: function (data) {
  471. // 此处放失败后执行的代码
  472. }
  473. });
  474. }
  475. //替换返程票种数量信息
  476. function showCountInfoByBack(data){
  477. var html1 = '';
  478. var temp1 = count_back_html;
  479. temp1 = temp1.replace('[座位等级]',data.site_type);
  480. temp1 = temp1.replace('[价格]',parseFloat(data.price)*2);
  481. //数量
  482. var maxCount = data.num > 20 ? 20 : data.num;
  483. maxCount = maxCount>0 ? maxCount : 0;
  484. stockCount = maxCount < stockCount ? maxCount : stockCount;
  485. html1 += temp1;
  486. $('#list_info_back').html(html1);
  487. if (stockCount == 0) {
  488. var count_replace = '';
  489. for (var i = 0 ; i <= stockCount; i ++) {
  490. var tempHTML2 = '<option value="[0]">[-]</option>';
  491. tempHTML2 = tempHTML2.replace('[0]',i);
  492. tempHTML2 = tempHTML2.replace('[-]','无库存');
  493. count_replace += tempHTML2;
  494. }
  495. $('#back_count_station').html(count_replace);
  496. } else{
  497. var count_replace = '';
  498. for (var i = 0 ; i <= stockCount; i ++) {
  499. var tempHTML2 = '<option value="[0]">[-]</option>';
  500. tempHTML2 = tempHTML2.replace('[0]',i);
  501. tempHTML2 = tempHTML2.replace('[-]',i);
  502. count_replace += tempHTML2;
  503. }
  504. $('#back_count_station').html(count_replace);
  505. }
  506. var select_count = $('#back_count_station').val();
  507. var totalPrice = parseFloat(select_count)*parseFloat(data.price)*2;
  508. $('#back_total').html(totalPrice);
  509. back_ticket_id = data.ticket_id;
  510. $('#list_info_back').show();
  511. }
  512. //返程出发站点的更改
  513. function selectBackStartStationID(){
  514. var start_id = $('#start_area_station_back').val();
  515. var end_id = $('#end_area_station_back').val();
  516. $.ajax({
  517. url:'./zz-fx/control.php',
  518. type: "post",
  519. data: {
  520. run_id:back_run_id,
  521. line_id:back_line_id,
  522. start_id:start_id,
  523. end_id:end_id,
  524. tickets:back_ticket,
  525. back:2,
  526. type:"retrieval_tickets"
  527. },
  528. dataType: "json",
  529. success: function (data) {
  530. if(data.code == 0){
  531. console.log(data);
  532. //替换返程票种数量信息
  533. showCountInfoByBack(data.list);
  534. }
  535. },
  536. fail: function (data) {
  537. // 此处放失败后执行的代码
  538. }
  539. });
  540. }
  541. //返程目的地站点的更改
  542. function selectBackEndStationID(){
  543. var start_id = $('#start_area_station_back').val();
  544. var end_id = $('#end_area_station_back').val();
  545. $.ajax({
  546. url:'./zz-fx/control.php',
  547. type: "post",
  548. data: {
  549. run_id:back_run_id,
  550. line_id:back_line_id,
  551. start_id:start_id,
  552. end_id:end_id,
  553. tickets:back_ticket,
  554. back:2,
  555. type:"retrieval_tickets"
  556. },
  557. dataType: "json",
  558. success: function (data) {
  559. if(data.code == 0){
  560. console.log(data);
  561. //替换返程票种数量信息
  562. showCountInfoByBack(data.list);
  563. }
  564. },
  565. fail: function (data) {
  566. // 此处放失败后执行的代码
  567. }
  568. });
  569. }
  570. //班次selected的选中事件
  571. function selectShiftInfo(){
  572. var run_id = $('#select_shift').val();
  573. //返程出发地
  574. var back_start_area_id = getPar('end_area_id');
  575. //返程目的地
  576. var back_end_area_id = getPar('start_area_id');
  577. showBackTicketInfo(run_id,back_start_area_id,back_end_area_id);
  578. }
  579. //保存按钮
  580. function saveBtnClicked(){
  581. // var goCount = $('#count_station').val();
  582. // var go_prod_id = '{m'+line_id+'p'+goCount+'|'+'r'+run_id+'}';
  583. //联系人信息
  584. var name = $('#peo_name').val();
  585. var tel = $('#peo_tel').val();
  586. var phoneRe =/^1[3|4|5|7|8]\d{9}$/;
  587. if (name == "") {
  588. window.wxc.xcConfirm("请输入联系人姓名!", window.wxc.xcConfirm.typeEnum.info);
  589. return;
  590. }
  591. var aname = name;
  592. if (tel == "") {
  593. window.wxc.xcConfirm("请输入联系人电话!", window.wxc.xcConfirm.typeEnum.info);
  594. return;
  595. }
  596. if(!phoneRe.test(tel)){
  597. window.wxc.xcConfirm("请输入正确的手机号", window.wxc.xcConfirm.typeEnum.info);
  598. return;
  599. };
  600. $('#save_btn').html('提交中...');
  601. var tempStr = '"';
  602. var passCount = $('#all_passenger').children().length;
  603. for (var i = 0; i < passCount ; i ++) {
  604. var pass_name_str = $('#pass_name'+i).val();
  605. var pass_tel_str = $('#pass_tel'+i).val();
  606. var addstr = pass_name_str+'×'+pass_tel_str+'|';
  607. tempStr= tempStr+addstr;
  608. }
  609. tempStr = tempStr.substring(0,tempStr.length-1);
  610. tempStr = tempStr+'"';
  611. var peoInfo = '{,'+aname+',1,'+tel+',150,,,0,,'+tempStr+'}';
  612. if (ifcheck==0) {
  613. var goCount = $('#count_station').val();
  614. if (goCount == 0) {
  615. window.wxc.xcConfirm("购买票种数量为0!", window.wxc.xcConfirm.typeEnum.info);
  616. $('#save_btn').html('提交');
  617. return;
  618. }
  619. var go_prod_id = '{m'+ticket_id+'p'+goCount+'|'+'r'+run_id+'}';
  620. $.ajax({
  621. url:'./zz-fx/control.php',
  622. type: "post",
  623. data: {
  624. prod:go_prod_id,
  625. customer:peoInfo,
  626. ifback:0,
  627. back_prod:0,
  628. type:"distribut_OrderUp"
  629. },
  630. dataType: "json",
  631. success: function (data) {
  632. if(data.code == 0){
  633. console.log(data);
  634. showSuccessConmiteInfo(data.go_list);
  635. $('#save_btn').html('提交');
  636. }else{
  637. window.wxc.xcConfirm("预订失败,请重新下单!", window.wxc.xcConfirm.typeEnum.info);
  638. }
  639. },
  640. fail: function (data) {
  641. // 此处放失败后执行的代码
  642. }
  643. });
  644. } else{
  645. var backCount = $('#back_count_station').val();
  646. var go_prod_id = '{m'+ticket_id+'p'+backCount+'|'+'r'+run_id+'}';
  647. var back_prod_id = '{m'+back_ticket_id+'p'+backCount+'|'+'r'+back_run_id+'}';
  648. if (back_line_id == '') {
  649. window.wxc.xcConfirm("请选择相关日期!", window.wxc.xcConfirm.typeEnum.info);
  650. return;
  651. }
  652. if (backCount == 0) {
  653. window.wxc.xcConfirm("购买票种数量为0!", window.wxc.xcConfirm.typeEnum.info);
  654. $('#save_btn').html('提交');
  655. return;
  656. }
  657. $.ajax({
  658. url:'./zz-fx/control.php',
  659. type: "post",
  660. data: {
  661. prod:go_prod_id,
  662. customer:peoInfo,
  663. ifback:1,
  664. back_prod:back_prod_id,
  665. type:"distribut_OrderUp"
  666. },
  667. dataType: "json",
  668. success: function (data) {
  669. if(data.code == 0){
  670. console.log(data);
  671. //替换返程票种数量信息
  672. showSuccessConmiteBackInfo(data);
  673. $('#save_btn').html('提交');
  674. }else{
  675. window.wxc.xcConfirm("预订失败,请重新下单!", window.wxc.xcConfirm.typeEnum.info);
  676. }
  677. },
  678. fail: function (data) {
  679. // 此处放失败后执行的代码
  680. }
  681. });
  682. }
  683. }
  684. //展示去程的成功提交信息
  685. function showSuccessConmiteInfo(data){
  686. center_show($('.commit_ticket_go_success'));
  687. var tempHTML = gosuccessHTML;
  688. var list = data.list;
  689. tempHTML=tempHTML.replace('[去程出发地]',data.start_area);
  690. tempHTML=tempHTML.replace('去程出发地站点',data.start_res);
  691. tempHTML=tempHTML.replace('[去程目的地]',data.end_area);
  692. tempHTML=tempHTML.replace('去程目的地站点',data.end_res);
  693. tempHTML=tempHTML.replace('[yyyy-mm-dd][mm:ss]',data.run_date+" "+data.run_time);
  694. tempHTML=tempHTML.replace('[座位等级]x[数量]',data.site_type+"×"+data.num);
  695. tempHTML=tempHTML.replace('[订单总额]',data.order_price);
  696. tempHTML=tempHTML.replace('[姓名]',data.customer_name);
  697. tempHTML=tempHTML.replace('[手机号]',data.customer_mobile);
  698. $('#commit_ticket_go_success').html(tempHTML);
  699. }
  700. //展示返程提交成功的返回信息
  701. function showSuccessConmiteBackInfo(data){
  702. center_show($('.commit_ticket_back_success'));
  703. var tempHTML = backsuccessHTML;
  704. var listgo = data.go_list;
  705. var listback = data.back_list;
  706. //去程
  707. tempHTML=tempHTML.replace('[去程出发地]',listgo.start_area);
  708. tempHTML=tempHTML.replace('去程出发地站点',listgo.start_res);
  709. tempHTML=tempHTML.replace('[去程目的地]',listgo.end_area);
  710. tempHTML=tempHTML.replace('去程目的地站点',listgo.end_res);
  711. tempHTML=tempHTML.replace('[yyyy-mm-dd][mm:ss]',listgo.run_date+" "+listgo.run_time);
  712. tempHTML=tempHTML.replace('[座位等级]x[数量]',listgo.site_type+"×"+listgo.num);
  713. //返程
  714. tempHTML=tempHTML.replace('[返程出发地]',listback.start_area);
  715. tempHTML=tempHTML.replace('返程出发地站点',listback.start_res);
  716. tempHTML=tempHTML.replace('[返程目的地]',listback.end_area);
  717. tempHTML=tempHTML.replace('返程目的地站点',listback.end_res);
  718. tempHTML=tempHTML.replace('[yyyy-mm-dd][mm:ss]',listback.run_date+" "+listback.run_time);
  719. tempHTML=tempHTML.replace('[座位等级]x[数量]',listback.site_type+"×"+listback.num);
  720. tempHTML=tempHTML.replace('[订单总额]',parseInt(listback.order_price)+parseInt(listback.order_price)+'元');
  721. tempHTML=tempHTML.replace('[姓名]',listback.customer_name);
  722. tempHTML=tempHTML.replace('[手机号]',listback.customer_mobile);
  723. $('#commit_ticket_back_success').html(tempHTML);
  724. }
  725. //得到url上的参数
  726. function getPar(par){
  727. var local_url = document.location.href;
  728. local_url = decodeURI(local_url);
  729. var get = local_url.indexOf(par +"=");
  730. if(get == -1){
  731. return false;
  732. }
  733. var get_par = local_url.slice(par.length + get + 1);
  734. var nextPar = get_par.indexOf("&");
  735. if(nextPar != -1){
  736. get_par = get_par.slice(0, nextPar);
  737. }
  738. return get_par;
  739. }
  740. //居中显示
  741. var tempDiv = null;
  742. function center_show(show_div) {
  743. tempDiv = show_div;
  744. //显示蒙板
  745. show_div.css('display', 'block');
  746. show_div.css('z-index', 10);
  747. show_div.css('background-color', 'white');
  748. show_div.css('position', 'fixed');
  749. var w = show_div.css('width');
  750. var h = show_div.css('height');
  751. w = w.substr(0, w.length - 2);
  752. h = h.substr(0, h.length - 2);
  753. var s_left = (window.innerWidth - w) / 2 + 'px';
  754. var s_top = (window.innerHeight - h) / 2 + 'px';
  755. show_div.css('left', s_left);
  756. show_div.css('top', s_top);
  757. $('.mask').css('display', 'block');
  758. }
  759. //点击蒙板
  760. function hide_all() {
  761. $('.mask').css('display', 'none');
  762. tempDiv.css('display', 'none');
  763. }
  764. //点击已经有的按钮
  765. function click_show_div(objName, self_obj) {
  766. var obj = $(objName);
  767. if (obj.css('display') == 'none') {
  768. center_show(obj);
  769. } else {
  770. obj.css('display', 'none');
  771. }
  772. }
  773. //点击了弹层关闭
  774. function click_cancel(father_name, self_name) {
  775. if (father_name) {
  776. var father = $(father_name);
  777. center_show(father);
  778. } else {
  779. $('.mask').css('display', 'none');
  780. }
  781. $(self_name).css('display', 'none');
  782. }