Files
advertising/home/js/buy.js

158 lines
4.3 KiB
JavaScript
Raw Permalink Normal View History

2019-04-11 15:54:34 +08:00
$(document).ready(function(){
$(".xsiqy_f_in .xsiqy_f_in_1").last().css({display:"none"});
$(".zslgxzx_f_in ul li").click(function(){
$(this).addClass("addys_f3").siblings().removeClass("addys_f3");
$(".xsiqy_f_in .xsiqy_f_in_1").eq($(this).index()).css({display:"block"}).siblings().css({display:"none"});
});
var msg={"adid":adid};
sendClientMsg(root+"Wap/getAd",msg,"");
$("body").unbind('click');
$("body").click(function(event){
var _id=$(event.target).attr("id");
var arr=String(_id).split("_");
if (arr[0]=="selectBtn")
{
if (checkCbLen("id[]")>0)
{
select_arr=getCheckBox("id[]");
disMyBuy();
}
}else if (arr[0]=="cb")
{
if ($("#"+_id).is(':checked'))
{
setTotalCost();
}else
{
setTotalCost();
}
}
});
});
function setTotalCost()
{
var total=0;
$("input[name='id[]']").each(function(){
if (this.checked==true)
{
var _id=this.value;
var num=parseInt($("#total_"+_id).html());
total=total+num;
}
});
$("#totalVacancyCost").html(total);
}
function setBuyAd(msg)
{
$("#slider").html("");
$("#vacancy_list").html("");
var _photo=msg.photo;
var str='';
for(var i in _photo)
{
str+='<li id="callbacks1_s'+i+'" class="" style="display: list-item; transition: opacity 500ms ease-in-out; -webkit-transition: opacity 500ms ease-in-out; float: none; position: absolute; opacity: 0; z-index: 1;"><a href="#"><img src="'+upload_url+_photo[i]+'" border="0"></a></li>'
}
$("#slider").append(str);
$("#slider").responsiveSlides({
auto: true,
pager: false,
nav: true,
speed: 500,
timeout:4000,
pager: true,
pauseControls: true,
namespace: "callbacks"
});
var cityd=msg.cityd;
console.log(msg);
$(".novice_title").html(msg["community"]);
$(".novice_address").html(msg["city"]+"&nbsp;-&nbsp;"+msg["area"]);
$(".novice_add").html(msg["citydess"]);
$(".novice_num").html("空位&nbsp;:&nbsp;"+msg["free"]);
$('#fenbutu').attr("src", upload_url+msg["img"]);
var vstr="";
for(var i in msg["empty"])
{
vstr+='<li>'+
'<div style="width:10%"><input type="checkbox" id="cb_'+msg["empty"][i].id+'" name="id[]" value="'+msg["empty"][i].id+'" /></div>'+
'<div style="width:20%" id="number_'+msg["empty"][i].id+'">'+msg["empty"][i].number+'</div>'+
'<div style="width:20%"><span id="cost_'+msg["empty"][i].id+'">'+msg["empty"][i].cost+'</span>元/天</div>'+
'<div style="width:38%">'+
'&nbsp;&nbsp;<input type="text" class="input3" name="day_'+msg["empty"][i].id+'" id="day_'+msg["empty"][i].id+'" style="padding:3px;" value="1" size="3" style="color:#ccc" onblur="check(this.id)"/>天&nbsp;&nbsp;'+
'</div>'+
'<div style="width:12%"><span id="total_'+msg["empty"][i].id+'">'+parseInt(msg["empty"][i].cost*1)+'</span>元</div>'+
'</li>';
}
$("#vacancy_list").html(vstr);
/*var vstr="";
for(var i in msg["appointment"])
{
vstr+='<li>'+
'<div style="width:10%">&nbsp;</div>'+
'<div style="width:20%" id="appointment_'+msg["appointment"][i].id+'">'+msg["appointment"][i].number+'</div>'+
'<div style="width:10%">&nbsp;</div>'+
'<div style="width:30%" id="appointment_cost_'+msg["appointment"][i].id+'">'+msg["appointment"][i].cost+'元/天</div>'+
'<div style="width:30%">已预约</div>'+
'</li>';
}
$("#other_list").append(vstr);*/
var vstr="";
for(var i in msg["buy"])
{
var _days="";
if (msg["buy"][i].surplus==0||msg["buy"][i].surplus=="")
{
_days="正在申请";
}else
{
_days='剩余'+msg["buy"][i].surplus+'天';
}
vstr+='<li>'+
'<div style="width:10%">&nbsp;</div>'+
'<div style="width:20%" id="buy_'+msg["buy"][i].id+'">'+msg["buy"][i].number+'</div>'+
'<div style="width:10%">&nbsp;</div>'+
'<div style="width:30%" id="buy_cost_'+msg["buy"][i].id+'">'+msg["buy"][i].cost+'元/天</div>'+
'<div style="width:30%">'+_days+'</div>'+
'</li>';
}
$("#other_list").append(vstr);
}
function check(id)
{
var arr=String(id).split("_");
if (arr[0]=="day")
{
var num=$("[name=day_"+arr[1]+"]").val();
var bol=checkNum(num);
var day=1;
if (bol==true)
{
day=parseInt(num);
}else if (bol==false)
{
$("[name=day_"+arr[1]+"]").val(day);
}
var _num=parseInt($("#cost_"+arr[1]).html())*parseInt(day);
$("#total_"+arr[1]).html(_num);
setTotalCost();
}
}