//Author:fuhc
//Date:20160825
$("#loading_html").show();
//Description:热门城市
var key_word = "";
var area_type = "all";
var type_null = "";
//线路类型
var line_type = getPar("line_type");
var poi_type = getPar("poi_type");
var poi_name = "";
var inout_type = getPar("op_type");
var station_id = getPar("station_id");
var from = getPar("from");
//页面加载
window.onload = function() {
var param1 = {
line_type: line_type,
poi_type: poi_type,
poi_name: poi_name,
inout_type: inout_type,
station_id: station_id
}
ZZLog(base_api + "base/getStation&" + JSON.stringify(param1));
$.ajax({
type: "post",
url: base_api + "base/getStation",
data: param1,
async: false,
dataType: 'json',
success: function(res_data) {
ZZLog(res_data);
if(res_data.flag == true) {
base_html(res_data.data);
} else {
alert(res_data.mag);
}
},
error: function(e) {
ZZLog(e);
}
});
// eg:打字太快 如黄
// 黄的数据先出来,拼音的后出来就没有显示
function base_html(data) {
var temp = "";
if(data.length == 1) {
$("#shaixuan").html("");
$(".remove_height").css("height","0.6rem");
$("#shaixuan").removeClass("outer_line_down_color");
poi_type = data[0].type_id;
} else {
for(var i = 0; i < data.length; i++) {
if(i == 0) {
poi_type = data[i].type_id;
temp += '
' +
'
' + data[i].type_name + '
' +
'
' +
'
'
} else {
temp += '' +
'
' + data[i].type_name + '
' +
'
' +
'
'
}
}
$("#shaixuan").html(temp);
}
if(inout_type=="in"&&poi_type=="0"){
$("#hot1").show();
$("#hot2").show();
}else{
$("#hot1").hide();
$("#hot2").hide();
}
//头部切换
$(".selected").click(function() {
poi_type = $(this).attr("select_type");
console.log(poi_type);
$("#shaixuan").find(".select_div").removeClass("select_color");
$("#shaixuan").find(".select_div").addClass("unselect_color");
$("#shaixuan").find(".select_span").removeClass("select_border");
$("#shaixuan").find(".select_span").addClass("unselect_border");
$(this).find(".select_div").removeClass("unselect_color");
$(this).find(".select_div").addClass("select_color");
$(this).find(".select_span").removeClass("unselect_border");
$(this).find(".select_span").addClass("select_border");
if(poi_type=="0"&&inout_type=="in"){
$("#hot1").show();
$("#hot2").show();
}else{
$("#hot1").hide();
$("#hot2").hide();
}
var param2 = {
line_type: line_type,
poi_type: poi_type,
poi_name: poi_name,
inout_type: inout_type,
station_id: station_id
}
ZZLog(JSON.stringify(param2));
$.post(base_api + "base/getStation", param2, function(res_data) {
res_data = JSON.parse(res_data);
ZZLog(res_data);
//将下拉列表展示出来
$(".select_content").css('z-index', '5');
var list = res_data['data'];
var letter_text = "";
var all_html = "";
var right_html = "";
var HTML = "";
var LetterBox=$('#letter');
var Initials=$('.initials');
for(var key in list){
letter_text = ''+key+'
';
right_html += ''+key+''
HTML = "";
for(var i=0;i' +
'' + list[key][i].area_name + '
' +
''
}
all_html += letter_text + HTML;
}
$(".select_content").html(all_html);
$("#right_letter").html(right_html);
$(".initials ul li").on("mouseover",function(){
var _this=$(this);
var LetterHtml=_this.html();
LetterBox.html(LetterHtml).fadeIn();
// Initials.css('background','rgba(145,145,145,0.6)');
setTimeout(function(){
// Initials.css('background','rgba(145,145,145,0)');
LetterBox.fadeOut();
},1000);
var _index = _this.index()
if(_index==0){
$('html,body').animate({scrollTop: '0px'}, 300);//点击第一个滚到顶部
}else{
var letter = _this.text();
if($('#'+letter).length>0){
var LetterTop = $('#'+letter).position().top;
$('html,body').animate({scrollTop: parseInt(LetterTop+80)+'px'}, 300);
}
}
})
});
})
var param2 = {
line_type: line_type,
poi_type: poi_type,
poi_name: poi_name,
inout_type: inout_type,
station_id: station_id
}
ZZLog(JSON.stringify(param2));
$.post(base_api + "base/getStation", param2, function(res_data) {
res_data = JSON.parse(res_data);
ZZLog(res_data);
//将下拉列表展示出来
$(".select_content").css('z-index', '5');
var list = res_data['data'];
var HTML = "";
var right_html = "";
var letter_text = "";
var all_html = "";
var LetterBox=$('#letter');
var Initials=$('.initials');
for(var key in list){
letter_text = ''+key+'
';
right_html += ''+key+''
HTML = "";
for(var i=0;i' +
'' + list[key][i].area_name + '
' +
''
}
all_html += letter_text + HTML;
}
$(".select_content").html(all_html);
$("#right_letter").html(right_html);
$(".initials ul li").on("mouseover",function(){
var _this=$(this);
var LetterHtml=_this.html();
LetterBox.html(LetterHtml).fadeIn();
// Initials.css('background','rgba(145,145,145,0.6)');
setTimeout(function(){
// Initials.css('background','rgba(145,145,145,0)');
LetterBox.fadeOut();
},1000);
var _index = _this.index()
if(_index==0){
$('html,body').animate({scrollTop: '0px'}, 300);//点击第一个滚到顶部
}else{
var letter = _this.text();
if($('#'+letter).length>0){
var LetterTop = $('#'+letter).position().top;
$('html,body').animate({scrollTop: parseInt(LetterTop+80)+'px'}, 300);
}
}
})
});
}
$('#key_word').on('input', function(e) {
$("#btn_cancel").css("color", "#0076ff");
key_word = $(this).val();
var url = base_api + "base/getStation";
if(getPar('poi_type')=='7+') {
var parm = {
line_type: line_type,
poi_type: 7,
poi_name: key_word,
inout_type: inout_type,
station_id: station_id
};
} else {
var parm = {
line_type: line_type,
poi_type: 0,
poi_name: key_word,
inout_type: inout_type,
station_id: station_id
};
}
ZZLog(url + JSON.stringify(parm));
$.post(url, parm, function(res_data) {
res_data = JSON.parse(res_data);
ZZLog(res_data);
if(res_data.flag != true) {
alert(res_data["msg"]);
return;
}
//将下拉列表展示出来
$(".select_xiala").css('z-index', '999');
var list = res_data['data'];
var HTML = "";
for(var key in list){
for(var i=0;i' + list[key][i].area_name + ''
}
}
$(".select_xiala").html(HTML);
$(".select_content").hide();
});
});
//取消
$('#btn_cancel').on('click', function(e) {
$('#key_word').val('');
$(".select_xiala").css('z-index', '-1');
$(".select_xiala").html('');
$("#btn_cancel").css("color", "#FFF");
$(".select_content").show();
});
}
function click_select_area(self_id) {
if(from == "disney_tranship") {
var self_obj = $('#' + self_id);
var area_name = self_obj.attr('area_name');
var area_id = self_obj.attr('area_id');
var type = self_obj.attr('type');
var temp_data = getStorJson('disney_tranship');
if(temp_data.where_disney == 1) {
//迪士尼在下面
temp_data.up_name = area_name;
temp_data.up_id = area_id;
setStorJson("disney_tranship", temp_data);
window.location.href = "disney_tranship.html";
} else {
//迪士尼在上面
temp_data.down_name = area_name;
temp_data.down_id = area_id;
setStorJson("disney_tranship", temp_data);
window.location.href = "disney_tranship.html";
}
} else if(from == "pick_drop_person") {
var self_obj = $('#' + self_id);
var area_name = self_obj.attr('area_name');
var area_id = self_obj.attr('area_id');
var data = getStorJson('pick_drop'); //拿到缓存
var type = getStorJson('type'); //接机还是送机
var are_type = getPar('area_type'); //判断是查站点还是机场
if(are_type == 'airport') {
data.airprot_name = area_name;
data.airprot_id = area_id;
} else {
data.place_name = area_name;
data.place_id = area_id;
}
setStorJson('pick_drop', data);
window.location.href = "pick_drop_person.html";
} else {
var self_obj = $('#' + self_id);
var area_name = self_obj.attr('area_name');
var area_id = self_obj.attr('area_id');
var type = self_obj.attr('type');
var op_type = getPar('op_type'); //判断是选择出发地-还是目的地
var data = {
op_type: op_type,
area_id: area_id,
area_name: area_name
};
if(op_type == "in") {
setStorJson('f_wx_start_hot_city20160826', data);
}
if(op_type == "out") {
setStorJson('f_wx_end_hot_city20160826', data);
}
var tt = getDateTime(4);
var listURL = 'travel_book.html?tt=' + tt;
window.location.href = listURL;
}
}