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.

landmark_ticket.js 24 KiB

3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768
  1. var total_price = 0;
  2. var total_no = 1;
  3. var prod_Arr = [];
  4. var category_id = getStorage("category_id");
  5. var pro_cate_id = getStorage("pro_cate_id");
  6. var pro_cate_name = "";
  7. var run_date = after(getDateTime(0));
  8. var back_run_date = after(getDateTime(0));
  9. var go_year = getMonthAndDayByDate(run_date, 'year');
  10. var go_month = getMonthAndDayByDate(run_date, 'month');
  11. var go_day = getMonthAndDayByDate(run_date, 'day');
  12. var back_year = getMonthAndDayByDate(back_run_date, 'year');
  13. var back_month = getMonthAndDayByDate(back_run_date, 'month');
  14. var back_day = getMonthAndDayByDate(back_run_date, 'day');
  15. var car_id = "";
  16. var back_car_id = "";
  17. var go_back = "0";
  18. var run_date_list = [];
  19. var bus_stock = -1; //后台实时库存
  20. var back_station_prod = [];
  21. var back_prod_arr = [];
  22. var back_date_list = [];
  23. $(document).ready(function() {
  24. ifLogin(function(flag) {
  25. $('body').show();
  26. httpLoadInfo();
  27. });
  28. });
  29. function httpLoadInfo() {
  30. get_data();
  31. $("#go_run_date").text(go_month + "月" + go_day + "日");
  32. // $("#back_run_date").text(back_month + "月" + back_day + "日");
  33. $("#back_run_date").text('请选择');
  34. $("#go_sel_date").text(go_month + "月" + go_day + "日");
  35. $(".model").on("click", function() {
  36. $('.model_box').addClass('fadeInDown animated');
  37. setTimeout(function() {
  38. $('.model').hide();
  39. $('#body_mod').removeClass('mod_fil');
  40. }, 400);
  41. // $(".model_box").animate({
  42. // height: "hide"
  43. // }, 400, function() {
  44. // $(".model").hide();
  45. // $("#body_mod").removeClass("mod_fil");
  46. // });
  47. });
  48. $(".model_car").on("click", function() {
  49. $('.model_box_car').addClass('fadeInDown animated');
  50. setTimeout(function() {
  51. $('.model_car').hide();
  52. $('#body_mod').removeClass('mod_fil');
  53. }, 400);
  54. // $(".model_box_car").animate({
  55. // height: "hide"
  56. // }, 400, function() {
  57. // $(".model_car").hide();
  58. // $("#body_mod").removeClass("mod_fil");
  59. // });
  60. });
  61. $(".model_box").on("click", function(e) {
  62. e.stopPropagation();
  63. });
  64. $(".model_box_car").on("click", function(e) {
  65. e.stopPropagation();
  66. });
  67. }
  68. function get_data() {
  69. $.ajax({
  70. url: base_api + "prod/prod/get-prod-detail", //请求地址
  71. data: {
  72. pro_cate_id: pro_cate_id,
  73. category_id: category_id
  74. },
  75. type: "post",
  76. dataType: "json",
  77. async: false,
  78. success: function(data) {
  79. run_date_list = data.data.run_date;
  80. ZZLog(data);
  81. if(data.flag) {
  82. list_html(data.data);
  83. $("#bg_img").css("background-image", "url(" + data.data.show_img + ")");
  84. $(".top_title").text(data.data.pro_cate_name);
  85. pro_cate_name = data.data.pro_cate_name;
  86. } else {
  87. if(codeNotLogin == data['code']) {
  88. alert(infoNotLogin);
  89. var URL = '/web/fx/landmark_ticket.html';
  90. URL = encodeURI(URL);
  91. location.href = data['url'] + URL;
  92. } else if(codeNotRegister == res_data['code']) {
  93. location.href = 'register.html';
  94. } else {
  95. alert(data['msg']);
  96. }
  97. }
  98. },
  99. error: function(error) {
  100. console.log(error);
  101. }
  102. });
  103. }
  104. function list_html(data) {
  105. var temp = "";
  106. for(var i = 0, j = data.prod_arr.length; i < j; i++) {
  107. var img = 'images/jianhao.png';
  108. var str = '<span class="ulev3 count aticket" type="text" readonly="true" one_price="' + data.prod_arr[i].prod_price + '" prod_name="' + data.prod_arr[i].prod_name + '" prod_id="' + data.prod_arr[i].prod_id + '">0</span>';
  109. if(i == 0) {
  110. img = 'images/jianhao_sel.png';
  111. str = '<span class="ulev3 count aticket" type="text" readonly="true" one_price="' + data.prod_arr[i].prod_price + '" prod_name="' + data.prod_arr[i].prod_name + '" prod_id="' + data.prod_arr[i].prod_id + '">1</span>'
  112. }
  113. temp += '<div class="ub ub-ver disney_div">' +
  114. '<div style="padding-bottom: 0.12rem;">' + data.prod_arr[i].prod_name + '</div>' +
  115. '<div class="ub">' +
  116. '<div class="ub-f1 ub">' +
  117. '<img class="cut" style="width: 0.22rem;height: 0.22rem;vertical-align: middle;" src="' + img + '"/>' +
  118. str +
  119. // '<span class="ulev3 count aticket" type="text" readonly="true" one_price="' + data.prod_arr[i].prod_price + '" prod_name="' + data.prod_arr[i].prod_name + '" prod_id="' + data.prod_arr[i].prod_id + '">0</span>' +
  120. '<img class="add" style="width: 0.22rem;height: 0.22rem;vertical-align: middle;" src="images/jiahao_sel.png"/>' +
  121. '</div>' +
  122. '<div class="ub-f1 ub tx-r">' +
  123. '<div class="ub-f1 ub ub-pe ub-ae font_price" >¥</div>' +
  124. '<div class="ulev3 ub ub-ae font_price single_price" data-price="' + data.prod_arr[i].prod_price + '" style="line-height: 1;">' + data.prod_arr[i].prod_price + '<span class="font_price" style="font-size:0.12rem">/张</span></div>' +
  125. '</div>' +
  126. '</div>' +
  127. '</div>'
  128. }
  129. $("#tick_type").html(temp);
  130. //订票须知
  131. if(data.booking_notice) {
  132. var booking_notice_arr = data.booking_notice.split('<br/>');
  133. var bnHTML = '';
  134. for(var i = 0, m = booking_notice_arr.length; i < m; i++) {
  135. // bnHTML += `<div class="font_gray">${booking_notice_arr[i]}</div>`;
  136. bnHTML += '<div class="font_gray">' + booking_notice_arr[i] + '</div>';
  137. }
  138. $(".booking_notice").html(bnHTML);
  139. }
  140. //加
  141. $(".add").on("touchstart", function() {
  142. if(pro_cate_id == "3") {
  143. // var tot_no = 0;
  144. $(".aticket").each(function(index, domE) {
  145. total_no += parseInt($(this).text());
  146. });
  147. if(total_no == 5) {
  148. alert("迪士尼最多只能买五张票");
  149. } else {
  150. var current = $(this).parent().find(".aticket").text();
  151. var now_count = parseInt(current) + 1;
  152. $(this).parent().find(".aticket").text(now_count);
  153. $(this).parent().find(".cut").attr("src", "images/jianhao_sel.png");
  154. // countTotal();
  155. }
  156. } else {
  157. var current = $(this).parent().find(".aticket").text();
  158. var now_count = parseInt(current) + 1;
  159. $(this).parent().find(".aticket").text(now_count);
  160. $(this).parent().find(".cut").attr("src", "images/jianhao_sel.png");
  161. // countTotal();
  162. }
  163. });
  164. //减
  165. $(".cut").on("touchstart", function() {
  166. var current = $(this).parent().find(".aticket").text();
  167. var now_count = parseInt(current) - 1;
  168. if(now_count > 0) {
  169. $(this).parent().find(".aticket").text(now_count);
  170. } else {
  171. $(this).parent().find(".aticket").text('0');
  172. $(this).attr("src", "images/jianhao.png");
  173. }
  174. // countTotal();
  175. })
  176. }
  177. //总价
  178. function countTotal() {
  179. total_price = 0;
  180. prod_Arr = [];
  181. prod_info = "";
  182. total_no = 0;
  183. var tick_no = '';
  184. back_prod_arr = [];
  185. $(".aticket").each(function(index, domE) {
  186. tick_no = parseInt($(this).text());
  187. var tick_price = parseFloat($(this).attr("one_price"));
  188. var back_tick_price = 0;
  189. var back_prod_id = 0;
  190. var go_back = $("#if_back").attr("go_back");
  191. if(go_back == 1) {
  192. back_tick_price = back_station_prod[index]['prod_price'] - 0;
  193. back_prod_id = back_station_prod[index]['prod_id'];
  194. var obj = {
  195. "prod_id": back_prod_id,
  196. "prod_count": $(this).text(),
  197. "prod_name": $(this).attr('prod_name')
  198. }
  199. back_prod_arr.push(obj);
  200. }
  201. total_price = (total_price * 100 + tick_no * tick_price * 100) / 100;
  202. total_no += tick_no;
  203. prod_info = {
  204. "prod_id": $(this).attr("prod_id"),
  205. "prod_count": $(this).text(),
  206. "prod_name": $(this).attr("prod_name")
  207. }
  208. prod_Arr.push(prod_info);
  209. });
  210. // console.log(total_price);
  211. // console.log(prod_Arr);
  212. // console.log(total_no);
  213. }
  214. //选择去程日期
  215. $("#go_date_select").on("click", function() {
  216. $('.model_box').removeClass('fadeInUp');
  217. $('.model_box').removeClass('animated');
  218. $('.model_box').removeClass('fadeInDown');
  219. $("#go_sel_date").text(go_month + "月" + go_day + "日");
  220. var caType = window.calendar.init.showTypeEnum.show_customer;
  221. window.calendar.init({
  222. showType:caType,
  223. startDate: getDateTime(0),
  224. chooseDate: run_date,
  225. showDays:run_date_list
  226. }, function(year, month, day, ymdString) {
  227. $('.model_box').addClass('fadeInDown animated');
  228. setTimeout(function() {
  229. $('.model').hide();
  230. $('#body_mod').removeClass('mod_fil');
  231. }, 400);
  232. // $(".model_box").animate({
  233. // height: "hide"
  234. // }, 400, function() {
  235. // $(".model").hide();
  236. // $("#body_mod").removeClass("mod_fil");
  237. // });
  238. run_date = ymdString;
  239. go_year = year;
  240. go_month = month;
  241. go_day = day;
  242. if(run_date > back_run_date) {
  243. back_run_date = ymdString;
  244. back_year = year;
  245. back_month = month;
  246. back_day = day;
  247. // $("#back_run_date").text(month + "月" + day + "日");
  248. $("#back_run_date").text('请选择');
  249. $("#back_show_class").text("请选择");
  250. $("#back_show_class").removeAttr("back_time");
  251. $("#back_show_class").removeAttr("back_run_id");
  252. $("#back_show_class").removeAttr("back_cate_name");
  253. back_car_id = "";
  254. }
  255. $("#go_run_date").text(month + "月" + day + "日");
  256. $("#go_sel_date").text(month + "月" + day + "日");
  257. console.log(year, month, day, ymdString);
  258. // 2017 04 12 2017-04-12
  259. //重新选择日期后班次要重新选
  260. $("#go_show_class").text("请选择");
  261. $("#go_show_class").removeAttr("go_time");
  262. $("#go_show_class").removeAttr("go_run_id");
  263. $("#go_show_class").removeAttr("go_cate_name");
  264. car_id = "";
  265. });
  266. $(".model").show();
  267. $('.model_box').show();
  268. $("#body_mod").addClass("mod_fil");
  269. $('.model_box').addClass('fadeInUp animated');
  270. // $(".model_box").animate({
  271. // height: "show"
  272. // }, 400);
  273. });
  274. //选择去程班次
  275. $("#go_classes").on("click", function() {
  276. $('.model_box_car').removeClass('fadeInUp');
  277. $('.model_box_car').removeClass('animated');
  278. $('.model_box_car').removeClass('fadeInDown');
  279. $('#back_run_date').html('请选择');
  280. $.ajax({
  281. url: base_api + "prod/prod/get-bus-stock", //请求地址
  282. data: {
  283. pro_cate_id: pro_cate_id,
  284. date: run_date
  285. },
  286. type: "post",
  287. dataType: "json",
  288. async: false,
  289. success: function(data) {
  290. console.log(data)
  291. if(data.flag) {
  292. go_car_html(data.data);
  293. $(".model_car").show();
  294. $('.model_box_car').show();
  295. $("#body_mod").addClass("mod_fil");
  296. $('.model_box_car').addClass('fadeInUp animated');
  297. // $(".model_car").show();
  298. // $("#body_mod").addClass("mod_fil");
  299. // $(".model_box_car").animate({
  300. // height: "show"
  301. // }, 400);
  302. } else {
  303. if(codeNotLogin == data['code']) {
  304. alert(infoNotLogin);
  305. var URL = 'landmark_ticket.html';
  306. URL = encodeURI(URL);
  307. location.href = data['url'] + URL;
  308. } else {
  309. alert(data['msg']);
  310. }
  311. }
  312. },
  313. error: function(error) {
  314. console.log(error);
  315. }
  316. });
  317. });
  318. //替换去程班次信息
  319. function go_car_html(data) {
  320. var temp = "";
  321. var run_status = "";
  322. var run_count = "";
  323. for(var key in data.prod_info) {
  324. var prod_list = data.prod_info[key];
  325. var p_obj = prod_list[0];
  326. var may_sel = "";
  327. var may_info = "";
  328. var may_col = "";
  329. var select_car = "";
  330. run_status = p_obj.run_status;
  331. run_count = p_obj.count;
  332. if(run_status == 142) {
  333. may_sel = "select_kong";
  334. may_info = "已停运";
  335. may_col = "text_c_cc";
  336. select_car = "select_car_off";
  337. } else if(run_status != "138") {
  338. may_sel = "select_kong";
  339. may_info = "已发车";
  340. may_col = "text_c_cc";
  341. select_car = "select_car_off";
  342. } else {
  343. if(run_count == "0") {
  344. may_sel = "select_kong";
  345. may_info = "已售罄";
  346. may_col = "text_c_cc";
  347. select_car = "select_car_off";
  348. } else {
  349. may_sel = "select_quan";
  350. may_info = "余票充足";
  351. may_col = "text_c_80";
  352. select_car = "select_car_on";
  353. }
  354. }
  355. temp += '<div run_status = "' + p_obj.run_status + '" run_count = "' + run_count + '" cate_name="' + p_obj.station_str + '" id="' + p_obj.run_id + '" go_time="' + p_obj.start_time + '" class="ub ub-ac bor_b_e5 ' + select_car + '">' +
  356. '<div class="ui_p_t12 ui_p_b12 ui_p_l15 ui_p_r20 ulev1 ' + may_col + '">' + p_obj.start_time + '</div>' +
  357. '<div class="ub-f1 ' + may_col + '">' + may_info + '</div>' +
  358. '<div class="ui_p_r15 ui_p_t10 ui_p_b10 ui_p_l15">' +
  359. '<div class="' + may_sel + ' selected"></div>' +
  360. '</div>' +
  361. '</div>'
  362. }
  363. $("#sel_car").html(temp);
  364. if($("#" + car_id).attr("run_status") == "138" && $("#" + car_id).attr("run_count") != "0") {
  365. $("#" + car_id).find(".selected").removeClass("select_quan");
  366. $("#" + car_id).find(".selected").addClass("select_gou");
  367. }
  368. $(".select_car_on").on("click", function() {
  369. car_id = $(this).attr("id");
  370. //获取库存
  371. if(bus_stock==-1){
  372. bus_stock = $(this).attr('run_count')-0;
  373. }else{
  374. var t_stock = $(this).attr('run_count')-0;
  375. bus_stock = bus_stock>t_stock?t_stock:bus_stock;
  376. }
  377. var go_time = $(this).attr("go_time");
  378. var go_run_id = $(this).attr("id");
  379. var go_cate_name = $(this).attr("cate_name");
  380. $("#sel_car").find(".selected").removeClass("select_gou");
  381. $("#sel_car").find(".selected").addClass("select_quan");
  382. $(this).find(".selected").removeClass("select_quan");
  383. $(this).find(".selected").addClass("select_gou");
  384. $('.model_box_car').addClass('fadeInDown animated');
  385. setTimeout(function() {
  386. $('.model_car').hide();
  387. $('#body_mod').removeClass('mod_fil');
  388. }, 400);
  389. // $(".model_box_car").animate({
  390. // height: "hide"
  391. // }, 400, function() {
  392. // $(".model_car").hide();
  393. // $("#body_mod").removeClass("mod_fil");
  394. // });
  395. $("#go_show_class").text(go_time + "发车");
  396. $("#go_show_class").attr("go_time", go_time);
  397. $("#go_show_class").attr("go_run_id", go_run_id);
  398. $("#go_show_class").attr("go_cate_name", go_cate_name);
  399. });
  400. }
  401. //、、、、、、、、、、、、、、、、、、、、、去程结束、返程开始、、、、、、、、、、、、、、、、、、//
  402. //选择返程日期
  403. $("#back_date_select").on("click", function() {
  404. if($('#go_show_class').html() == '请选择'){
  405. alert('请选择去程班次');
  406. return;
  407. }
  408. $.ajax({
  409. url: base_api + "prod/prod/get-bus-sale-date", //请求地址
  410. data: {
  411. pro_cate_id: pro_cate_id,
  412. if_back: '1'
  413. },
  414. type: "post",
  415. dataType: "json",
  416. async: false,
  417. success: function(data) {
  418. ZZLog(data);
  419. if(data.flag) {
  420. back_date_list = data.data.list;
  421. } else {
  422. alert('未获取到后台数据');
  423. }
  424. },
  425. error: function(error) {
  426. alert('未获取到后台数据');
  427. }
  428. });
  429. $('.model_box').removeClass('fadeInUp');
  430. $('.model_box').removeClass('animated');
  431. $('.model_box').removeClass('fadeInDown');
  432. $("#go_sel_date").text(back_month + "月" + back_day + "日");
  433. var baType = window.calendar.init.showTypeEnum.show_customer;
  434. window.calendar.init({
  435. showType:baType,
  436. startDate: run_date,
  437. chooseDate: back_run_date,
  438. showDays:back_date_list
  439. }, function(year, month, day, ymdString) {
  440. $('.model_box').addClass('fadeInDown animated');
  441. setTimeout(function() {
  442. $('.model').hide();
  443. $('#body_mod').removeClass('mod_fil');
  444. }, 400);
  445. // $(".model_box").animate({
  446. // height: "hide"
  447. // }, 400, function() {
  448. // $(".model").hide();
  449. // $("#body_mod").removeClass("mod_fil");
  450. // });
  451. back_run_date = ymdString;
  452. back_year = year;
  453. back_month = month;
  454. back_day = day;
  455. if(run_date > back_run_date) {
  456. back_run_date = ymdString;
  457. $("#back_run_date").text(month + "月" + day + "日");
  458. }
  459. $("#back_run_date").text(month + "月" + day + "日");
  460. $("#go_sel_date").text(month + "月" + day + "日");
  461. $("#back_show_class").text("请选择");
  462. $("#back_show_class").removeAttr("back_time");
  463. $("#back_show_class").removeAttr("back_run_id");
  464. $("#back_show_class").removeAttr("back_cate_name");
  465. back_car_id = "";
  466. });
  467. $(".model").show();
  468. $('.model_box').show();
  469. $("#body_mod").addClass("mod_fil");
  470. $('.model_box').addClass('fadeInUp animated');
  471. // $(".model_box").animate({
  472. // height: "show"
  473. // }, 400);
  474. });
  475. //选择返程班次
  476. $("#back_classes").on("click", function() {
  477. if($('#go_show_class').html() == '请选择'){
  478. alert('请选择去程班次');
  479. return;
  480. }
  481. if($('#back_run_date').html() == '请选择'){
  482. alert('请选择返程日期');
  483. return;
  484. }
  485. $('.model_box_car').removeClass('fadeInUp');
  486. $('.model_box_car').removeClass('animated');
  487. $('.model_box_car').removeClass('fadeInDown');
  488. $.ajax({
  489. url: base_api + "prod/prod/get-bus-stock", //请求地址
  490. data: {
  491. pro_cate_id: pro_cate_id,
  492. date: back_run_date,
  493. if_back: "1"
  494. },
  495. type: "post",
  496. dataType: "json",
  497. async: false,
  498. success: function(data) {
  499. console.log(data)
  500. if(data.flag) {
  501. back_car_html(data.data);
  502. $(".model_car").show();
  503. $('.model_box_car').show();
  504. $("#body_mod").addClass("mod_fil");
  505. $('.model_box_car').addClass('fadeInUp animated');
  506. // $(".model_car").show();
  507. // $("#body_mod").addClass("mod_fil");
  508. // $(".model_box_car").animate({
  509. // height: "show"
  510. // }, 400);
  511. } else {
  512. if(codeNotLogin == data['code']) {
  513. alert(infoNotLogin);
  514. var URL = 'landmark_ticket.html';
  515. URL = encodeURI(URL);
  516. location.href = data['url'] + URL;
  517. } else {
  518. alert(data['msg']);
  519. }
  520. }
  521. },
  522. error: function(error) {
  523. console.log(error);
  524. }
  525. });
  526. });
  527. //替换返程班次信息
  528. function back_car_html(data) {
  529. var temp = "";
  530. var run_status = "";
  531. var run_count = "";
  532. for(var key in data.prod_info) {
  533. var prod_list = data.prod_info[key];
  534. var p_obj = prod_list[0];
  535. var may_sel = "";
  536. var may_info = "";
  537. var may_col = "";
  538. var select_car = "";
  539. run_status = p_obj.run_status;
  540. run_count = p_obj.count;
  541. if(run_status == 142) {
  542. may_sel = "select_kong";
  543. may_info = "已停运";
  544. may_col = "text_c_cc";
  545. select_car = "select_car_off";
  546. } else if(run_status != "138") {
  547. may_sel = "select_kong";
  548. may_info = "已发车";
  549. may_col = "text_c_cc";
  550. select_car = "select_car_off";
  551. } else {
  552. if(run_count == "0") {
  553. may_sel = "select_kong";
  554. may_info = "已售罄";
  555. may_col = "text_c_cc";
  556. select_car = "select_car_off";
  557. } else {
  558. may_sel = "select_quan";
  559. may_info = "余票充足";
  560. may_col = "text_c_80";
  561. select_car = "select_car_on";
  562. }
  563. }
  564. var obj = prod_list;
  565. obj.forEach(function(v, i) {
  566. v['station_str'] = v['station_str'].replace(/ /g, '');
  567. })
  568. temp += '<div dict=' + JSON.stringify(obj) + ' run_status = "' + p_obj.run_status + '" run_count = "' + run_count + '" cate_name="' + p_obj.station_str + '" id="' + p_obj.run_id + '" go_time="' + p_obj.start_time + '" class="ub ub-ac bor_b_e5 ' + select_car + '">' +
  569. '<div class="ui_p_t12 ui_p_b12 ui_p_l15 ui_p_r20 ulev1 ' + may_col + '">' + p_obj.start_time + '</div>' +
  570. '<div class="ub-f1 ' + may_col + '">' + may_info + '</div>' +
  571. '<div class="ui_p_r15 ui_p_t10 ui_p_b10 ui_p_l15">' +
  572. '<div class="' + may_sel + ' selected"></div>' +
  573. '</div>' +
  574. '</div>'
  575. }
  576. $("#sel_car").html(temp);
  577. if($("#" + back_car_id).attr("run_status") == "138" && $("#" + back_car_id).attr("run_count") != "0") {
  578. $("#" + back_car_id).find(".selected").removeClass("select_quan");
  579. $("#" + back_car_id).find(".selected").addClass("select_gou");
  580. }
  581. $(".select_car_on").on("click", function() {
  582. back_car_id = $(this).attr("id");
  583. //获取库存
  584. if(bus_stock==-1){
  585. bus_stock = $(this).attr('run_count')-0;
  586. }else{
  587. var t_stock = $(this).attr('run_count')-0;
  588. bus_stock = bus_stock>t_stock?t_stock:bus_stock;
  589. }
  590. var back_time = $(this).attr("go_time");
  591. var back_run_id = $(this).attr("id");
  592. var back_cate_name = $(this).attr("cate_name");
  593. //update 201705231337
  594. back_station_prod = $(this).attr('dict');
  595. back_station_prod = JSON.parse(back_station_prod);
  596. back_pro_cate_id = data.pro_cate_id;
  597. //选择班次的时候将返程的价格显示上去
  598. $('.single_price').each(function(index, dom) {
  599. var price = parseFloat($(this).attr('data-price')) - 0;
  600. var price_2 = (parseFloat(price) + parseFloat(back_station_prod[index]['prod_price'])) - 0;
  601. // $(this).attr('data-price', price_2); //false TODO选择返程的班次时更改票种的价格-现定义data-price为单程价格 注释后:始终存为去程的价格
  602. $(this).html(price_2 + '<span class="font_price" style="font-size:0.12rem">/张</span>');
  603. })
  604. $("#sel_car").find(".selected").removeClass("select_gou");
  605. $("#sel_car").find(".selected").addClass("select_quan");
  606. $(this).find(".selected").removeClass("select_quan");
  607. $(this).find(".selected").addClass("select_gou");
  608. $('.model_box_car').addClass('fadeInDown animated');
  609. setTimeout(function() {
  610. $('.model_car').hide();
  611. $('#body_mod').removeClass('mod_fil');
  612. }, 400);
  613. // $(".model_box_car").animate({
  614. // height: "hide"
  615. // }, 400, function() {
  616. // $(".model_car").hide();
  617. // $("#body_mod").removeClass("mod_fil");
  618. // });
  619. $("#back_show_class").text(back_time + "发车");
  620. $("#back_show_class").attr("back_time", back_time);
  621. $("#back_show_class").attr("back_run_id", back_run_id);
  622. $("#back_show_class").attr("back_cate_name", back_cate_name);
  623. });
  624. }
  625. function reserve() {
  626. countTotal();
  627. var go_time = $("#go_show_class").attr("go_time");
  628. var back_time = $("#back_show_class").attr("back_time");
  629. var go_run_id = $("#go_show_class").attr("go_run_id");
  630. var back_run_id = $("#back_show_class").attr("back_run_id");
  631. var go_cate_name = $("#go_show_class").attr("go_cate_name");
  632. var back_cate_name = $("#back_show_class").attr("back_cate_name");
  633. var fill_order_20170307 = "";
  634. go_back = $("#if_back").attr("go_back");
  635. if(total_no == "0") {
  636. alert("请选择票种数量");
  637. } else {
  638. if(bus_stock<total_no){
  639. alert('库存不足');
  640. return;
  641. }
  642. if(go_back == "0") {
  643. if(go_run_id) {
  644. fill_order_20170307 = {
  645. "pro_cate_id": pro_cate_id,
  646. "if_back": go_back, //只有去程 0 往返 1
  647. "prod_arr": prod_Arr,
  648. "total_money": total_price,
  649. "go_info": {
  650. "go_start_date": run_date,
  651. "go_start_time": go_time,
  652. "go_run_id": go_run_id,
  653. "go_pro_cate_name": go_cate_name
  654. },
  655. "back_info": {}
  656. }
  657. console.log(fill_order_20170307);
  658. setStorJson("fill_order_20170307", fill_order_20170307);
  659. window.location.href = "fill_order.html?" + version;
  660. } else {
  661. alert("请选择去程班次");
  662. }
  663. } else {
  664. //往返程票价必须一样,所以可以按*2算,白哥说的。
  665. if(go_run_id && back_run_id) {
  666. fill_order_20170307 = {
  667. "pro_cate_id": pro_cate_id,
  668. "back_pro_cate_id": back_pro_cate_id,
  669. "if_back": go_back, //只有去程 0 往返 1
  670. "prod_arr": prod_Arr,
  671. "back_prod_arr": back_prod_arr, //update 2017-05-23
  672. "total_money": total_price * 2,
  673. "go_info": {
  674. "go_start_date": run_date,
  675. "go_start_time": go_time,
  676. "go_run_id": go_run_id,
  677. "go_pro_cate_name": go_cate_name
  678. },
  679. "back_info": {
  680. "back_start_date": back_run_date,
  681. "back_start_time": back_time,
  682. "back_run_id": back_run_id,
  683. "back_pro_cate_name": back_cate_name
  684. }
  685. }
  686. console.log(fill_order_20170307);
  687. setStorJson("fill_order_20170307", fill_order_20170307);
  688. window.location.href = "fill_order.html?" + version;
  689. } else {
  690. alert("请选择班次");
  691. }
  692. }
  693. }
  694. }
  695. //添加或取消返程
  696. $(".sel_back_btn").on("click", function() {
  697. go_back = $(this).attr("go_back");
  698. if(go_back == "0") {
  699. $("#back_date").animate({
  700. height: "show"
  701. }, 200);
  702. $(this).attr("go_back", "1");
  703. $(this).text("取消返程");
  704. $(this).removeClass("sel_back_btn");
  705. $(this).addClass("cancel_back_btn");
  706. } else {
  707. if($('#back_show_class').text() != '请选择') {
  708. $('.single_price').each(function(index, dom) {
  709. var price = parseFloat($(this).attr('data-price')) + 0;
  710. // var price_2 = price / 2 + 0; //false
  711. var price_2 = price - 0; //true
  712. $(this).attr('data-price', price_2);
  713. $(this).html(price_2 + '<span class="font_price" style="font-size:0.12rem">/张</span>');
  714. })
  715. }
  716. $("#back_date").animate({
  717. height: "hide"
  718. }, 200);
  719. $(this).attr("go_back", "0");
  720. $(this).text("添加返程");
  721. $(this).removeClass("cancel_back_btn");
  722. $(this).addClass("sel_back_btn");
  723. $("#back_show_class").text("请选择");
  724. $("#back_show_class").removeAttr("go_time");
  725. back_car_id = "";
  726. }
  727. });