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.
 
 
 
 
 

273 lines
7.9 KiB

  1. var list_order = getStorJson("list_order");
  2. var get_bus = "";
  3. var people_num = $(".aticket").text();
  4. var people_name = $("#people_name").val();
  5. var people_phone = $("#people_phone").val();
  6. var goHTML = '';
  7. var year = getMonthAndDayByDate(list_order.run_date,'year');
  8. var month = getMonthAndDayByDate(list_order.run_date,'month');
  9. var day = getMonthAndDayByDate(list_order.run_date,'day');
  10. var str = year+ '/' +month +'/'+day;
  11. var week = getWeekDay(str);
  12. var cur_date_m_d=getDateTime(0);
  13. var total_pirce = parseInt(Math.ceil(list_order.price));
  14. var geton_time = "";
  15. var getoff_time = "";
  16. $(document).ready(function(){
  17. goHTML = $('#go').html();
  18. reloadDate();
  19. get_bus_inform();
  20. });
  21. function reloadDate(data){
  22. var tempHTML = goHTML;
  23. tempHTML=tempHTML.replace('[时间]',list_order.start_time);
  24. tempHTML=tempHTML.replace('[9月24日]',month+'月'+day+'日');
  25. tempHTML=tempHTML.replace('[今天]',list_order.run_date==getDateTime(0)?'今天':week);
  26. tempHTML=tempHTML.replace('[南京]',list_order.start_area);
  27. tempHTML=tempHTML.replace('[南通]',list_order.end_area);
  28. tempHTML=tempHTML.replace('[59]',Math.ceil(list_order.price));
  29. $('#go').html(tempHTML);
  30. //加
  31. $(".add").on("click",function(){
  32. var num =parseInt($(this).siblings("span").text());
  33. if(num>=6){
  34. $(".add").removeClass("bor_right");
  35. $(".add").addClass("bor_right_c");
  36. var people_number = $(".aticket").text();
  37. total_pirce = parseInt(people_number)*parseInt(Math.ceil(list_order.price));
  38. $("#total").text(total_pirce);
  39. }else{
  40. var num = $(this).siblings("span").text();
  41. $(this).siblings("span").text(++num);
  42. $(".cut").removeClass("bor_left_c");
  43. $(".cut").addClass("bor_left");
  44. var people_number = $(".aticket").text();
  45. total_pirce = parseInt(people_number)*parseInt(Math.ceil(list_order.price));
  46. $("#total").text(total_pirce);
  47. }
  48. });
  49. //减
  50. $(".cut").on("click",function(){
  51. var num = parseInt($(this).siblings("span").text());
  52. if(num==2){
  53. $(".cut").removeClass("bor_left");
  54. $(".cut").addClass("bor_left_c");
  55. var people_number = $(".aticket").text();
  56. total_pirce = parseInt(people_number)*parseInt(Math.ceil(list_order.price));
  57. $("#total").text(total_pirce);
  58. }
  59. if(num==1){
  60. var people_number = $(".aticket").text();
  61. total_pirce = parseInt(people_number)*parseInt(Math.ceil(list_order.price));
  62. $("#total").text(total_pirce);
  63. }else{
  64. $(this).siblings("span").text(--num);
  65. $(".add").removeClass("bor_right_c");
  66. $(".add").addClass("bor_right");
  67. var people_number = $(".aticket").text();
  68. total_pirce = parseInt(people_number)*parseInt(Math.ceil(list_order.price));
  69. $("#total").text(total_pirce);
  70. }
  71. })
  72. $("#geton_bus").click(function(){
  73. people_num = $(".aticket").text();
  74. people_name = $("#people_name").val();
  75. people_phone = $("#people_phone").val();
  76. setStorage("people_num",people_num);
  77. setStorage("people_name",people_name);
  78. setStorage("people_phone",people_phone);
  79. get_bus = "0";
  80. setStorage("get_bus",get_bus);
  81. window.location.href="select_add.html";
  82. });
  83. $("#getoff_bus").click(function(){
  84. people_num = $(".aticket").text();
  85. people_name = $("#people_name").val();
  86. people_phone = $("#people_phone").val();
  87. setStorage("people_num",people_num);
  88. setStorage("people_name",people_name);
  89. setStorage("people_phone",people_phone);
  90. get_bus = "1";
  91. setStorage("get_bus",get_bus);
  92. window.location.href="select_add.html";
  93. });
  94. }
  95. function get_bus_inform(){
  96. var geton_name = getStorage("geton_name");
  97. var geton_point = getStorage("geton_point");
  98. var getoff_name = getStorage("getoff_name");
  99. var getoff_point = getStorage("getoff_point");
  100. var get_people_num = getStorage("people_num");
  101. var get_people_name = getStorage("people_name");
  102. var get_people_phone = getStorage("people_phone");
  103. var people_amount = $(".aticket").text();
  104. var times = list_order.run_date+" "+list_order.start_time;
  105. if(get_people_num==null){
  106. $(".aticket").text("1");
  107. $("#total").text(total_pirce);
  108. }else{
  109. $(".aticket").text(get_people_num);
  110. $("#total").text(parseInt(get_people_num)*parseInt(Math.ceil(list_order.price)));
  111. }
  112. if(get_people_name==null){
  113. return;
  114. }else{
  115. $("#people_name").val(get_people_name);
  116. }
  117. if(get_people_phone==null){
  118. return;
  119. }else{
  120. $("#people_phone").val(get_people_phone);
  121. }
  122. if(geton_name==null){
  123. $("#get_on").text("选择上车地点");
  124. $("#get_on").css("color","#999");
  125. }else{
  126. $("#get_on").text(geton_name);
  127. $("#get_on").css("color","#333");
  128. }
  129. if(getoff_name==null){
  130. $("#get_off").text("选择下车地点");
  131. $("#get_off").css("color","#999");
  132. }else{
  133. $("#get_off").text(getoff_name);
  134. $("#get_off").css("color","#333");
  135. }
  136. //判断上下车时间
  137. if(geton_point!=null&&getoff_point!=null){
  138. // console.log("num:"+people_amount
  139. // +"&&&startx_y:"+geton_point
  140. // +"&&&endx_y:"+getoff_point
  141. // +"&&&prod_id:"+list_order.prod_id
  142. // +"&&&run_id:"+list_order.run_id
  143. // +"&&&run_date:"+times
  144. // );
  145. $.ajax({
  146. url:base_api+"application/api/get_time_by_location.php", //请求地址
  147. data:{
  148. num:people_amount,
  149. startx_y:geton_point,
  150. endx_y:getoff_point,
  151. prod_id:list_order.prod_id,
  152. run_id:list_order.run_id,
  153. run_date:times
  154. },
  155. type: "post",
  156. dataType: "json",
  157. success: function (data) {
  158. console.log(data);
  159. if(data.code == 0){
  160. geton_time = data.result[0];
  161. getoff_time = data.result[1];
  162. $("#on_time").text(data.str_time[0]);
  163. $("#off_time").text(data.str_time[1]);
  164. }else{
  165. alert(data.info);
  166. return false;
  167. }
  168. }
  169. });
  170. }
  171. }
  172. $("#submit").click(function(){
  173. var geton_name = getStorage("geton_name");
  174. var geton_point = getStorage("geton_point");
  175. var getoff_name = getStorage("getoff_name");
  176. var getoff_point = getStorage("getoff_point");
  177. var get_people_num = getStorage("people_num");
  178. var get_people_name = getStorage("people_name");
  179. var get_people_phone = getStorage("people_phone");
  180. var people_amount = $(".aticket").text();
  181. var people_sub_name = $("#people_name").val();
  182. var people_sub_phone = $("#people_phone").val();
  183. var phoneRe =/^1[3|4|5|7|8]\d{9}$/;
  184. var prod_list = '{m'+list_order.ticket_id+'p'+people_amount+'|r'+list_order.run_id+'}';
  185. var customer_info = '{,'+people_sub_name+',1,'+people_sub_phone+',150,,,0,,}';
  186. if(geton_time==null||geton_time==""){
  187. alert("所选地点不在规划范围内");
  188. return false;
  189. }
  190. if(geton_name==null){
  191. alert("请选择上车地");
  192. return false;
  193. }
  194. if(getoff_name==null){
  195. alert("请选择下车地");
  196. return false;
  197. }
  198. if(people_sub_name==""){
  199. alert("请输入姓名");
  200. return false;
  201. }
  202. if(people_sub_phone==""){
  203. alert("请输入手机号");
  204. return false;
  205. }
  206. if(!phoneRe.test(people_sub_phone)){
  207. alert("请输入正确的手机号");
  208. return false;
  209. }
  210. $("#loadingToast").show();
  211. $.ajax({
  212. url:base_api+"application/custom_made/control.php", //请求地址
  213. data:{
  214. type:"order_submit",
  215. prod_list:prod_list,
  216. customer_info:customer_info,
  217. startx_y:geton_point,
  218. start_name:geton_name,
  219. endx_y:getoff_point,
  220. end_name:getoff_name,
  221. start_time:geton_time,
  222. end_time:getoff_time,
  223. line_id:list_order.prod_id
  224. },
  225. type: "post",
  226. dataType: "json",
  227. success: function (data) {
  228. $("#loadingToast").hide();
  229. console.log(data);
  230. if(data.code == "0"){
  231. clearStorage("getoff_name");
  232. clearStorage("getoff_point");
  233. clearStorage("geton_name");
  234. clearStorage("geton_point");
  235. window.location.href= data.info;
  236. }else if(data.code == "101"){
  237. clearStorage("getoff_name");
  238. clearStorage("getoff_point");
  239. clearStorage("geton_name");
  240. clearStorage("geton_point");
  241. window.location.href="order_success.html";
  242. }else{
  243. clearStorage("getoff_name");
  244. clearStorage("getoff_point");
  245. clearStorage("geton_name");
  246. clearStorage("geton_point");
  247. alert(data.info);
  248. }
  249. }
  250. });
  251. });