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.
 
 
 
 

416 lines
10 KiB

  1. //记录选中的方式
  2. var select_style = 255;
  3. //记录迪士尼隐藏
  4. var ifhide_disney = 0;
  5. //记录出发地还是目的地
  6. var area_if = '';
  7. var login_data = getStorJson("login_data");
  8. var HTML = '';
  9. //出发地和目的地全局 保存之前用户输入的信息
  10. var data_start = '';
  11. var data_end = '';
  12. window.onload = function(){
  13. var start_data = getStorJson('start_data_str');
  14. var end_data = getStorJson('end_data_str');
  15. if (start_data != null) {
  16. $('#start_area').text(start_data.line);
  17. $('#start_area').attr('changeid',start_data.value);
  18. }
  19. if (end_data != null) {
  20. $('#end_area').text(end_data.line);
  21. $('#end_area').attr('changeid',end_data.value);
  22. }
  23. HTML = $('#disney_shuttle').html();
  24. if(login_data.login_type==1){
  25. $("#footer").hide();
  26. if(login_data.user_id==62 || login_data.user_id==148 || login_data.user_id==290)
  27. {
  28. $("#shuttle").hide();
  29. $("#disney").hide();
  30. $("#through").trigger("click");
  31. }else if(login_data.user_id==121 || login_data.user_id==141){
  32. $("#through").trigger("click");
  33. }else
  34. {
  35. $("#shuttle").trigger("click");
  36. }
  37. }else{
  38. $("#footer").show();
  39. }
  40. if( login_data.main_corp_id==4 ) {
  41. $("#disney").hide();
  42. }
  43. var day = getDateTime(11);
  44. $('#nowdate').html(day);
  45. $('#nowdate').attr('sendStr',getDateTime(0));
  46. var nowWeek = getWeekDay(getDateTime(10));
  47. $('#nowWeek').html(nowWeek);
  48. }
  49. //出发地查询
  50. function areaSearch(start_id){
  51. area_if = start_id;
  52. $('#search_area_all').val('');
  53. $('#search_info').addClass('ui_hide');
  54. $('#search_area_div').removeClass('ui_hide');
  55. //propertychange
  56. $('#search_area_all').focus();
  57. $('#search_area_all').bind('input onchange',function(){
  58. searchAreaInfo(area_if);
  59. });
  60. }
  61. //查询相关的信息
  62. function searchAreaInfo(search_id){
  63. if(search_id == 'start_area'){
  64. var inout_type = 'in';
  65. }else{
  66. var inout_type = 'out';
  67. }
  68. var area_name = $("#search_area_all").val();
  69. $.ajax({
  70. url:'./zz-fx/control.php',
  71. type: "post",
  72. data: {
  73. area_name:area_name,
  74. type:"retrieval_area",
  75. bus_type:select_style,
  76. inout_type:inout_type
  77. },
  78. dataType: "json",
  79. success: function (data) {
  80. console.log(data);
  81. if(data.code == 0){
  82. console.log(data);
  83. createHtml(data.list,search_id);
  84. $(".select_content").removeClass("ui_hide");
  85. }
  86. },
  87. fail: function (data) {
  88. }
  89. });
  90. }
  91. //筛选列表
  92. function createHtml(data,id){
  93. var temp ="";
  94. for (var i = 0; i < data.length; i++) {
  95. temp +='<div class="content_xiala ui_p_t10 ui_p_b10 ui_m_l15 ui_m_r15 ui_line_b bc-border" id="'+id+''+data[i].area_id+'" onmouseover="getDark(this.id)" onmouseout="getLight(this.id)" area_id="'+data[i].area_id+'">'+data[i].area_name+'</div>'
  96. }
  97. $(".select_content").html(temp);
  98. $(".content_xiala").click(function(){
  99. var line = $(this).text();
  100. var value = $(this).attr('area_id');
  101. $("#search_area_all").val(line);
  102. $(".select_content").addClass("ui_hide");
  103. //返回
  104. $('#search_info').removeClass('ui_hide');
  105. $('#search_area_div').addClass('ui_hide');
  106. $('#'+id).html(line);
  107. $("#"+id).attr('changeid',value);
  108. $('#'+id).removeClass('blackfont');
  109. if (id == 'start_area') {
  110. var start_data = {
  111. line : line,
  112. value : value
  113. }
  114. // data_start = start_data;
  115. setStorJson('start_data_str',start_data);
  116. }
  117. if(id == 'end_area'){
  118. var end_data = {
  119. line : line,
  120. value : value
  121. }
  122. // end_data = data_end;
  123. setStorJson('end_data_str',end_data)
  124. }
  125. })
  126. }
  127. function getDark(value,select_id){
  128. $('#'+value).addClass("get_dark");
  129. }
  130. function getLight(value){
  131. $('#'+value).removeClass("get_dark");
  132. }
  133. //交换出发地和目的地
  134. function changePosition(){
  135. //取值
  136. var strid = '';
  137. var strtext = '';
  138. var start_area_id = $('#start_area').attr('changeid');
  139. var start_area_text = $('#start_area').html();
  140. var end_area_id = $('#end_area').attr('changeid');
  141. var end_area_text = $('#end_area').html();
  142. //替换
  143. strid = start_area_id;
  144. start_area_id = end_area_id;
  145. end_area_id = strid;
  146. strtext = start_area_text;
  147. start_area_text = end_area_text;
  148. end_area_text = strtext;
  149. $('#start_area').attr('changeid',start_area_id);
  150. $('#start_area').html(start_area_text);
  151. $('#end_area').attr('changeid',end_area_id);
  152. $('#end_area').html(end_area_text);
  153. if ($('#start_area').html() == '输入出发地' || $('#start_area').html() == '输入目的地' ) {
  154. $('#start_area').addClass('blackfont');
  155. }else{
  156. $('#start_area').removeClass('blackfont');
  157. }
  158. if ($('#end_area').html() == '输入出发地' || $('#end_area').html() == '输入目的地') {
  159. $('#end_area').addClass('blackfont');
  160. }else{
  161. $('#end_area').removeClass('blackfont');
  162. }
  163. }
  164. //选择日期
  165. $(document).ready(function(){
  166. var tomonth = new Date();
  167. $(".sel_goback").on("click",function(){
  168. addmouth($(".month"),tomonth.getFullYear(),tomonth.getMonth());
  169. $(".month").show();
  170. $("#search_info").hide();
  171. selectDate();
  172. });
  173. })
  174. //选中日期
  175. function selectDate(){
  176. $(".canday").on("click",function(){
  177. if($(this).html()=="今天"){
  178. var seldate = new Date().getDate();
  179. }else{
  180. var seldate =$(this).html();
  181. }
  182. var yearmonth = $(".currentdate").html().split("年");
  183. if (yearmonth[1] != 10 && yearmonth[1] != 11 && yearmonth[1] != 12) {
  184. var show_yearmonth = '0'+yearmonth[1];
  185. }else{
  186. var show_yearmonth = yearmonth[1];
  187. }
  188. if (seldate<10) {
  189. var show_seldate = '0'+seldate;
  190. }else{
  191. var show_seldate = seldate;
  192. }
  193. //前台展示
  194. var thisdataStrShow = yearmonth[1]+'月'+seldate+'日';
  195. //后台传参
  196. var thisdataStrSend = yearmonth[0]+"-"+show_yearmonth+"-"+show_seldate;
  197. //获取星期
  198. var thisdata = yearmonth[0]+"/"+yearmonth[1]+"/"+seldate;
  199. var select_week = getWeekDay(thisdata);
  200. $("#nowdate").html(thisdataStrShow);
  201. $('#nowdate').attr('sendStr',thisdataStrSend);
  202. $('#nowWeek').html(select_week);
  203. $(".month").hide();
  204. $("#search_info").show();
  205. })
  206. }
  207. //选择方式
  208. function selectStyle(value){
  209. switch(value){
  210. case 255:
  211. select_style = 255;
  212. $('#select_style').children().removeClass('bc-bg');
  213. $("#through").addClass('bc-bg')
  214. $('#disney_shuttle').addClass('ui_hide');
  215. reloadTroughInfo();
  216. break;
  217. case 256:
  218. select_style = 256;
  219. $('#select_style').children().removeClass('bc-bg');
  220. $("#shuttle").addClass('bc-bg');
  221. reloadDisneyInfo();
  222. break;
  223. default:
  224. select_style = 257;
  225. $("#mask").removeClass('ui_hide');
  226. $('#select_style').children().removeClass('bc-bg');
  227. $('#disney_shuttle').addClass('ui_hide');
  228. $("#disney").addClass('bc-bg')
  229. if (ifhide_disney == 0) {
  230. $('#hide_disney').removeClass('ui_hide');
  231. ifhide_disney = 1;
  232. }else{
  233. $('#hide_disney').addClass('ui_hide');
  234. ifhide_disney = 0;
  235. }
  236. }
  237. }
  238. //展示直通车的数据
  239. function reloadTroughInfo(){
  240. $.ajax({
  241. url:'./zz-fx/control.php', //请求地址
  242. data:{type:'distribut_recommendThrough'},
  243. type: "post", //请求方式
  244. async:false,
  245. dataType: "json",
  246. success: function (data) {
  247. if(data.code == 0){
  248. console.log(data);
  249. var list = data.list;
  250. var newHTML='';
  251. for(var i=0;i<list.length;i++){
  252. var tempHTML=HTML;
  253. tempHTML=tempHTML.replace('[出发地]',list[i].up_station_name);
  254. tempHTML=tempHTML.replace('[start_attrid]',list[i].up_station);
  255. tempHTML=tempHTML.replace('[end_attrid]',list[i].down_station);
  256. tempHTML=tempHTML.replace('[目的地]',list[i].down_station_name);
  257. tempHTML=tempHTML.replace('[i]',i);
  258. tempHTML=tempHTML.replace('[disney_start]','disney_start'+i);
  259. tempHTML=tempHTML.replace('[disney_end]','disney_end'+i);
  260. newHTML+=tempHTML;
  261. }
  262. $('#disney_shuttle').html(newHTML);
  263. $('#disney_shuttle').removeClass('ui_hide');
  264. }else{
  265. $('#disney_shuttle').addClass('ui_hide');
  266. }
  267. },
  268. fail: function (date) {
  269. }
  270. });
  271. }
  272. //展示穿梭车的数据
  273. function reloadDisneyInfo(){
  274. $.ajax({
  275. url:'./zz-fx/Model/distribut/hotel_through.php', //请求地址
  276. type: "post", //请求方式
  277. async:false,
  278. dataType: "json",
  279. success: function (data) {
  280. if(data.code == 0){
  281. console.log(data);
  282. var list = data.list;
  283. var newHTML='';
  284. for(var i=0;i<list.length;i++){
  285. var tempHTML=HTML;
  286. tempHTML=tempHTML.replace('[出发地]',list[i].up_station_name);
  287. tempHTML=tempHTML.replace('[start_attrid]',list[i].up_station);
  288. tempHTML=tempHTML.replace('[end_attrid]',list[i].down_station);
  289. tempHTML=tempHTML.replace('[目的地]',list[i].down_station_name);
  290. tempHTML=tempHTML.replace('[i]',i);
  291. tempHTML=tempHTML.replace('[disney_start]','disney_start'+i);
  292. tempHTML=tempHTML.replace('[disney_end]','disney_end'+i);
  293. newHTML+=tempHTML;
  294. }
  295. $('#disney_shuttle').html(newHTML);
  296. $('#disney_shuttle').removeClass('ui_hide');
  297. }else{
  298. $('#disney_shuttle').addClass('ui_hide');
  299. }
  300. },
  301. fail: function (date) {
  302. }
  303. });
  304. }
  305. //选择穿梭信息
  306. function selectDisneyInfo(id){
  307. var start_attrid = $('#disney_start'+id).attr('attrid');
  308. var start_area_name = $('#disney_start'+id).html();
  309. var end_attrid = $('#disney_end'+id).attr('attrid');
  310. var end_area_name = $('#disney_end'+id).html();
  311. $('#start_area').attr('changeid',start_attrid);
  312. $('#start_area').html(start_area_name);
  313. $('#end_area').attr('changeid',end_attrid);
  314. $('#end_area').html(end_area_name);
  315. $('#start_area').removeClass('blackfont');
  316. $('#end_area').removeClass('blackfont');
  317. }
  318. $('#mask').click(function(){
  319. $("#mask").addClass("ui_hide");
  320. $('#hide_disney').addClass('ui_hide');
  321. ifhide_disney = 0;
  322. })
  323. //$("#hide_disney").click(function(e){
  324. // e.stopPropagation();
  325. // $("#hide_disney").removeClass("ui_hide");
  326. // $("#hide_disney").addClass("ui_hide");
  327. //});
  328. //查询按钮
  329. function searchBtnDidClicked(){
  330. var startId = $('#start_area').attr('changeid');
  331. var endId = $('#end_area').attr('changeid');
  332. var dataStr = $('#nowdate').attr('sendstr');
  333. var styleStr = select_style;
  334. var dateStr = $('#nowdate').html();
  335. var data = {
  336. start_area : startId,
  337. end_area : endId,
  338. go_time : dataStr,
  339. bus_type : styleStr,
  340. type:"retrieval_through",
  341. run_type:0,
  342. currpage:1,
  343. pagesize:10000
  344. }
  345. setStorJson('searchData',data);
  346. setStorage('sendDate',dateStr);
  347. window.location.href = './search_result.html';
  348. }
  349. //search页面的后退按钮
  350. function returnMain(){
  351. $('#search_area_div').addClass('ui_hide');
  352. $('#search_info').removeClass('ui_hide');
  353. }
  354. //删除input的内容
  355. function delInput(){
  356. $('#search_area_all').val('');
  357. }