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.
 
 
 
 
 
 

885 lines
25 KiB

  1. //Author:zhangsq
  2. //Date:2016-11-17
  3. //Description:填写订单
  4. $("#loading_html").show();
  5. //全局参数 往返程run_id
  6. var run_id = getPar('run_id');
  7. var start_area_id = getPar('start_area_id');
  8. var end_area_id = getPar('end_area_id');
  9. //是否返程
  10. //var if_back = '0'; //0去程 1返程
  11. //去程--- 出发站点 目的站点数组
  12. var go_start_res_ary = '';
  13. var go_end_res_ary = '';
  14. //返程--- 触犯站点 目的站点数组
  15. //var back_start_res_ary = '';
  16. //var back_end_res_ary = '';
  17. //去程的优惠价格
  18. //var go_discount_price = '';
  19. ////返程的优惠价格
  20. //var back_discount_price = '';
  21. //去程的ticket_id
  22. var go_ticket_id = '';
  23. var stock = '';
  24. //返程的ticket_id
  25. //var back_ticket_id = '';
  26. //站点下弹框
  27. var resHTML = '';
  28. // 选中的上下车站点
  29. var selected_res_name = '';
  30. var selected_res_id = '';
  31. var selected_sel_id = '';
  32. //去程的run_date;
  33. var go_run_date = '';
  34. //var back_run_date = '';
  35. window.onload = function() {
  36. var airtype = getPar("air_type");
  37. if(airtype == "jie") {
  38. //接机
  39. $("#air_type_img").attr("src", "images/airport2x.png");
  40. $("#start_station_name").text("出发机场");
  41. $("#end_station_name").text("到达位置");
  42. } else {
  43. //送机
  44. $("#air_type_img").attr("src", "images/songji.png");
  45. $("#start_station_name").text("出发位置");
  46. $("#end_station_name").text("到达机场");
  47. }
  48. //站点html 下弹框
  49. resHTML = $('#wei_info').html();
  50. // var if_go = getPar('if_go');
  51. // if (if_go == 'go') {
  52. // $('#backinfo').hide();
  53. // if_back = '0';
  54. //加载去程的信息
  55. // reloadGoInfo();
  56. // } else{
  57. // if_back = '1';
  58. //加载信息
  59. reloadInfo();
  60. // }
  61. }
  62. //页面开始加载信息
  63. function reloadInfo() {
  64. var go_data = getStorage('CacheStationInfo_Go_Around');
  65. if(go_data) {
  66. //替换去程信息
  67. replaceInfo(go_data);
  68. var sel_station = getStorJson('CacheInfo_custmer_Around');
  69. if(sel_station) {
  70. //加载之前站点的选中信息
  71. // reloadHistoryStation(sel_station);
  72. $('#custmer').val(sel_station.custmer);
  73. $('#tel').val(sel_station.tel);
  74. $('.aticket').text(sel_station.count);
  75. }
  76. } else {
  77. //重新加载
  78. var urlstr = base_api + 'order/order/getRunDetail';
  79. var run_id = $('#goinfo').attr('run_id');
  80. if(!run_id) {
  81. run_id = getPar('run_id')
  82. }
  83. var data = {
  84. start_area_id: start_area_id,
  85. end_area_id: end_area_id,
  86. run_id: run_id
  87. }
  88. ZZLog(data);
  89. $.ajax({
  90. url: urlstr,
  91. data: data,
  92. async: false,
  93. type: 'post',
  94. dataType: 'json',
  95. success: function(data) {
  96. ZZLog(data);
  97. if(data.flag) {
  98. //替换去程数据
  99. var dataHTML = setJsonHtml(data.data);
  100. $('#goinfo').attr('data_str', dataHTML);
  101. replaceGoInfo(data.data);
  102. }
  103. },
  104. error: function(error) {
  105. ZZLog(error);
  106. }
  107. });
  108. }
  109. }
  110. //替换去程的数据
  111. function replaceGoInfo(data) {
  112. console.log(data);
  113. //替换时间信息
  114. $('#gotime').html(data.run_time);
  115. go_run_date = data.run_date;
  116. var year = getMonthAndDayByDate(go_run_date, 'year');
  117. var month = getMonthAndDayByDate(go_run_date, 'month');
  118. if(month < 10) {
  119. month = month.substring(1, month.length - 1);
  120. }
  121. var day = getMonthAndDayByDate(go_run_date, 'day');
  122. var showday = month + '月' + day + '日';
  123. $('#go_day').html(showday);
  124. //判断是否是今天
  125. if(go_run_date == getDateTime(0)) {
  126. $('#go_week').html('今天');
  127. } else {
  128. var str = year + '/' + month + '/' + day;
  129. var week = getWeekDay(str);
  130. $('#go_week').html(week);
  131. }
  132. //run_id
  133. $('#goinfo').attr('run_id', data.run_id);
  134. //替换选中站点信息
  135. var sel_start_info = data.select_start_res;
  136. var sel_end_info = data.select_end_res;
  137. //===站点信息
  138. $('#start_res_go').attr('startres_goid', sel_start_info.res_id);
  139. $('#start_res_go').html(sel_start_info.res_name + '(' + sel_start_info.res_time + ')');
  140. $('#end_res_go').attr('endres_goid', sel_end_info.res_id);
  141. $('#end_res_go').html(sel_end_info.res_name + '(' + sel_end_info.res_time + ')');
  142. //===poi信息
  143. $('#stare_area_id').html(data.start_area_name);
  144. $('#stare_area_id').attr('startarea_goid', data.start_area_id);
  145. $('#end_area_id').html(data.end_area_name);
  146. $('#end_area_id').attr('endarea_goid', data.end_area_id);
  147. //去程站点数据
  148. go_start_res_ary = data.start_res_arr;
  149. go_end_res_ary = data.end_res_arr;
  150. //替换票种 日程信息
  151. var ticket_info = data.ticket_info;
  152. $('#go_price').html(ticket_info.price);
  153. go_discount_price = ticket_info.discount_price;
  154. go_ticket_id = ticket_info.ticket_id;
  155. $('#distance_back').html('全程' + ticket_info.total_distance + '公里');
  156. $('#usetime_back').html('约' + ticket_info.total_time + '到达');
  157. $('#discount').html('选择往返有优惠');
  158. $('#goinfo').attr('discount_price', go_discount_price);
  159. $('#select_back').html('添加返程');
  160. $('#select_back').css('color', '#3d434f');
  161. //库存
  162. stock = ticket_info.stock > 20 ? 20 : ticket_info.stock;
  163. stock = stock > 0 ? stock : 0;
  164. // stock = "10";
  165. countTotal();
  166. }
  167. //去程上车站点的选择
  168. function goStartAreaDidClicked() {
  169. $("#mask").css("display", "block");
  170. $('#res_div').css("display", "block");
  171. sel_res_div = 'startres_goid';
  172. upDiv(go_start_res_ary, 'start_res_go', 'go');
  173. $("#weui_actionsheet").addClass("weui_actionsheet_toggle");
  174. }
  175. //切换去程的出发地站点信息
  176. function changeGoStartResInfo(id, time, name) {
  177. var start_res_id = $('#start_res_go').attr('startres_goid');
  178. var urlstr = base_api + 'order/order/getRunDetailByStart';
  179. var run_id = $('#goinfo').attr('run_id');
  180. var data = {
  181. start_res_id: start_res_id,
  182. end_area_id: end_area_id,
  183. run_id: run_id
  184. }
  185. $.ajax({
  186. url: urlstr,
  187. data: data,
  188. async: false,
  189. type: 'post',
  190. dataType: 'json',
  191. success: function(data) {
  192. ZZLog(data);
  193. if(data.flag) {
  194. //选择去程的出发站点,修改详情数据
  195. showDetailInfoByChangeStartRes(data.data);
  196. //替换 html json 数据
  197. var data_str = $('#goinfo').attr('data_str');
  198. data_str = getJsonHtml(data_str);
  199. data_str.ticket_info = data.data.ticket_info;
  200. data_str.end_res_arr = data.data.end_res_arr;
  201. data_str.select_end_res = data.data.select_end_res;
  202. data_str.select_start_res.res_id = id;
  203. data_str.select_start_res.res_time = time;
  204. data_str.select_start_res.res_name = name;
  205. var data_str = setJsonHtml(data_str);
  206. $('#goinfo').attr('data_str', data_str);
  207. }
  208. },
  209. error: function(error) {
  210. ZZLog(error);
  211. }
  212. });
  213. }
  214. //选择去程的出发站点,修改详情数据
  215. function showDetailInfoByChangeStartRes(data) {
  216. //替换选中站点信息
  217. var sel_end_info = data.select_end_res;
  218. //===站点信息
  219. $('#end_res_go').attr('endres_goid', sel_end_info.res_id);
  220. $('#end_res_go').html(sel_end_info.res_name + '(' + sel_end_info.res_time + ')');
  221. //去程站点数据
  222. go_end_res_ary = data.end_res_arr;
  223. //替换票种 日程信息
  224. var ticket_info = data.ticket_info;
  225. $('#go_price').html(ticket_info.price);
  226. go_discount_price = ticket_info.discount_price;
  227. go_ticket_id = ticket_info.ticket_id;
  228. $('#distance_back').html('全程' + ticket_info.total_distance + '公里');
  229. $('#usetime_back').html('约' + ticket_info.total_time + '到达');
  230. $('#discount').html('选择往返有优惠');
  231. $('#goinfo').attr('discount_price', go_discount_price);
  232. //库存
  233. stock = ticket_info.stock > stock ? stock : ticket_info.stock;
  234. stock = stock > 0 ? stock : 0;
  235. countTotal();
  236. }
  237. //去程下车站点的选择
  238. function goEndAreaDidClicked() {
  239. $("#mask").css("display", "block");
  240. $('#res_div').css("display", "block");
  241. sel_res_div = 'endres_goid';
  242. upDiv(go_end_res_ary, 'end_res_go', 'go');
  243. $("#weui_actionsheet").addClass("weui_actionsheet_toggle");
  244. }
  245. //切换去程的目的地站点信息
  246. function changeGoEndResInfo(id, time, name) {
  247. var start_res_id = $('#start_res_go').attr('startres_goid');
  248. var end_res_id = $('#end_res_go').attr('endres_goid');
  249. var urlstr = base_api + 'order/order/getRunDetailByEnd';
  250. var run_id = $('#goinfo').attr('run_id');
  251. var data = {
  252. start_res_id: start_res_id,
  253. end_res_id: end_res_id,
  254. run_id: run_id
  255. }
  256. $.ajax({
  257. url: urlstr,
  258. data: data,
  259. async: false,
  260. type: 'post',
  261. dataType: 'json',
  262. success: function(data) {
  263. ZZLog(data);
  264. if(data.flag) {
  265. //选择去程的目的站点,修改详情数据
  266. showDetailInfoByChangeEndRes(data.data);
  267. //替换 html json 数据
  268. var data_str = $('#goinfo').attr('data_str');
  269. data_str = getJsonHtml(data_str);
  270. data_str.ticket_info = data.data.ticket_info;
  271. data_str.select_end_res.res_id = id;
  272. data_str.select_end_res.res_name = name;
  273. data_str.select_end_res.res_time = time;
  274. var data_str = setJsonHtml(data_str);
  275. $('#goinfo').attr('data_str', data_str);
  276. }
  277. },
  278. error: function(error) {
  279. ZZLog(error);
  280. }
  281. });
  282. }
  283. //选择去程的目的站点,修改详情数据
  284. function showDetailInfoByChangeEndRes(data) {
  285. //替换票种 日程信息
  286. var ticket_info = data.ticket_info;
  287. $('#go_price').html(ticket_info.price);
  288. go_discount_price = ticket_info.discount_price;
  289. go_ticket_id = ticket_info.ticket_id;
  290. $('#distance_back').html('全程' + ticket_info.total_distance + '公里');
  291. $('#usetime_back').html('约' + ticket_info.total_time + '到达');
  292. $('#discount').html('选择往返有优惠');
  293. $('#goinfo').attr('discount_price', go_discount_price);
  294. //库存
  295. stock = ticket_info.stock > stock ? stock : ticket_info.stock;
  296. stock = stock > 0 ? stock : 0;
  297. countTotal();
  298. }
  299. //添加返程
  300. //function selectBackInfo(){
  301. //
  302. // if (if_back == '0') {
  303. // //缓存联系人信息
  304. // cacheTheCustomerInfo();
  305. // //缓存站点信息
  306. // cacheTheStationInfo();
  307. //
  308. // if_back = '1';
  309. // $('#select_back').html('取消返程');
  310. // $('#select_back').css('color','#999999');
  311. //
  312. //
  313. // window.location.href = './calendar.html?start_area_id='+end_area_id+'&end_area_id='+start_area_id+'&from=fill_order&if_go=go'+'&go_run_date='+go_run_date;
  314. // }else{
  315. // clearStorage('CacheStationInfo_Back');
  316. // if_back = '0';
  317. // $('#backinfo').hide();
  318. // $('#select_back').html('添加返程');
  319. // $('#select_back').css('color','#3d434f');
  320. //
  321. // }
  322. //
  323. //
  324. //
  325. //}
  326. //
  327. ////加载返程的信息
  328. //function reloadBackInfo(){
  329. // var back_data = getStorage('CacheStationInfo_Back');
  330. // if (back_data) {
  331. // //替换去程信息
  332. // replaceBackInfo(back_data);
  333. //
  334. // var sel_station = getStorJson('CacheInfo_station');
  335. // if (sel_station) {
  336. // //加载之前站点的选中信息
  337. //// reloadHistoryStation(sel_station);
  338. // $('#custmer').val(sel_station.custmer);
  339. // $('#tel').val(sel_station.tel);
  340. // $('.aticket').text(sel_station.count);
  341. // }
  342. // }else{
  343. //
  344. //
  345. // var urlstr = base_api + 'order/order/getRunDetail';
  346. // var data = {
  347. // start_area_id : start_area_id,
  348. // end_area_id : end_area_id,
  349. // run_id : run_id
  350. // }
  351. // $.ajax({
  352. // url : urlstr,
  353. // data : data,
  354. // async : false,
  355. // type : 'post',
  356. // dataType : 'json',
  357. // success : function(data){
  358. // if (data.flag) {
  359. // ZZLog(data);
  360. // var dataHTML = setJsonHtml(data.data);
  361. // $('#backinfo').attr('data_str',dataHTML);
  362. // //替换返程数据
  363. // replaceBackInfo(data.data);
  364. // }
  365. // },
  366. // error : function(error){
  367. // ZZLog(error);
  368. // }
  369. // });
  370. // }
  371. //}
  372. //
  373. ////替换返程数据
  374. //function replaceBackInfo(data){
  375. // //展示去程的数据
  376. // var go_info = getStorJson('CacheStationInfo_Go');
  377. // replaceGoInfo(go_info);
  378. // console.log(go_info);
  379. //
  380. // $('#backinfo').removeClass('ui_hide');
  381. //
  382. //// 替换时间信息
  383. // $('#backtime').html(data.run_time);
  384. // back_run_date = data.run_date;
  385. // var year = getMonthAndDayByDate(back_run_date,'year');
  386. // var month = getMonthAndDayByDate(back_run_date,'month');
  387. // if (month < 10) {
  388. // month = month.substring(1,month.length-1);
  389. // }
  390. // var day = getMonthAndDayByDate(back_run_date,'day');
  391. // var showday = month + '月' + day + '日';
  392. // $('#back_day').html(showday);
  393. // //判断是否是今天
  394. // if (back_run_date == getDateTime(0)) {
  395. // $('#back_week').html('今天');
  396. // }else{
  397. // var str = year + '/' + month + '/' + day;
  398. // var week = getWeekDay(str);
  399. // $('#back_week').html(week);
  400. // }
  401. //
  402. // //run_id_back
  403. // $('#backinfo').attr('run_id',data.run_id);
  404. //
  405. // //替换选中站点信息
  406. // var sel_start_info = data.select_start_res;
  407. // var sel_end_info = data.select_end_res;
  408. // //===站点信息
  409. // $('#start_res_back').attr('startres_backid',sel_start_info.res_id);
  410. // $('#start_res_back').html(sel_start_info.res_name+'('+sel_start_info.res_time+')');
  411. // $('#end_res_back').attr('endres_backid',sel_end_info.res_id);
  412. // $('#end_res_back').html(sel_end_info.res_name+'('+sel_end_info.res_time+')');
  413. // //===poi信息
  414. // $('#back_stare_area_id').html(data.start_area_name);
  415. // $('#back_stare_area_id').attr('startarea_backid',data.start_area_id);
  416. // $('#back_end_area_id').html(data.end_area_name);
  417. // $('#back_end_area_id').attr('endarea_backid',data.end_area_id);
  418. //
  419. // //返程站点数据
  420. // back_start_res_ary = data.start_res_arr;
  421. // back_end_res_ary = data.end_res_arr;
  422. //
  423. // //替换票种 日程信息
  424. // var ticket_info = data.ticket_info;
  425. // $('#back_price').html(parseInt(ticket_info.price)-parseInt(ticket_info.discount_price)-parseInt(go_discount_price));
  426. // back_discount_price = ticket_info.discount_price;
  427. // back_ticket_id = ticket_info.ticket_id;
  428. //
  429. //// $('#distance_back').html('全程'+ticket_info.total_distance+'公里');
  430. //// $('#usetime_back').html(ticket_info.total_time+'到达');
  431. // $('#discount').html('已优惠'+(parseInt(go_discount_price)+parseInt(back_discount_price))+'元/人');
  432. // $('#select_back').html('取消返程');
  433. // $('#select_back').css('color','#3d434f');
  434. // $('#backinfo').attr('discount_price',back_discount_price);
  435. //
  436. // //库存
  437. // stock = ticket_info.stock > stock ? stock : ticket_info.stock;
  438. // stock = stock > 0 ? stock : 0;
  439. // countTotal();
  440. //}
  441. //
  442. //
  443. ////返程上车站点的选择
  444. //function goStartAreaDidClickedBack(){
  445. // $("#mask").css("display","block");
  446. // $('#res_div').css("display","block");
  447. // sel_res_div = 'startres_backid';
  448. // upDiv(back_start_res_ary,'start_res_back','back');
  449. // $("#weui_actionsheet").addClass("weui_actionsheet_toggle");
  450. //
  451. //}
  452. //
  453. ////切换返程的出发地站点信息
  454. //function changeBackStartResInfo(id,time,name){
  455. // var start_res_id = $('#start_res_back').attr('startres_backid');
  456. // var urlstr = base_api + 'order/order/getRunDetailByStart';
  457. // var data = {
  458. // start_res_id : start_res_id,
  459. // end_area_id : end_area_id,
  460. // run_id : run_id
  461. // }
  462. // $.ajax({
  463. // url : urlstr,
  464. // data : data,
  465. // async : false,
  466. // type : 'post',
  467. // dataType : 'json',
  468. // success : function(data){
  469. // ZZLog(data);
  470. // if (data.flag) {
  471. // //选择返程的出发站点,修改详情数据
  472. // showDetailInfoByChangeStartResBack(data.data);
  473. // //替换 html json 数据
  474. // var data_str = $('#backinfo').attr('data_str');
  475. // data_str = getJsonHtml(data_str);
  476. // data_str.ticket_info = data.data.ticket_info;
  477. // data_str.end_res_arr = data.data.end_res_arr;
  478. //
  479. // data_str.select_end_res = data.data.select_end_res;
  480. //
  481. // data_str.select_start_res.res_id = id;
  482. // data_str.select_start_res.res_time = time;
  483. // data_str.select_start_res.res_name = name;
  484. //
  485. // var data_str = setJsonHtml(data_str);
  486. // $('#backinfo').attr('data_str',data_str);
  487. // }
  488. // },
  489. // error : function(error){
  490. // ZZLog(error);
  491. // }
  492. // });
  493. //}
  494. //
  495. //
  496. ////选择返程的出发站点,修改详情数据
  497. //function showDetailInfoByChangeStartResBack(data){
  498. //
  499. // //替换选中站点信息
  500. // var sel_end_info = data.select_end_res;
  501. // //===站点信息
  502. // $('#end_res_back').attr('endres_backid',sel_end_info.res_id);
  503. // $('#end_res_back').html(sel_end_info.res_name+'('+sel_end_info.res_time+')');
  504. // //去程站点数据
  505. // back_end_res_ary = data.end_res_arr;
  506. //
  507. // //替换票种 日程信息
  508. // var ticket_info = data.ticket_info;
  509. // $('#back_price').html(parseInt(ticket_info.price)-parseInt(ticket_info.discount_price)-parseInt(go_discount_price));
  510. // back_discount_price = ticket_info.discount_price;
  511. // back_ticket_id = ticket_info.ticket_id;
  512. //
  513. //// $('#distance_back').html('全程'+ticket_info.total_distance+'公里');
  514. //// $('#usetime_back').html(ticket_info.total_time+'到达');
  515. //// $('#discount').html('选择往返有优惠');
  516. // $('#discount').html('已优惠'+(parseInt(go_discount_price)+parseInt(back_discount_price))+'元/人');
  517. // $('#backinfo').attr('discount_price',back_discount_price);
  518. //
  519. // //库存
  520. // stock = ticket_info.stock > stock ? stock : ticket_info.stock;
  521. // stock = stock > 0 ? stock : 0;
  522. // countTotal();
  523. //
  524. //
  525. //}
  526. //
  527. //
  528. ////返程下车站点的选择
  529. //function goEndAreaDidClickedBack(){
  530. // $("#mask").css("display","block");
  531. // $('#res_div').css("display","block");
  532. // sel_res_div = 'endres_backid';
  533. // upDiv(back_end_res_ary,'end_res_back','back');
  534. // $("#weui_actionsheet").addClass("weui_actionsheet_toggle");
  535. //
  536. //}
  537. //
  538. ////切换返程的目的地站点信息
  539. //function changeBackEndResInfo(id,time,name){
  540. // var start_res_id = $('#start_res_back').attr('startres_backid');
  541. // var end_res_id = $('#end_res_back').attr('endres_backid');
  542. // var urlstr = base_api + 'order/order/getRunDetailByEnd';
  543. // var data = {
  544. // start_res_id : start_res_id,
  545. // end_res_id : end_res_id,
  546. // run_id : run_id
  547. // }
  548. // $.ajax({
  549. // url : urlstr,
  550. // data : data,
  551. // async : false,
  552. // type : 'post',
  553. // dataType : 'json',
  554. // success : function(data){
  555. // ZZLog(data);
  556. // if (data.flag) {
  557. // //选择去程的目的站点,修改详情数据
  558. // showDetailInfoByChangeEndResBack(data.data);
  559. //
  560. // //替换 html json 数据
  561. // var data_str = $('#backinfo').attr('data_str');
  562. // data_str = getJsonHtml(data_str);
  563. // data_str.ticket_info = data.data.ticket_info;
  564. //
  565. // data_str.select_end_res.res_id = id;
  566. // data_str.select_end_res.res_name = name;
  567. // data_str.select_end_res.res_time = time;
  568. //
  569. // var data_str = setJsonHtml(data_str);
  570. // $('#backinfo').attr('data_str',data_str);
  571. // }
  572. // },
  573. // error : function(error){
  574. // ZZLog(error);
  575. // }
  576. // });
  577. //}
  578. //
  579. ////选择返程的目的站点,修改详情数据
  580. //function showDetailInfoByChangeEndResBack(data){
  581. // //替换票种 日程信息
  582. // var ticket_info = data.ticket_info;
  583. // $('#back_price').html(parseInt(ticket_info.price)-parseInt(ticket_info.discount_price)-parseInt(go_discount_price));
  584. // back_discount_price = ticket_info.discount_price;
  585. // back_ticket_id = ticket_info.ticket_id;
  586. //
  587. //// $('#distance_back').html('全程'+ticket_info.total_distance+'公里');
  588. //// $('#usetime_back').html(ticket_info.total_time+'到达');
  589. //// $('#discount').html('选择往返有优惠');
  590. // $('#discount').html('已优惠'+(parseInt(go_discount_price)+parseInt(back_discount_price))+'元/人');
  591. // $('#backinfo').attr('discount_price',back_discount_price);
  592. //
  593. // //库存
  594. // stock = ticket_info.stock > stock ? stock : ticket_info.stock;
  595. // stock = stock > 0 ? stock : 0;
  596. // countTotal();
  597. //}
  598. //缓存联系人信息
  599. function cacheTheCustomerInfo() {
  600. var custmer = $('#custmer').val();
  601. var tel = $('#tel').val();
  602. var count = $('.aticket').text();
  603. var info_data = {
  604. custmer: custmer,
  605. tel: tel,
  606. count: count
  607. };
  608. setStorJson('CacheInfo_custmer_Around', info_data);
  609. }
  610. //缓存站点信息
  611. function cacheTheStationInfo() {
  612. // if (if_back == '0') {
  613. //去程
  614. var data_str = $('#goinfo').attr('data_str');
  615. data_str = getJsonHtml(data_str);
  616. setStorJson('CacheStationInfo_Go_Around', data_str);
  617. // }else{
  618. // //去程
  619. // var data_str = $('#goinfo').attr('data_str');
  620. // data_str = getJsonHtml(data_str);
  621. // setStorJson('CacheStationInfo_Go',data_str);
  622. //
  623. // //返程
  624. // var data_str_back = $('#backinfo').attr('data_str');
  625. // data_str_back = getJsonHtml(data_str_back);
  626. // setStorJson('CacheStationInfo_Back',data_str_back);
  627. // }
  628. }
  629. //提交订单
  630. function payBtnDidClicked() {
  631. delay(makeorder, 300);
  632. function makeorder() {
  633. var custmer = $('#custmer').val();
  634. var tel = $('#tel').val();
  635. var phoneRe = /^1[3|4|5|7|8]\d{9}$/;
  636. var custmer_count = $('.aticket').text();
  637. if(custmer == '' || tel == '') {
  638. alert('请填写联系人信息!')
  639. return;
  640. } else if(!phoneRe.test(tel)) {
  641. alert('请输入正确的手机号!')
  642. return;
  643. } else if(custmer_count == '0') {
  644. alert('请填写正确的票种数量!');
  645. return;
  646. }
  647. var customer_info = '{' + custmer + ',' + tel + ',' + " " + '}';
  648. var new_str = '';
  649. // if (if_back == '0') {
  650. var go_run_id = $('#goinfo').attr('run_id');
  651. var go_discount = $('#goinfo').attr('discount_price');
  652. var go_price = parseInt($('#go_price').html()) - parseInt(go_discount);
  653. new_str = '{1' + ',' + go_run_id + ',' + go_ticket_id + ',' + go_price + ',' + custmer_count + '}';
  654. // }else{
  655. // var go_run_id = $('#goinfo').attr('run_id');
  656. // var go_discount = $('#goinfo').attr('discount_price');
  657. // var go_price = parseInt($('#go_price').html())-parseInt(go_discount);
  658. // new_str = '{1'+','+go_run_id+','+go_ticket_id+','+go_price+','+custmer_count+'}';
  659. // var back_run_id = $('#backinfo').attr('run_id');
  660. // var back_discount = $('#backinfo').attr('discount_price');
  661. // var back_price = parseInt($('#back_price').html())-parseInt(back_discount);
  662. // new_str += '{2'+','+back_run_id+','+back_ticket_id+','+back_price+','+custmer_count+'}';
  663. // }
  664. $("#payBtn").removeAttr('onClick');
  665. $("#loadingToast").show();
  666. var data = {
  667. customer_info: customer_info,
  668. ticket_info: new_str
  669. };
  670. ZZLog(data);
  671. $.ajax({
  672. url: base_api + 'order/order/submitOrder',
  673. data: data,
  674. async: false,
  675. type: 'post',
  676. dataType: 'json',
  677. success: function(data) {
  678. if(data.flag) {
  679. $("#loadingToast").hide();
  680. $("#payBtn").attr('onClick', 'payBtnDidClicked();');
  681. clearStorage('pick_drop');
  682. window.location.href = data.url;
  683. } else {
  684. $("#loadingToast").hide();
  685. $("#payBtn").attr('onClick', 'payBtnDidClicked();');
  686. if (data.code != '10001') {
  687. alert(data.msg);
  688. } else{
  689. return;
  690. }
  691. }
  692. },
  693. error: function(error) {
  694. ZZLog(error);
  695. }
  696. });
  697. }
  698. }
  699. //上弹框的内容封装
  700. function upDiv(data, select_id, goBack) {
  701. var sel = $('#' + select_id).attr(sel_res_div);
  702. var html = '';
  703. for(var i = 0; i < data.length; i++) {
  704. var tempHTML = resHTML;
  705. tempHTML = tempHTML.replace('示例菜单', data[i].res_name);
  706. tempHTML = tempHTML.replace('[res_id]', data[i].res_id);
  707. tempHTML = tempHTML.replace('[showtime]', data[i].res_time);
  708. if(sel == data[i].res_id) {
  709. tempHTML = tempHTML.replace('images/a3/ic_select_nor.png', 'images/a3/ic_select_sel.png');
  710. } else {
  711. tempHTML = tempHTML.replace('images/a3/ic_select_nor.png', 'images/a3/ic_select_nor.png');
  712. }
  713. html += tempHTML;
  714. }
  715. $('#wei_info').html(html);
  716. $('#actionsheet_cancel').click(function() {
  717. $('#mask').click();
  718. })
  719. $('.weui_actionsheet_cell').parent().click(function() {
  720. console.log($(this).children().eq(0).attr('id'));
  721. selected_res_name = $(this).children().eq(0).text();
  722. selected_res_id = $(this).children().eq(0).attr('id');
  723. selected_sel_id = select_id;
  724. var seltime = $(this).children().eq(0).attr('showtime');
  725. $('#' + select_id).html($(this).children().eq(0).text() + '(' + seltime + ')');
  726. $('#' + select_id).attr(sel_res_div, $(this).children().eq(0).attr('id'));
  727. $('#mask').click();
  728. var id = $(this).children().eq(0).attr('id');
  729. var name = $(this).children().eq(0).text();
  730. var time = seltime;
  731. switch(select_id) {
  732. case 'start_res_go':
  733. //切换去程的出发地站点信息
  734. changeGoStartResInfo(id, time, name);
  735. break;
  736. case 'end_res_go':
  737. //切换去程的目的地站点信息
  738. changeGoEndResInfo(id, time, name);
  739. break;
  740. // case 'start_res_back':
  741. // //切换去程的出发地站点信息
  742. // changeBackStartResInfo(id,time,name);
  743. // break;
  744. // case 'end_res_back':
  745. // //切换去程的目的地站点信息
  746. // changeBackEndResInfo(id,time,name);
  747. // break;
  748. default:
  749. break;
  750. }
  751. })
  752. }
  753. //点击了蒙板
  754. $('#mask').click(function() {
  755. $("#mask").css("display", "none");
  756. $("#weui_actionsheet").removeClass("weui_actionsheet_toggle");
  757. // $('#res_div').hide();
  758. })
  759. //加
  760. $(".add").on("click", function() {
  761. var current = $('.aticket').text();
  762. var now_count = parseInt(current) + 1;
  763. if(now_count >= stock) {
  764. $('.aticket').text(stock);
  765. if(now_count > stock) {
  766. alert('没有更多的库存!')
  767. }
  768. $('.add').addClass('bor_right_c');
  769. $('.add').removeClass('bor_right');
  770. $('.cut').addClass('bor_left');
  771. $('.cut').removeClass('bor_left_c');
  772. } else {
  773. $('.aticket').text(now_count);
  774. $('.add').removeClass('bor_right_c');
  775. $('.add').addClass('bor_right');
  776. $('.cut').addClass('bor_left');
  777. $('.cut').removeClass('bor_left_c');
  778. }
  779. countTotal();
  780. });
  781. //减
  782. $(".cut").on("click", function() {
  783. var current = $('.aticket').text();
  784. var now_count = parseInt(current) - 1;
  785. if(now_count > 1 && now_count <= stock) {
  786. $('.aticket').text(now_count);
  787. $('.cut').addClass('bor_left');
  788. $('.cut').removeClass('bor_left_c');
  789. $('.add').removeClass('bor_right_c');
  790. $('.add').addClass('bor_right');
  791. } else {
  792. // alert('请选择正确的数量!');
  793. $('.aticket').text('1');
  794. $('.cut').removeClass('bor_left');
  795. $('.cut').addClass('bor_left_c');
  796. $('.add').removeClass('bor_right_c');
  797. $('.add').addClass('bor_right');
  798. }
  799. countTotal();
  800. })
  801. //计算价格信息
  802. function countTotal() {
  803. var count = $('.aticket').text();
  804. $('#total_people').html('共' + count + '人');
  805. var price = '';
  806. // if (if_back == '0') {
  807. price = parseInt($('#go_price').html());
  808. // }else{
  809. // price = parseInt($('#go_price').html())+parseInt($('#back_price').html());
  810. // }
  811. $('#count_price').html(count * price);
  812. }
  813. var delay = (function() {
  814. var timer = 0;
  815. return function(callback, time) {
  816. clearTimeout(timer);
  817. timer = setTimeout(callback, time);
  818. };
  819. })()