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.
 
 
 
 
 

1112 lines
32 KiB

  1. //Author:zhangsq
  2. //Date:20160826
  3. //Description:查询结果
  4. var goinfoHTML = '';
  5. var backinfoHTML = '';
  6. //记录去程时间
  7. var go_date = '';
  8. //去程的出发地站点数组
  9. var go_stares_ary = '';
  10. //去程的目的地站点数组
  11. var go_endres_ary = '';
  12. //返程的出发地站点数组
  13. var back_stares_ary = '';
  14. //返程的目的地站点数组
  15. var back_endres_ary = '';
  16. //记录map info
  17. var map_info = '';
  18. //站点下弹框
  19. var resHTML = '';
  20. //乘客人弹层的html
  21. var passHTML = '';
  22. //ticket_id
  23. var ticket_id_back = '';
  24. var ticket_id_go = '';
  25. var ticket_id_back_back ='';
  26. var run_id_go = '';
  27. var run_id_back = '';
  28. //乘客数量
  29. var passCount = 0;
  30. //记录乘客人的数组
  31. var passAry = '';
  32. //记录是否选择返程 0为单一去程
  33. var ifselback = 0;
  34. //选择不同的站点弹层
  35. var sel_res_div = '';
  36. //存乘客信息缓存数组
  37. var cacheinfo = new Array();
  38. // 选中的上下车站点
  39. var t_res_name='';
  40. var t_res_id='';
  41. var t_sel_id='';
  42. $(document).ready(function(){
  43. })
  44. window.onload = function(){
  45. $("#loadingToast").show();
  46. //去程的html
  47. goinfoHTML = $('#goinfo').html();
  48. //返程的html
  49. backinfoHTML = $('#backinfo').html();
  50. //站点html 下弹框
  51. resHTML = $('#wei_info').html();
  52. //乘客人的弹层
  53. passHTML = $('#wei_info_passenger').html();
  54. //加载乘客人信息
  55. reloadPassangersInfo();
  56. var cache_info_people = getStorJson('CacheInfo_people');
  57. if (cache_info_people) {
  58. //加载历史填写信息
  59. reloadHistoryInfo(cache_info_people);
  60. }
  61. // if (CacheInfo_station) {
  62. // //加载之前的选中信息
  63. // reloadHistoryStation(CacheInfo_station);
  64. // }
  65. //判断返程
  66. var go_ticketid = getPar('go_ticket_id');
  67. if (go_ticketid == '') {
  68. $('#discount').removeClass('ui_hide');
  69. $('#hideback').addClass('ui_hide');
  70. $('#backinfo').addClass('ui_hide');
  71. ifselback = 0
  72. //加载去程的信息
  73. reloadGoInfo();
  74. } else{
  75. $("#loadingToast").show();
  76. $('#add_back').addClass('ui_hide');
  77. $('#discount').addClass('ui_hide');
  78. ifselback = 1;
  79. //加载去程和返程信息
  80. reloadBackInfo(go_ticketid);
  81. }
  82. }
  83. //加载历史信息
  84. function reloadHistoryInfo(data){
  85. $('#custmer').val(data.name);
  86. $('#tel').val(data.tel);
  87. $('#count_price').html(data.count_price);
  88. $('#people_count').html(data.people_count);
  89. var newhtml = '';
  90. for (var i = 0; i < data.peopele_array.length; i ++ ) {
  91. var str = '<div class="ub line_color_b ui_line_b ui_p_b15 passinfo" >'
  92. +'<div class="ub-f1 ui_p_t15 ui_p_t15 ulev1" style="color: black;width:1%;text-overflow:ellipsis;white-space:nowrap;overflow:hidden;">'+data.peopele_array[i].name+'</div>'
  93. +'<div class="ub-f1 ui_p_t15 ui_p_t15 lightgray_color" style="width:1%">'+data.peopele_array[i].card+'</div>'
  94. +'<div class="ub-f1 ui_p_t15 ui_p_t15 ui_p_l5 ui_p_r30 text_right" onclick="delThis(this)">'
  95. +'<img src="images/a3/ic_delete.png" style="width: 0.2rem;"/>'
  96. +'</div>'
  97. +'</div>'
  98. newhtml += str;
  99. }
  100. $('#fill_info').html(newhtml);
  101. cacheinfo = data.peopele_array;
  102. }
  103. //加载站点的历史信息
  104. function reloadHistoryStation(data){
  105. $('#gotime').html(data.gotime);
  106. $('#go_price').html(data.goPrice);
  107. $('#start_res_go').text(data.go_start_res_name);
  108. $('#start_res_go').attr('startres_goid',data.go_start_res_id);
  109. $('#end_res_go').text(data.go_end_res_name);
  110. $('#end_res_go').attr('#endres_goid',data.go_end_res_id);
  111. $('#backtime').html(data.backtime);
  112. $('#back_price').html(data.backPrice);
  113. $('#start_res_back').text(data.back_start_res_name);
  114. $('#start_res_back').attr('startres_backid',data.back_start_res_id);
  115. $('#end_res_back').text(data.back_end_res_name);
  116. $('#end_res_back').attr('endres_backid',data.back_end_res_id);
  117. $('#distance_back').html(data.distance_back);
  118. $('#usetime_back').html(data.usetime_back);
  119. map_info = data.map_info;
  120. $('#seat').html(data.seat);
  121. $('#single').html(data.single);
  122. $('#discount').html(data.discount);
  123. ticket_id_go = data.ticket_id_go;
  124. ticket_id_back = data.ticket_id_back;
  125. ticket_id_back_back = data.ticket_id_back_back;
  126. }
  127. //加载乘客人信息
  128. function reloadPassangersInfo(){
  129. var url=base_api+"./zz_wxsct/control.php";
  130. var parm={
  131. type:"order_getcustomer"
  132. }
  133. $.post(url,parm,function(res_data){
  134. res_data=JSON.parse(res_data);
  135. ZZLog(res_data);
  136. if (res_data.code == 0) {
  137. passCount = res_data.list.length;
  138. passAry = res_data.list;
  139. }
  140. });
  141. }
  142. //页面开始 加载去程信息
  143. function reloadGoInfo(){
  144. var run_id = getPar('run_id');
  145. var start_area_id = getPar('start_area_id');
  146. var end_area_id = getPar('end_area_id');
  147. var start_res_id = getPar('start_res_id');
  148. var end_res_id = getPar('end_res_id');
  149. //fuhc
  150. var go_data=getStorJson('go_data');
  151. if(go_data){
  152. // 替换去程信息
  153. ZZLog('storJson');
  154. replaceGoInfo(go_data);
  155. //得到之前选中的值
  156. var sel_station=getStorJson('CacheInfo_station');
  157. if(sel_station){
  158. //加载之前的选中信息
  159. reloadHistoryStation(sel_station);
  160. }
  161. }else{
  162. ZZLog('storJson');
  163. var url=base_api+"./zz_wxsct/control.php";
  164. var parm={
  165. type:"bus_detail_info_go",
  166. run_id:run_id,
  167. start_area_id:start_area_id,
  168. end_area_id:end_area_id,
  169. start_res_id:start_res_id,
  170. end_res_id:end_res_id
  171. }
  172. ZZLog(url+JSON.stringify(parm));
  173. $.post(url,parm,function(res_data){
  174. res_data=JSON.parse(res_data);
  175. ZZLog(res_data);
  176. if (res_data.code == 0) {
  177. // 替换去程信息
  178. replaceGoInfo(res_data);
  179. countTotal();
  180. setStorJson('go_data',res_data);
  181. } else{
  182. alert(res_data.info);
  183. }
  184. });
  185. }
  186. //fuhc end
  187. // var url=base_api+"./zz_wxsct/control.php";
  188. // var parm={
  189. // type:"bus_detail_info_go",
  190. // run_id:run_id,
  191. // start_area_id:start_area_id,
  192. // end_area_id:end_area_id,
  193. // start_res_id:start_res_id,
  194. // end_res_id:end_res_id
  195. // }
  196. // ZZLog(url+JSON.stringify(parm));
  197. // $.post(url,parm,function(res_data){
  198. // res_data=JSON.parse(res_data);
  199. // ZZLog(res_data);
  200. // if (res_data.code == 0) {
  201. //// 替换去程信息
  202. // replaceGoInfo(res_data);
  203. // countTotal();
  204. // setStorJson('go_data',res_data);
  205. // } else{
  206. // alert(res_data.info);
  207. // }
  208. // });
  209. }
  210. //替换去程信息
  211. function replaceGoInfo(data){
  212. var list = data.list;
  213. var temphtml = goinfoHTML;
  214. var nowdate = getDateTime(0);
  215. var selmonth = getMonthAndDayByDate(list.run_date,'month');
  216. var selday = getMonthAndDayByDate(list.run_date,'day');
  217. go_date = list.run_date;
  218. if (nowdate == list.run_date) {
  219. temphtml = temphtml.replace('[日期]',selmonth+'月'+selday+'日'+'&nbsp;&nbsp;今天');
  220. }else{
  221. temphtml = temphtml.replace('[日期]',selmonth+'月'+selday+'日');
  222. }
  223. temphtml = temphtml.replace('[去程时间]',list.start_time);
  224. temphtml = temphtml.replace('[出发地]',list.start_area_name);
  225. temphtml = temphtml.replace('[出发地站点]',list.start_res_name);
  226. temphtml = temphtml.replace('[目的地]',list.end_area_name);
  227. temphtml = temphtml.replace('[目的地站点]',list.end_res_name);
  228. // temphtml = temphtml.replace('[日程]','全程'+list.distance+'公里');
  229. // temphtml = temphtml.replace('[用时]',list.center_time);
  230. temphtml = temphtml.replace('[go_line_id]',list.line_id);
  231. temphtml = temphtml.replace('[go_ticket_id]',list.ticket.ticket_id_go);
  232. temphtml = temphtml.replace('[startarea_goid]',list.start_area_id);
  233. temphtml = temphtml.replace('[startres_goid]',list.start_res_id);
  234. temphtml = temphtml.replace('[endarea_goid]',list.end_area_id);
  235. temphtml = temphtml.replace('[endres_goid]',list.end_res_id);
  236. temphtml = temphtml.replace('[run_id_go]',list.run_id);
  237. temphtml = temphtml.replace('[价格]',list.ticket.go_price);
  238. $('#goinfo').html(temphtml);
  239. if (data.list.bus_type == '256'){
  240. $('#start_res_go').addClass('ui_hide');
  241. $('#end_res_go').addClass('ui_hide');
  242. }else{
  243. $('#start_res').removeClass('ui_hide');
  244. $('#end_res').removeClass('ui_hide');
  245. }
  246. $('#distance_back').html('全程'+list.distance+'公里');
  247. $('#usetime_back').html(list.center_time);
  248. ticket_id_back = list.ticket.ticket_id_back;
  249. ticket_id_go = list.ticket.ticket_id_go;
  250. run_id_go = list.run_id;
  251. var temphtml1 = $('#seatInfo').html();
  252. temphtml1 = temphtml1.replace('[普通座]',list.ticket.site);
  253. temphtml1 = temphtml1.replace('[单程]',list.ticket.run_type);
  254. if (list.ticket.discount_price == '0') {
  255. temphtml1 = temphtml1.replace('[优惠]','无往返优惠');
  256. }else{
  257. temphtml1 = temphtml1.replace('[优惠]','往返优惠'+list.ticket.discount_price+'元');
  258. temphtml1 = temphtml1.replace('[aaa]',list.ticket.discount_price);
  259. }
  260. $('#seatInfo').html(temphtml1);
  261. //去程的出发地、目的地数组
  262. go_stares_ary = list.start_res_array;
  263. go_endres_ary = list.end_res_array;
  264. //记录地图信息
  265. map_info = list['map'];
  266. //选择站点的下侧弹层
  267. $("#start_area").click(function(){
  268. $("#mask").css("display","block");
  269. $('#res_div').css("display","block");
  270. sel_res_div = 'startres_goid';
  271. upDiv(go_stares_ary,'start_res_go','go');
  272. $("#weui_actionsheet").addClass("weui_actionsheet_toggle");
  273. })
  274. $("#end_area").click(function(){
  275. $("#mask").css("display","block");
  276. $('#res_div').css("display","block");
  277. sel_res_div = 'endres_goid';
  278. upDiv(go_endres_ary,'end_res_go','go');
  279. $("#weui_actionsheet").addClass("weui_actionsheet_toggle");
  280. })
  281. $('#mask').click(function(){
  282. $("#mask").css("display","none");
  283. $('#res_div').css("display","none");
  284. $('#continue_add').css("display","none");
  285. $('#add_pass').css("display","none");
  286. $("#weui_actionsheet").removeClass("weui_actionsheet_toggle");
  287. })
  288. $('#total_div').removeClass('ui_hide');
  289. $("#loadingToast").hide();
  290. }
  291. //选择返程
  292. function selectBackInfo(){
  293. cacheTheInfo();
  294. cacheTheStation();
  295. var go_ticket_id = $('#go_id_info').attr('go_ticket_id');
  296. var data = {
  297. back : 'back',
  298. go_date : go_date,
  299. go_ticket_id : go_ticket_id
  300. }
  301. setStorJson('goListInfo',data);
  302. ifselback = 1;
  303. window.location.href = './calendar.html?go_ticket_id='+go_ticket_id+'&go_date='+go_date+'&from=fill_order';
  304. }
  305. //取消返程
  306. function hideBackInfo(){
  307. $('#discount').removeClass('ui_hide');
  308. $('#hideback').addClass('ui_hide');
  309. $('#backinfo').addClass('ui_hide');
  310. $('#add_back').removeClass('ui_hide');
  311. // clearStorage('back_data');
  312. // clearStorage('CacheInfo_station');
  313. ifselback = 0;
  314. countTotal();
  315. }
  316. //跳转地图
  317. function goToMapInfo(){
  318. cacheTheInfo();
  319. cacheTheStation();
  320. setStorJson('goMapInfo',map_info);
  321. console.log(map_info);
  322. window.location.href = './navigation_map.html';
  323. }
  324. ////选择站点的下侧弹层
  325. //$("#start_res_go").click(function(){
  326. //// upDiv(start_station_list,'start_res_go','go');
  327. // $("#mask").css("display","block");
  328. // $("#weui_actionsheet").addClass("weui_actionsheet_toggle");
  329. //})
  330. //$("#end_res_go").click(function(){
  331. // upDiv(end_station_list,'end_res_go','go');
  332. // $("#mask").css("display","block");
  333. // $("#weui_actionsheet").addClass("weui_actionsheet_toggle");
  334. //})
  335. //
  336. //$('#mask').click(function(){
  337. // $("#mask").css("display","none");
  338. // $("#weui_actionsheet").removeClass("weui_actionsheet_toggle");
  339. //})
  340. //修改去程票种的信息
  341. function changeTicketInfoGo(go_back){
  342. var type = '';
  343. var start_area_id = '';
  344. var start_res_id = '';
  345. var end_area_id = '';
  346. var end_res_id = '';
  347. var run_id = '';
  348. if (go_back == 'go') {
  349. type = 'bus_detail_ticket_go';
  350. start_area_id = $('#stare_area_id').attr('startarea_goid');
  351. start_res_id = $('#start_res_go').attr('startres_goid');
  352. end_area_id = $('#end_area_id').attr('endarea_goid');
  353. end_res_id = $('#end_res_go').attr('endres_goid');
  354. run_id = $('#hiderun').html();
  355. }else{
  356. type = 'bus_detail_ticket_back';
  357. start_area_id = $('#back_stare_area_id').attr('startarea_backid');
  358. start_res_id = $('#start_res_back').attr('startres_backid');
  359. end_area_id = $('#back_end_area_id').attr('endarea_backid');
  360. end_res_id = $('#end_res_back').attr('endres_backid');
  361. run_id = $('#hiderun_back').html();
  362. }
  363. // run_id = $('#hiderun').html();
  364. var data = {
  365. type:type,
  366. run_id:run_id,
  367. start_area_id:start_area_id,
  368. start_res_id:start_res_id,
  369. end_area_id:end_area_id,
  370. end_res_id:end_res_id
  371. }
  372. ZZLog(JSON.stringify(data));
  373. $.ajax({
  374. url:base_api+'./zz_wxsct/control.php',
  375. type: "post",
  376. data: data,
  377. dataType: "json",
  378. success: function (data) {
  379. if(data.code == 0){
  380. console.log(data);
  381. //替换去程票种数量信息
  382. showCountInfoByBack(data.list,go_back);
  383. }else{
  384. //
  385. $('#'+t_sel_id).attr(sel_res_div,t_res_id);
  386. $('#'+t_sel_id).html(t_res_name);
  387. alert(data.info)
  388. }
  389. },
  390. fail: function (data) {
  391. alert(data.info);
  392. }
  393. });
  394. }
  395. //加载去程和返程信息
  396. function reloadBackInfo(go_ticket_id){
  397. //得到去程的信息 并填充
  398. var godata = getStorJson('go_data');
  399. replaceGoInfo(godata);
  400. //fuhc 添加测试一下错没
  401. //得到之前选中的值
  402. var sel_station=getStorJson('CacheInfo_station');
  403. if(sel_station){
  404. //加载之前的选中信息
  405. reloadHistoryStation(sel_station);
  406. }
  407. var run_id = getPar('run_id');
  408. $('#loadingToast').show();
  409. //fuhc
  410. var back_data=getStorJson('back_data');
  411. if(back_data){
  412. //替换去程信息
  413. replaceBackInfo(back_data);
  414. var get_station = getStorJson('CacheInfo_station');
  415. if (get_station) {
  416. reloadHistoryStation(get_station);
  417. countTotal();
  418. }
  419. }else{
  420. var url=base_api+"./zz_wxsct/control.php";
  421. var parm={
  422. type:"bus_detail_info_back",
  423. run_id:run_id,
  424. ticket_id:go_ticket_id
  425. }
  426. ZZLog(url+JSON.stringify(parm));
  427. $.post(url,parm,function(res_data){
  428. res_data=JSON.parse(res_data);
  429. ZZLog(res_data);
  430. if (res_data.code == 0) {
  431. setStorJson('back_data',res_data);
  432. // 替换去程信息
  433. replaceBackInfo(res_data);
  434. cacheTheStation();
  435. countTotal();
  436. } else{
  437. alert(res_data.info);
  438. }
  439. });
  440. }
  441. //fuhc end
  442. // var url=base_api+"./zz_wxsct/control.php";
  443. // var parm={
  444. // type:"bus_detail_info_back",
  445. // run_id:run_id,
  446. // ticket_id:go_ticket_id
  447. // }
  448. // ZZLog(url+JSON.stringify(parm));
  449. // $.post(url,parm,function(res_data){
  450. // res_data=JSON.parse(res_data);
  451. // ZZLog(res_data);
  452. // if (res_data.code == 0) {
  453. //// 替换去程信息
  454. // replaceBackInfo(res_data);
  455. // countTotal();
  456. // setStorJson('back_data',res_data);
  457. // } else{
  458. // alert(res_data.info);
  459. // }
  460. // });
  461. }
  462. //替换返程信息
  463. function replaceBackInfo(data){
  464. var list = data.list;
  465. var temphtml = backinfoHTML;
  466. var nowdate = getDateTime(0);
  467. var selmonth = getMonthAndDayByDate(list.run_date,'month');
  468. var selday = getMonthAndDayByDate(list.run_date,'day');
  469. if (nowdate == list.run_date) {
  470. temphtml = temphtml.replace('[返程日期]',selmonth+'月'+selday+'日'+'&nbsp;&nbsp;今天');
  471. }else{
  472. temphtml = temphtml.replace('[返程日期]',selmonth+'月'+selday+'日');
  473. }
  474. temphtml = temphtml.replace('[返程时间]',list.start_time);
  475. temphtml = temphtml.replace('[返程出发地]',list.start_area_name);
  476. temphtml = temphtml.replace('[返程出发地站点]',list.start_res_name);
  477. temphtml = temphtml.replace('[返程目的地]',list.end_area_name);
  478. temphtml = temphtml.replace('[返程目的地站点]',list.end_res_name);
  479. // temphtml = temphtml.replace('[日程]','全程'+list.distance+'公里');
  480. // temphtml = temphtml.replace('[用时]',list.center_time);
  481. temphtml = temphtml.replace('[back_line_id]',list.line_id);
  482. temphtml = temphtml.replace('[back_ticket_id]',list.ticket.ticket_id_go);
  483. temphtml = temphtml.replace('[startarea_backid]',list.start_area_id);
  484. temphtml = temphtml.replace('[startres_backid]',list.start_res_id);
  485. temphtml = temphtml.replace('[endarea_backid]',list.end_area_id);
  486. temphtml = temphtml.replace('[endres_backid]',list.end_res_id);
  487. temphtml = temphtml.replace('[run_id_back]',list.run_id);
  488. ZZLog('run_id_back'+list.run_id);
  489. temphtml = temphtml.replace('[返程价格]',list.ticket.price);
  490. $('#backinfo').html(temphtml);
  491. $('#seat').html(list.ticket.site);
  492. $('#single').html(list.ticket.run_type);
  493. if (data.list.bus_type == '256'){
  494. $('#start_res_back').addClass('ui_hide');
  495. $('#end_res_back').addClass('ui_hide');
  496. }else{
  497. $('#start_res_back').removeClass('ui_hide');
  498. $('#end_res_back').removeClass('ui_hide');
  499. }
  500. ticket_id_back_back = list.ticket.ticket_id;
  501. run_id_back = list.run_id;
  502. // ticket_id_go = list.ticket.ticket_id_go;
  503. //去程的出发地、目的地数组
  504. back_stares_ary = list.start_res_array;
  505. back_endres_ary = list.end_res_array;
  506. //记录地图信息
  507. // map_info = list['map'];
  508. //返程站点 更换
  509. //选择站点的下侧弹层
  510. $("#back_start_area").click(function(){
  511. $("#mask").css("display","block");
  512. $('#res_div').css("display","block");
  513. sel_res_div = 'startres_backid';
  514. upDiv(back_stares_ary,'start_res_back','back');
  515. $("#weui_actionsheet").addClass("weui_actionsheet_toggle");
  516. })
  517. $("#back_end_area").click(function(){
  518. $("#mask").css("display","block");
  519. $('#res_div').css("display","block");
  520. sel_res_div = 'endres_backid';
  521. upDiv(back_endres_ary,'end_res_back','back');
  522. $("#weui_actionsheet").addClass("weui_actionsheet_toggle");
  523. })
  524. $('#mask').click(function(){
  525. $("#mask").css("display","none");
  526. $('#res_div').css("display","none");
  527. $('#continue_add').css("display","none");
  528. $('#add_pass').css("display","none");
  529. $("#weui_actionsheet").removeClass("weui_actionsheet_toggle");
  530. })
  531. $('#hideback').removeClass('ui_hide');
  532. $('#backinfo').removeClass('ui_hide');
  533. $("#loadingToast").hide();
  534. }
  535. //添加乘客
  536. function addPassanger(){
  537. if (passCount == 0) {
  538. $("#mask").css("display","block");
  539. $('#add_pass').css("display","block");
  540. $("#weui_actionsheet").addClass("weui_actionsheet_toggle");
  541. } else{
  542. var html = '';
  543. for (var i = 0 ; i < passAry.length; i ++) {
  544. var tempHTML = passHTML;
  545. tempHTML = tempHTML.replace('[乘客]',passAry[i].name);
  546. tempHTML = tempHTML.replace('[证件]',passAry[i].id_num);
  547. tempHTML = tempHTML.replace('[changeid]',passAry[i].id);
  548. tempHTML = tempHTML.replace('[img]','img'+passAry[i].id);
  549. tempHTML = tempHTML.replace('[selid]',passAry[i].id);
  550. // tempHTML = tempHTML.replace('[showtime]',data.station[i].start_time);
  551. // tempHTML = tempHTML.replace('images/a3/ic_select_sel.png','images/a3/ic_select_nor.png');
  552. html += tempHTML;
  553. }
  554. $('#wei_info_passenger').html(html);
  555. $("#mask").css("display","block");
  556. $('#continue_add').css("display","block");
  557. $("#weui_actionsheet").addClass("weui_actionsheet_toggle");
  558. // $('.weui_actionsheet_cell').click(function(){
  559. $('#ok').click(function(){
  560. cacheinfo = new Array();
  561. var newhtml = '';
  562. $('.selectInfo').each(function(index,dom){
  563. var str = '<div class="ub line_color_b ui_line_b ui_p_b15 passinfo" >'
  564. +'<div class="ub-f1 ui_p_t15 ui_p_t15 ulev1" style="color: black;width:1%;text-overflow:ellipsis;white-space:nowrap;overflow:hidden;">'+$(this).parent().children().eq(0).text()+'</div>'
  565. +'<div class="ub-f1 ui_p_t15 fontmiddle_color" style="width:1%;padding-top:0.17rem">'+$(this).parent().children().eq(1).text()+'</div>'
  566. +'<div class="ub-f1 ui_p_t15 ui_p_t15 ui_p_l5 ui_p_r30 text_right" index="'+index+'" onclick="delThis(this)">'
  567. +'<img src="images/a3/ic_delete.png" style="width: 0.2rem;"/>'
  568. +'</div>'
  569. +'</div>'
  570. newhtml += str;
  571. var tempdata = {
  572. name : $(this).parent().children().eq(0).text(),
  573. card : $(this).parent().children().eq(1).text()
  574. }
  575. cacheinfo.push(tempdata);
  576. })
  577. $('#fill_info').html(newhtml);
  578. $('#mask').click();
  579. countTotal();
  580. })
  581. $('#add_pass_info').click(function(){
  582. goToAddPassangers();
  583. })
  584. // })
  585. }
  586. }
  587. //删除某一个乘车人信息
  588. function delThis(obj){
  589. $(obj).parent().remove();
  590. var index = $(obj).attr('index');
  591. cacheinfo.splice(index,1);
  592. countTotal();
  593. }
  594. //计算购买总数
  595. function countTotal() {
  596. var count = $('#fill_info').children().length;
  597. $('#people_count').html(count);
  598. if (ifselback == 1) {
  599. $('#count_price').html(count*(parseInt($('#back_price').html())+parseInt($('#go_price').html())));
  600. }else{
  601. $('#count_price').html(count*$('#go_price').html());
  602. }
  603. // if (ifselback == 1) {
  604. // $('#count_price').html(count*(parseInt($('#back_price').html())+parseInt($('#go_price').html())));
  605. // }else{
  606. // if(getPar('go_ticket_id')!=""){
  607. // $('#count_price').html(count*(parseInt($('#back_price').html())+parseInt($('#go_price').html())));
  608. // }else{
  609. // $('#count_price').html(count*$('#go_price').html());
  610. // }
  611. // }
  612. }
  613. //修改乘客信息
  614. function changeinfo(id){
  615. cacheTheInfo();
  616. cacheTheStation();
  617. var temp = getPar('go_ticket_id');
  618. var run_id = getPar('run_id');
  619. var start_area_id = getPar('start_area_id');
  620. var end_area_id = getPar('end_area_id');
  621. var start_res_id = getPar('start_res_id');
  622. var end_res_id = getPar('end_res_end');
  623. if (temp == '') {
  624. var urlstr = './wirte_order.html?run_id='+run_id+'&start_area_id='+start_area_id+'&end_area_id='+end_area_id+'&start_res_id='+start_res_id+'&end_res_id='+end_res_id+'&man_id='+id;
  625. window.location.href = urlstr;
  626. }else{
  627. var urlstr = './wirte_order.html?run_id='+run_id+'&start_area_id='+start_area_id+'&end_area_id='+end_area_id+'&start_res_id='+start_res_id+'&end_res_id='+end_res_id+'&go_ticket_id='+temp+'&man_id='+id;
  628. window.location.href = urlstr;
  629. }
  630. }
  631. //选中乘客
  632. function selectInfo(selid,obj){
  633. if (obj.id == 0) {
  634. $('#img'+selid).addClass('selectInfo');
  635. $('#img'+selid).attr('src','images/a3/ic_select_sel.png');
  636. obj.id = 1;
  637. } else{
  638. $('#img'+selid).removeClass('selectInfo');
  639. $('#img'+selid).attr('src','images/a3/ic_select_nor.png');
  640. obj.id = 0;
  641. }
  642. // $('#img'+selid).addClass('selectInfo');
  643. // $('#img'+selid).attr('src','images/a3/ic_select_sel.png')
  644. }
  645. //跳转添加乘客界面
  646. function goToAddPassangers(){
  647. cacheTheInfo();
  648. cacheTheStation();
  649. var temp = getPar('go_ticket_id');
  650. var run_id = getPar('run_id');
  651. var start_area_id = getPar('start_area_id');
  652. var end_area_id = getPar('end_area_id');
  653. var start_res_id = getPar('start_res_id');
  654. var end_res_id = getPar('end_res_end');
  655. if (temp == '') {
  656. window.location.href = './wirte_order.html?run_id='+run_id+'&start_area_id='+start_area_id+'&end_area_id='+end_area_id+'&start_res_id='+start_res_id+'&end_res_id='+end_res_id;
  657. }else{
  658. window.location.href = './wirte_order.html?run_id='+run_id+'&start_area_id='+start_area_id+'&end_area_id='+end_area_id+'&start_res_id='+start_res_id+'&end_res_id='+end_res_id+'&go_ticket_id='+temp;
  659. }
  660. }
  661. //支付按钮的点击
  662. function payBtnDidClicked(){
  663. var custmer = $('#custmer').val();
  664. var tel = $('#tel').val();
  665. var phoneRe =/^1[3|4|5|7|8]\d{9}$/;
  666. var people = $('#people_count').html();
  667. if (custmer =='') {
  668. alert('请输入联系人!');
  669. return;
  670. } else if(tel == ''){
  671. alert('请输入手机号!');
  672. return;
  673. }else if (people == '') {
  674. alert('请选择乘车人!');
  675. return;
  676. }else if(!phoneRe.test(tel)){
  677. alert('请输入正确的手机号!')
  678. return;
  679. };
  680. $("#loadingToast").show();
  681. var newstr = '';
  682. $('.passinfo').each(function(){
  683. var str = $(this).children().eq(0).text()+'*'+$(this).children().eq(1).text();
  684. newstr += str + '/';
  685. })
  686. var passenger = newstr.substring(0,newstr.length-1);
  687. //联系人 乘客人信息
  688. var customer = '{,'+custmer+',1,'+tel+',,,,0,,,'+passenger+'}';
  689. var prod = '';
  690. var count = $('#people_count').html();
  691. if (ifselback == 0) {
  692. prod = '{m'+ticket_id_go+'p'+count+'|r'+run_id_go+'}'
  693. }else{
  694. //判断是否 有返程优惠
  695. if (ticket_id_back == '') {
  696. prod = '{m'+ticket_id_go+'p'+count+'|r'+run_id_go+'}'
  697. } else{
  698. prod = '{m'+ticket_id_back+'p'+count+'|r'+run_id_go+'}'
  699. }
  700. }
  701. var ifback = ifselback;
  702. var back_prod = '{m'+ticket_id_back_back+'p'+count+'|r'+run_id_back+'}';
  703. var data = {
  704. type : 'order_submit',
  705. prod : prod,
  706. ifback : ifselback,
  707. back_prod : back_prod,
  708. customer :customer
  709. }
  710. ZZLog('提交传参')
  711. ZZLog(data);
  712. var url=base_api+"./zz_wxsct/control.php";
  713. var parm=data;
  714. $.post(url,parm,function(res_data){
  715. res_data=JSON.parse(res_data);
  716. ZZLog(res_data);
  717. if (res_data.code == 0) {
  718. $("#loadingToast").hide();
  719. clearStorage('CacheInfo_people');
  720. window.location.href = res_data.info;
  721. }else{
  722. alert(res_data.info);
  723. }
  724. });
  725. }
  726. //展示去程票种 修改后的信息
  727. function showCountInfoByBack(data,go_back){
  728. if (go_back == 'go') {
  729. map_info = data['map'];
  730. var temphtml1 = $('#seatInfo').html();
  731. temphtml1 = temphtml1.replace('[普通座]',data.ticket.site);
  732. temphtml1 = temphtml1.replace('[单程]',data.ticket.run_type);
  733. if (data.ticket.discount_price == '0') {
  734. temphtml1 = temphtml1.replace('[优惠]','无往返优惠');
  735. }else{
  736. temphtml1 = temphtml1.replace('[优惠]','往返优惠'+data.ticket.discount_price+'元');
  737. }
  738. $('#seatInfo').html(temphtml1);
  739. $('#go_price').html(data.ticket.go_price);
  740. $('#gotime').html(data.start_time);
  741. $('#distance').html('全程'+data.distance+'公里');
  742. $('#usetime').html(data.center_time);
  743. ticket_id_back = data.ticket.ticket_id_back;
  744. ticket_id_go = data.ticket.ticket_id_go;
  745. map_info = data.map;
  746. $('#distance_back').html('全程'+data.distance+'公里');
  747. $('#usetime_back').html(data.center_time);
  748. }else{
  749. $('#seat').html(data.site);
  750. $('#single').html(data.run_type);
  751. $('#backtime').html(data.start_time);
  752. $('#back_price').html(data.price);
  753. ticket_id_back_back = data.ticket_id;
  754. }
  755. }
  756. //上弹框的内容封装
  757. function upDiv(data,select_id,goBack){
  758. var sel = $('#'+select_id).attr(sel_res_div);
  759. var html = '';
  760. for (var i = 0 ; i < data.station.length; i ++) {
  761. var tempHTML = resHTML;
  762. tempHTML = tempHTML.replace('示例菜单',data.station[i].res_name);
  763. tempHTML = tempHTML.replace('[res_id]',data.station[i].res_id);
  764. tempHTML = tempHTML.replace('[showtime]',data.station[i].start_time);
  765. if (sel == data.station[i].res_id) {
  766. tempHTML = tempHTML.replace('images/a3/ic_select_nor.png','images/a3/ic_select_sel.png');
  767. } else{
  768. tempHTML = tempHTML.replace('images/a3/ic_select_nor.png','images/a3/ic_select_nor.png');
  769. }
  770. // tempHTML = tempHTML.replace('images/a3/ic_select_sel.png','images/a3/ic_select_nor.png');
  771. html += tempHTML;
  772. }
  773. $('#wei_info').html(html);
  774. // html = html.replace('[poi]',data.area_name)
  775. $('#poi').html(data.area_name);
  776. $('#actionsheet_cancel').click(function(){
  777. $('#mask').click();
  778. })
  779. $('.weui_actionsheet_cell').click(function(){
  780. t_res_name=this.innerHTML;
  781. t_res_id=this.id
  782. t_sel_id=select_id;
  783. $('#'+select_id).html(this.innerHTML);
  784. $('#'+select_id).attr(sel_res_div,this.id);
  785. var seltime = $(this).attr('showtime');
  786. //添加选中图片
  787. // $(this).parent().eq(1).attr('src','images/a3/ic_select_sel.png');
  788. $('gotime').html(seltime);
  789. $('#mask').click();
  790. //修改去程的票种信息
  791. changeTicketInfoGo(goBack);
  792. })
  793. }
  794. //截取日期参数
  795. function getMonthAndDayByDate(datestr,info){
  796. var dateAry = datestr.split('-');
  797. var cNewTimeStr;
  798. switch(info){
  799. case 'year':
  800. cNewTimeStr = dateAry[0];
  801. break;
  802. case 'month':
  803. cNewTimeStr = dateAry[1];
  804. break;
  805. default:
  806. cNewTimeStr = dateAry[2];
  807. break;
  808. }
  809. return cNewTimeStr;
  810. }
  811. //存联系人和乘车人的缓存
  812. function cacheTheInfo(){
  813. var name = $('#custmer').val();
  814. var tel = $('#tel').val();
  815. var people_count = $('#people_count').html();
  816. var count_price = $('#count_price').html();
  817. var infodata = {
  818. name : name,
  819. tel : tel,
  820. people_count : people_count,
  821. count_price : count_price,
  822. peopele_array : cacheinfo
  823. }
  824. setStorJson('CacheInfo_people',infodata);
  825. }
  826. //存站点信息的缓存
  827. function cacheTheStation(){
  828. // if (ifselback == 1) {
  829. // var gotime = $('#gotime').html();
  830. // var goPrice = $('#go_price').html();
  831. // var go_start_res_name = $('#start_res_go').text();
  832. // var go_start_res_id = $('#start_res_go').attr('startres_goid');
  833. // var go_end_res_name = $('#end_res_go').text();
  834. // var go_end_res_id = $('#end_res_go').attr('#endres_goid');
  835. // var backtime = $('#backtime').html();
  836. // var backPrice = $('#back_price').html();
  837. // var back_start_res_name = $('#start_res_back').text();
  838. // var back_start_res_id = $('#start_res_back').attr('startres_backid');
  839. // var back_end_res_name = $('#end_res_back').text();
  840. // var back_end_res_id = $('#end_res_back').attr('endres_backid');
  841. //
  842. // var distance_back = $('#distance_back').html();
  843. // var usetime_back = $('#usetime_back').html();
  844. // var map_info1 = map_info;
  845. // var seat = $('#seat').html();
  846. // var single = $('#single').html();
  847. // var discount = $('#discount').html()
  848. //
  849. // var ticket_id_go1 = ticket_id_go;
  850. // var ticket_id_back1 = ticket_id_back;
  851. // var ticket_id_back_back1 = ticket_id_back_back;
  852. //
  853. //
  854. // var data = {
  855. // gotime : gotime,
  856. // goPrice : goPrice,
  857. // go_start_res_name : go_start_res_name,
  858. // go_start_res_id : go_start_res_id,
  859. // go_end_res_name : go_end_res_name,
  860. // go_end_res_id : go_end_res_id,
  861. // backtime : backtime,
  862. // backPrice : backPrice,
  863. // back_start_res_name : back_start_res_name,
  864. // back_start_res_id : back_start_res_id,
  865. // back_end_res_name : back_end_res_name,
  866. // back_end_res_id : back_end_res_id,
  867. // distance_back : distance_back,
  868. // usetime_back : usetime_back,
  869. // map_info : map_info1,
  870. // seat : seat,
  871. // single : single,
  872. // discount : discount,
  873. // ticket_id_go : ticket_id_go1,
  874. // ticket_id_back : ticket_id_back1,
  875. // ticket_id_back_back : ticket_id_back_back1
  876. // }
  877. // setStorJson('CacheInfo_station',data);
  878. // } else{
  879. // var gotime = $('#gotime').html();
  880. // var goPrice = $('#go_price').html();
  881. // var go_start_res_name = $('#start_res_go').text();
  882. // var go_start_res_id = $('#start_res_go').attr('startres_goid');
  883. // var go_end_res_name = $('#end_res_go').text();
  884. // var go_end_res_id = $('#end_res_go').attr('#endres_goid');
  885. // var backtime = $('#backtime').html();
  886. // var backPrice = $('#back_price').html();
  887. // var back_start_res_name = $('#start_res_back').text();
  888. // var back_start_res_id = $('#start_res_back').attr('startres_backid');
  889. // var back_end_res_name = $('#end_res_back').text();
  890. // var back_end_res_id = $('#end_res_back').attr('endres_backid');
  891. // var distance_back = $('#distance_back').html();
  892. // var usetime_back = $('#usetime_back').html();
  893. // var map_info1 = map_info;
  894. // var seat = $('#seat').html();
  895. // var single = $('#single').html();
  896. // var discount = $('#discount').html()
  897. //
  898. // var ticket_id_go1 = ticket_id_go;
  899. // var ticket_id_back1 = ticket_id_back;
  900. // var ticket_id_back_back1 = ticket_id_back_back;
  901. // var data = {
  902. // gotime : gotime,
  903. // goPrice : goPrice,
  904. // go_start_res_name : go_start_res_name,
  905. // go_start_res_id : go_start_res_id,
  906. // go_end_res_name : go_end_res_name,
  907. // go_end_res_id : go_end_res_id,
  908. // backtime : backtime,
  909. // backPrice : backPrice,
  910. // back_start_res_name : back_start_res_name,
  911. // back_start_res_id : back_start_res_id,
  912. // back_end_res_name : back_end_res_name,
  913. // back_end_res_id : back_end_res_id,
  914. // distance_back : distance_back,
  915. // usetime_back : usetime_back,
  916. // map_info : map_info1,
  917. // seat : seat,
  918. // single : single,
  919. // discount : discount,
  920. // ticket_id_go : ticket_id_go1,
  921. // ticket_id_back : ticket_id_back1,
  922. //// ticket_id_back_back : ticket_id_back_back1
  923. // }
  924. // setStorJson('CacheInfo_station',data);
  925. // }
  926. var gotime = $('#gotime').html();
  927. var goPrice = $('#go_price').html();
  928. var go_start_res_name = $('#start_res_go').text();
  929. var go_start_res_id = $('#start_res_go').attr('startres_goid');
  930. var go_end_res_name = $('#end_res_go').text();
  931. var go_end_res_id = $('#end_res_go').attr('#endres_goid');
  932. var backtime = $('#backtime').html();
  933. var backPrice = $('#back_price').html();
  934. var back_start_res_name = $('#start_res_back').text();
  935. var back_start_res_id = $('#start_res_back').attr('startres_backid');
  936. var back_end_res_name = $('#end_res_back').text();
  937. var back_end_res_id = $('#end_res_back').attr('endres_backid');
  938. var distance_back = $('#distance_back').html();
  939. var usetime_back = $('#usetime_back').html();
  940. var map_info1 = map_info;
  941. var seat = $('#seat').html();
  942. var single = $('#single').html();
  943. var discount = $('#discount').html()
  944. var ticket_id_go1 = ticket_id_go;
  945. var ticket_id_back1 = ticket_id_back;
  946. var ticket_id_back_back1 = ticket_id_back_back;
  947. var data = {
  948. gotime : gotime,
  949. goPrice : goPrice,
  950. go_start_res_name : go_start_res_name,
  951. go_start_res_id : go_start_res_id,
  952. go_end_res_name : go_end_res_name,
  953. go_end_res_id : go_end_res_id,
  954. backtime : backtime,
  955. backPrice : backPrice,
  956. back_start_res_name : back_start_res_name,
  957. back_start_res_id : back_start_res_id,
  958. back_end_res_name : back_end_res_name,
  959. back_end_res_id : back_end_res_id,
  960. distance_back : distance_back,
  961. usetime_back : usetime_back,
  962. map_info : map_info1,
  963. seat : seat,
  964. single : single,
  965. discount : discount,
  966. ticket_id_go : ticket_id_go1,
  967. ticket_id_back : ticket_id_back1,
  968. ticket_id_back_back : ticket_id_back_back1
  969. }
  970. setStorJson('CacheInfo_station',data);
  971. }
  972. //取消按钮的点击
  973. function cancelDidClicked(){
  974. $('#mask').click();
  975. }