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.
 
 
 
 

267 rivejä
7.5 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 total_pirce = parseInt(Math.ceil(list_order.price));
  8. var geton_time = "";
  9. var getoff_time = "";
  10. var line_name = '';
  11. var str_id = getStorage('list_id');
  12. var run_id = getStorage('run_id');
  13. var ticket_id = '';
  14. var line_id = '';
  15. var start_station_ary = '';
  16. var end_station_ary = '';
  17. var wei_infoHTML = '';
  18. $(document).ready(function(){
  19. wei_infoHTML = $('#wei_info').html();
  20. goHTML = $('#go').html();
  21. reloadDate();
  22. });
  23. function reloadDate(){
  24. //zsq
  25. var data = {line_id:str_id,run_id:run_id};
  26. ZZLog(data);
  27. $.ajax({
  28. url:"http://wx.zhizhuchuxing.com/ZZDZ2/application/custom_made/order/get_station_info.php", //请求地址
  29. data:data,
  30. type: "post",
  31. dataType: "json",
  32. success: function (data) {
  33. console.log(data);
  34. if(data.code == 0){
  35. line_name = data.line_name;
  36. showInfo(data);
  37. }else{
  38. alert(data.info);
  39. }
  40. }
  41. });
  42. //zsq end
  43. // $("#geton_bus").click(function(){
  44. // people_num = $(".aticket").text();
  45. // people_name = $("#people_name").val();
  46. // people_phone = $("#people_phone").val();
  47. // setStorage("people_num",people_num);
  48. // setStorage("people_name",people_name);
  49. // setStorage("people_phone",people_phone);
  50. // get_bus = "0";
  51. // setStorage("get_bus",get_bus);
  52. // window.location.href="select_add.html";
  53. // });
  54. // $("#getoff_bus").click(function(){
  55. // people_num = $(".aticket").text();
  56. // people_name = $("#people_name").val();
  57. // people_phone = $("#people_phone").val();
  58. // setStorage("people_num",people_num);
  59. // setStorage("people_name",people_name);
  60. // setStorage("people_phone",people_phone);
  61. // get_bus = "1";
  62. // setStorage("get_bus",get_bus);
  63. // window.location.href="select_add.html";
  64. // });
  65. }
  66. function showInfo(data){
  67. var tempHTML = goHTML;
  68. tempHTML=tempHTML.replace('[时间]',data.time);
  69. tempHTML=tempHTML.replace('[线路]',data.line_name);
  70. var year = getMonthAndDayByDate(data.date,'year');
  71. var month = getMonthAndDayByDate(data.date,'month');
  72. var day = getMonthAndDayByDate(data.date,'day');
  73. var str = year+ '/' +month +'/'+day;
  74. var week = getWeekDay(str);
  75. var cur_date_m_d=getDateTime(0);
  76. start_station_ary = data.data_start;
  77. end_station_ary = data.data_end;
  78. tempHTML=tempHTML.replace('[9月24日]',month+'月'+day+'日');
  79. tempHTML=tempHTML.replace('[今天]',data.date==getDateTime(0)?'今天':week);
  80. tempHTML=tempHTML.replace('[南京]',data.start_area);
  81. tempHTML=tempHTML.replace('[南通]',data.end_area);
  82. tempHTML=tempHTML.replace('[59]',data.price);
  83. ticket_id = data.tic_id;
  84. run_id = data.run_id;
  85. line_id = data.line_id;
  86. $('#go').html(tempHTML);
  87. //加
  88. $(".add").on("click",function(){
  89. var num =parseInt($(this).siblings("span").text());
  90. if(num>=6){
  91. $(".add").removeClass("bor_right");
  92. $(".add").addClass("bor_right_c");
  93. var people_number = $(".aticket").text();
  94. total_pirce = parseInt(people_number)*parseInt(Math.ceil(list_order.price));
  95. $("#total").text(total_pirce);
  96. }else{
  97. var num = $(this).siblings("span").text();
  98. $(this).siblings("span").text(++num);
  99. $(".cut").removeClass("bor_left_c");
  100. $(".cut").addClass("bor_left");
  101. var people_number = $(".aticket").text();
  102. total_pirce = parseInt(people_number)*parseInt(Math.ceil(list_order.price));
  103. $("#total").text(total_pirce);
  104. }
  105. });
  106. //减
  107. $(".cut").on("click",function(){
  108. var num = parseInt($(this).siblings("span").text());
  109. if(num==2){
  110. $(".cut").removeClass("bor_left");
  111. $(".cut").addClass("bor_left_c");
  112. var people_number = $(".aticket").text();
  113. total_pirce = parseInt(people_number)*parseInt(Math.ceil(list_order.price));
  114. $("#total").text(total_pirce);
  115. }
  116. if(num==1){
  117. var people_number = $(".aticket").text();
  118. total_pirce = parseInt(people_number)*parseInt(Math.ceil(list_order.price));
  119. $("#total").text(total_pirce);
  120. }else{
  121. $(this).siblings("span").text(--num);
  122. $(".add").removeClass("bor_right_c");
  123. $(".add").addClass("bor_right");
  124. var people_number = $(".aticket").text();
  125. total_pirce = parseInt(people_number)*parseInt(Math.ceil(list_order.price));
  126. $("#total").text(total_pirce);
  127. }
  128. })
  129. //选择站点的下侧弹层
  130. $("#geton_bus").click(function(){
  131. upDiv(start_station_ary,'get_on','on_time');
  132. $("#mask").css("display","block");
  133. $('#actionSheet_wrap').show();
  134. $("#weui_actionsheet").addClass("weui_actionsheet_toggle");
  135. $('#sel_info').html('选择上车站点');
  136. })
  137. $("#getoff_bus").click(function(){
  138. upDiv(end_station_ary,'get_off','off_time');
  139. $("#mask").css("display","block");
  140. $("#weui_actionsheet").addClass("weui_actionsheet_toggle");
  141. $('#sel_info').html('选择下车站点');
  142. })
  143. $('#mask').click(function(){
  144. $("#mask").css("display","none");
  145. $("#weui_actionsheet").removeClass("weui_actionsheet_toggle");
  146. })
  147. $('#actionsheet_cancel').click(function(){
  148. $("#mask").css("display","none");
  149. $("#weui_actionsheet").removeClass("weui_actionsheet_toggle");
  150. })
  151. }
  152. function upDiv(data,sel_station,sel_time){
  153. var html = '';
  154. for (var i = 0 ; i < data.length; i ++) {
  155. var tempHTML = wei_infoHTML;
  156. tempHTML = tempHTML.replace('[站点名称]',data[i].name+'('+data[i].time+')');
  157. tempHTML = tempHTML.replace('[id]',data[i].id);
  158. tempHTML = tempHTML.replace('[name]',data[i].name);
  159. tempHTML = tempHTML.replace('[time]',data[i].time);
  160. html += tempHTML;
  161. }
  162. $('#wei_info').html(html);
  163. $(".weui_actionsheet_cell").click(function(){
  164. $('#'+sel_station).text($(this).attr('name'));
  165. $('#'+sel_station).css('color','#666666');
  166. $('#'+sel_station).attr('idstr',$(this).attr('id'));
  167. $('#'+sel_time).text($(this).attr('time'));
  168. $('#mask').click();
  169. });
  170. // var name = $(this).attr()
  171. // $('#'+sel_station).html(this.attr('name'));
  172. // $('#'+sel_time).html(this.attr('time'));
  173. }
  174. $("#submit").click(function(){
  175. var start_id = $('#get_on').attr('idstr');
  176. var end_id = $('#get_off').attr('idstr');
  177. var start_time = $('#on_time').text();
  178. var end_time = $('#off_time').text();
  179. var people_amount = $(".aticket").text();
  180. var people_sub_name = $("#people_name").val();
  181. var people_sub_phone = $("#people_phone").val();
  182. var phoneRe =/^1[3|4|5|7|8]\d{9}$/;
  183. var prod_list = '{m'+ticket_id+'p'+people_amount+'|r'+run_id+'}';
  184. var customer_info = '{,'+people_sub_name+',1,'+people_sub_phone+',150,,,0,,}';
  185. if (!start_id) {
  186. alert('请选择上车站点');
  187. return false;
  188. }
  189. if (!end_id) {
  190. alert('请选择下车站点');
  191. return false;
  192. }
  193. if(people_sub_name==""){
  194. alert("请输入姓名");
  195. return false;
  196. }
  197. if(people_sub_phone==""){
  198. alert("请输入手机号");
  199. return false;
  200. }
  201. if(!phoneRe.test(people_sub_phone)){
  202. alert("请输入正确的手机号");
  203. return false;
  204. }
  205. $("#loadingToast").show();
  206. var data = {
  207. type:"order_submit",
  208. prod_list:prod_list,
  209. customer_info:customer_info,
  210. start_time:start_time,
  211. end_time:end_time,
  212. line_id:line_id,
  213. start_id:start_id,
  214. end_id:end_id
  215. };
  216. ZZLog(data);
  217. $.ajax({
  218. url:base_api+"application/custom_made/control.php", //请求地址
  219. data:data,
  220. type: "post",
  221. dataType: "json",
  222. success: function (data) {
  223. $("#loadingToast").hide();
  224. console.log(data);
  225. if(data.code == "0"){
  226. window.location.href= data.info;
  227. }else if(data.code == "101"){
  228. window.location.href="order_success.html";
  229. }else{
  230. alert(data.info);
  231. }
  232. }
  233. });
  234. });