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.
 
 
 
 
 

253 lines
6.8 KiB

  1. //Author:zhangsq
  2. //Date:20160826
  3. //Description:查询结果
  4. var goinfoHTML = '';
  5. //记录去程时间
  6. var go_date = '';
  7. //去程的出发地站点数组
  8. var go_stares_ary = '';
  9. //去程的目的地站点数组
  10. var go_endres_ary = '';
  11. //记录map info
  12. var map_info = '';
  13. $(document).ready(function(){
  14. })
  15. window.onload = function(){
  16. //去程的html
  17. goinfoHTML = $('#goinfo').html();
  18. //加载去程的信息
  19. reloadGoInfo();
  20. }
  21. //页面开始 加载去程信息
  22. function reloadGoInfo(){
  23. var run_id = getPar('run_id');
  24. var start_area_id = getPar('start_area_id');
  25. var end_area_id = getPar('end_area_id');
  26. var start_res_id = getPar('start_res_id');
  27. var end_res_id = getPar('end_res_id');
  28. var url=base_api+"./zz_wxsct/control.php";
  29. var parm={
  30. type:"bus_detail_info_go",
  31. run_id:run_id,
  32. start_area_id:start_area_id,
  33. end_area_id:end_area_id,
  34. start_res_id:start_res_id,
  35. end_res_id:end_res_id
  36. }
  37. ZZLog(url+JSON.stringify(parm));
  38. $.post(url,parm,function(res_data){
  39. res_data=JSON.parse(res_data);
  40. ZZLog(res_data);
  41. if (res_data.code == 0) {
  42. // 替换去程信息
  43. replaceGoInfo(res_data);
  44. } else{
  45. alert(res_data.info);
  46. }
  47. });
  48. }
  49. //替换去程信息
  50. function replaceGoInfo(data){
  51. console.log(data);
  52. alert(data.list.bus_type)
  53. if (data.list.bus_type == '256'){
  54. $('#start_res').addClass('ui_hide');
  55. $('#end_res').addClass('ui_hide');
  56. }else{
  57. $('#start_res').removeClass('ui_hide');
  58. $('#end_res').removeClass('ui_hide');
  59. }
  60. var list = data.list;
  61. var temphtml = goinfoHTML;
  62. var nowdate = getDateTime(0);
  63. var selmonth = getMonthAndDayByDate(list.run_date,'month');
  64. var selday = getMonthAndDayByDate(list.run_date,'day');
  65. if (nowdate == list.run_date) {
  66. temphtml = temphtml.replace('[日期]',selmonth+'月'+selday+'日'+' &nbdp;今天');
  67. }else{
  68. temphtml = temphtml.replace('[日期]',selmonth+'月'+selday+'日');
  69. }
  70. temphtml = temphtml.replace('[去程时间]',list.start_time);
  71. temphtml = temphtml.replace('[出发地]',list.start_area_name);
  72. temphtml = temphtml.replace('[出发地站点]',list.start_res_name);
  73. temphtml = temphtml.replace('[目的地]',list.end_area_name);
  74. temphtml = temphtml.replace('[目的地站点]',list.end_res_name);
  75. temphtml = temphtml.replace('[日程]','全程'+list.distance+'公里');
  76. temphtml = temphtml.replace('[用时]',list.center_time);
  77. temphtml = temphtml.replace('[go_line_id]',list.line_id);
  78. temphtml = temphtml.replace('[go_ticket_id]',list.ticket.ticket_id_go);
  79. temphtml = temphtml.replace('[价格]',list.ticket.go_price);
  80. temphtml = temphtml.replace('[普通座]',list.ticket.site);
  81. temphtml = temphtml.replace('[单程]',list.ticket.ticket_id_go);
  82. if (list.ticket.discount_price == '0') {
  83. temphtml = temphtml.replace('[优惠]','无往返优惠');
  84. }else{
  85. temphtml = temphtml.replace('[优惠]','往返优惠'+list.ticket.discount_price+'元');
  86. }
  87. $('#goinfo').html(temphtml);
  88. //去程的出发地、目的地数组
  89. go_stares_ary = list.start_res_array;
  90. go_endres_ary = list.end_res_array;
  91. //记录地图信息
  92. map_info = list['map'];
  93. }
  94. //选择站点的下侧弹层
  95. $("#start_area").click(function(){
  96. $("#mask").css("display","block");
  97. $("#weui_actionsheet").addClass("weui_actionsheet_toggle");
  98. })
  99. $('#mask').click(function(){
  100. $("#mask").css("display","none");
  101. $("#weui_actionsheet").removeClass("weui_actionsheet_toggle");
  102. })
  103. //选择返程
  104. function selectBackInfo(){
  105. var go_ticket_id = $('#go_id_info').attr('go_ticket_id');
  106. var data = {
  107. back : 'back',
  108. go_date : go_date,
  109. go_ticket_id : go_ticket_id
  110. }
  111. setStorJson('goListInfo',data);
  112. window.location.href = './calendar.html?go_ticket_id='+go_ticket_id+'&go_date='+go_date+'&back=back'+'&from=fill_order';
  113. }
  114. //跳转地图
  115. function goToMapInfo(){
  116. setStorJson('goMapInfo',map_info);
  117. window.location.href = '';
  118. }
  119. //选择站点的下侧弹层
  120. $("#start_res_go").click(function(){
  121. // upDiv(start_station_list,'start_res_go','go');
  122. $("#mask").css("display","block");
  123. $("#weui_actionsheet").addClass("weui_actionsheet_toggle");
  124. })
  125. $("#end_res_go").click(function(){
  126. upDiv(end_station_list,'end_res_go','go');
  127. $("#mask").css("display","block");
  128. $("#weui_actionsheet").addClass("weui_actionsheet_toggle");
  129. })
  130. $('#mask').click(function(){
  131. $("#mask").css("display","none");
  132. $("#weui_actionsheet").removeClass("weui_actionsheet_toggle");
  133. })
  134. //上弹框的内容封装
  135. function upDiv(data,select_id,goBack){
  136. var html = '';
  137. for (var i = 0 ; i < data.length; i ++) {
  138. var tempHTML = wei_infoHTML;
  139. tempHTML = tempHTML.replace('示例菜单',data[i].name);
  140. tempHTML = tempHTML.replace('[id]',data[i].id);
  141. html += tempHTML;
  142. }
  143. $('#wei_info').html(html);
  144. $('.weui_actionsheet_cell').click(function(){
  145. if (this.innerHTML == '取消') {
  146. $('#mask').click();
  147. return ;
  148. }else{
  149. $('#'+select_id).html(this.innerHTML);
  150. $('#'+select_id).attr('valid',this.id);
  151. $('#mask').click();
  152. }
  153. if (goBack == 'go') {
  154. var start_id = $('#up_station_time').attr('valid');
  155. var end_id = $('#down_station_time').attr('valid');
  156. $.ajax({
  157. url:'./zz-fx/control.php',
  158. type: "post",
  159. data: {
  160. run_id:run_id,
  161. line_id:line_id,
  162. start_id:start_id,
  163. end_id:end_id,
  164. tickets:ticket,
  165. back:1,
  166. type:"retrieval_tickets"
  167. },
  168. dataType: "json",
  169. success: function (data) {
  170. if(data.code == 0){
  171. console.log(data);
  172. //替换去程票种数量信息
  173. showCountInfoByGo(data.list);
  174. }
  175. },
  176. fail: function (data) {
  177. // 此处放失败后执行的代码
  178. }
  179. });
  180. } else{
  181. var back_start_station_id = $('#back_up_station_time').attr('valid');
  182. var back_end_station_id = $('#back_down_station_time').attr('valid');
  183. $.ajax({
  184. url:'./zz-fx/control.php',
  185. type: "post",
  186. data: {
  187. run_id:back_run_id,
  188. line_id:back_line_id,
  189. start_id:back_start_station_id,
  190. end_id:back_end_station_id,
  191. tickets:back_ticket,
  192. back:2,
  193. type:"retrieval_tickets"
  194. },
  195. dataType: "json",
  196. success: function (data) {
  197. if(data.code == 0){
  198. console.log(data);
  199. //替换去程票种数量信息
  200. showCountInfoByBack(data.list);
  201. }
  202. },
  203. fail: function (data) {
  204. // 此处放失败后执行的代码
  205. }
  206. });
  207. }
  208. })
  209. }
  210. //截取日期参数
  211. function getMonthAndDayByDate(datestr,info){
  212. var dateAry = datestr.split('-');
  213. var cNewTimeStr;
  214. switch(info){
  215. case 'year':
  216. cNewTimeStr = dateAry[0];
  217. break;
  218. case 'month':
  219. cNewTimeStr = dateAry[1];
  220. break;
  221. default:
  222. cNewTimeStr = dateAry[2];
  223. break;
  224. }
  225. return cNewTimeStr;
  226. }