選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 

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