123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- var ajaxData = {time:0,city:0}
- // 自定义下拉
- $(".dropdiv").click(function(e){
- var parentDiv = $(this).parent();
- if(parentDiv.hasClass('on')){
- parentDiv.removeClass('on');
- }else{
- parentDiv.addClass('on');
- }
- $(".chooseItems").slideUp(300);
- e.stopPropagation();
- var quest = $(this).parent();
- var questwidth = parseInt(quest.width())-2;
- var questheight = quest.height();
- var left = quest.position().left+parseInt(quest.css("margin-left"))+parseInt(quest.css("padding-left"));
- var top = parseInt(quest.position().top)+parseInt(questheight)+24;
- var attrs = quest.attr("quest");
- var selectsd = $('.chooseItems[answer='+attrs+']');
- var selectsdHeight = selectsd.height();
- if((top+selectsdHeight)>$(window).height()){
- top = top - selectsdHeight - questheight-7;
- }
- if($(selectsd).is(":visible")){
- $(selectsd).slideUp(300);
- }else{
- $(selectsd).css({"left":left+"px","top":top+"px","width":questwidth+"px"}).slideDown(300);
- }
- });
- $(".chooseItem").click(function(e){
- var parentDiv = $('.dropmiandiv');
- if(parentDiv.hasClass('on')){
- parentDiv.removeClass('on');
- }else{
- parentDiv.addClass('on');
- }
- var otype = $(this).attr('type');
- var oid = $(this).attr('displayMember');
- ajaxData[otype] = oid;
- information() //调数据
- e.stopPropagation();
- var divhtml = $(this);
- var displayMember,valueMember;
- displayMember = divhtml.attr("displayMember");
- valueMember = divhtml.attr("valueMember");
- var attrs =$(this).parent().attr("answer");
- var parent = $("#"+attrs);
- var olddisplayMember,oldvalueMember;
- olddisplayMember = parent.attr("displayMember");
- oldvalueMember = parent.attr("valueMember");
- if(olddisplayMember !=displayMember){
- parent.attr("displayMember",displayMember);
- parent.attr("valueMember",valueMember);
- parent.val(valueMember);
- parent.change();
- }
- $(this).parent().slideUp(300);
- });
- // 点击元素以外隐藏下拉
- $(document).click(function(e){
- var target = $(e.target);
- if(target.closest(".chooseItems").length == 0){
- $(".chooseItems").slideUp(300);
- }
- $('.dropmiandiv').removeClass('on'); // 删除
- });
- information(); //默认执行一次
- function information(){
- $.ajax({
- type: 'post',
- url: '/zt/specialdata',
- data:ajaxData,
- dataType: 'json',
- success: function(data){
- if(data.code == "200"){
- var _html = "";
- $.each(data.data,function(k,v){
- _html += '<li>';
- _html += '<div class="delegation-img">';
- if(v.is_push==2){
- _html += '<b>热门</b>';
- }
- _html += '<img src="'+v.img+'" alt="">';
- // _html += '<div class="delegation-font"><span>'+v.title+'</span></div>';
- _html += '</div>';
- _html += '<div class="delegation-tier"><a data-id="'+v.city+'" href="'+v.url+'">查看详情</a></div>';
- _html += '</li>';
- })
- _html +='<li>';
- _html +='<div class="delegation-img">';
- _html +='<img src="/zt/kaocatuan20190126/image/lpb.png" alt="">';
- _html +='<div class="tion-font">更多精彩<br/>敬请期待</div>';
- _html +='</div>';
- _html +='</li>';
- $('.delegation-box ul').html("");
- $('.delegation-box ul').html(_html);
- }
- }
- });
- }
- // 列表中查看详情 点击按钮
- $('.delegation-box ul').on('click','.delegation-tier a',function(){
- var that = $(this);
- var eid = that.attr('data-id');
- ajaxData.time = 0;
- ajaxData.city = eid;
- information(); //点击列表再次调用
- })
|