119 lines
2.8 KiB
JavaScript
119 lines
2.8 KiB
JavaScript
![]() |
var _msg={"adid":adid};
|
||
|
$(document).ready(function(){
|
||
|
|
||
|
sendClientMsg(root+"Wap/selectVacancy",select_arr,"");
|
||
|
|
||
|
$("body").unbind('click');
|
||
|
$("body").click(function(event){
|
||
|
var _id=$(event.target).attr("id");
|
||
|
var arr=String(_id).split("_");
|
||
|
if (arr[0]=="mycb")
|
||
|
{
|
||
|
var design=$("#design_"+arr[1]).html();
|
||
|
var vcost=$("#vacancycost_"+arr[1]).html();
|
||
|
var total=$("#total_cost").html();
|
||
|
if ($("#"+_id).is(':checked'))
|
||
|
{
|
||
|
$("#vacancycost_"+arr[1]).html(parseInt(design)+parseInt(vcost));
|
||
|
$("#total_cost").html(parseInt(design)+parseInt(total));
|
||
|
setOrderCost(arr[1], $("#vacancycost_"+arr[1]).html())
|
||
|
}else
|
||
|
{
|
||
|
$("#vacancycost_"+arr[1]).html(parseInt(vcost)-parseInt(design));
|
||
|
$("#total_cost").html(parseInt(total)-parseInt(design));
|
||
|
setOrderCost(arr[1], $("#vacancycost_"+arr[1]).html())
|
||
|
}
|
||
|
}else if (arr[0]=="buyBtn")
|
||
|
{
|
||
|
/*
|
||
|
0.广告牌id
|
||
|
1.广告位id
|
||
|
2.租用天数
|
||
|
3.一天费用
|
||
|
4.设计费用
|
||
|
5.是否设计
|
||
|
6.总费用
|
||
|
7.订单状态
|
||
|
*/
|
||
|
setDesign();
|
||
|
//sendClientMsg(root+"Wap/addOrder",_msg,"");
|
||
|
var _msg={"msg":arrToString(orderMsg,",","|")};
|
||
|
sendClientMsg(root+"Wap/addOrder",_msg,"");
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
|
||
|
var orderMsg=[];
|
||
|
|
||
|
function setDesign()
|
||
|
{
|
||
|
$("input[name='design[]']").each(function(){
|
||
|
var _id=this.value;
|
||
|
if (this.checked==true)
|
||
|
{
|
||
|
isDesign(_id, 1);
|
||
|
}else
|
||
|
{
|
||
|
isDesign(_id, 0);
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
function isDesign(_id, _num)
|
||
|
{
|
||
|
for(j = 0,len=orderMsg.length; j < len; j++)
|
||
|
{
|
||
|
if (orderMsg[j][1]==_id)
|
||
|
{
|
||
|
orderMsg[j][5]=_num;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function setOrderCost(_id, _num)
|
||
|
{
|
||
|
for(j = 0,len=orderMsg.length; j < len; j++)
|
||
|
{
|
||
|
if (orderMsg[j][1]==_id)
|
||
|
{
|
||
|
orderMsg[j][6]=_num;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function selectList(msg)
|
||
|
{
|
||
|
var str="";
|
||
|
var _total=0;
|
||
|
for(var i in msg)
|
||
|
{
|
||
|
var _tmp=[];
|
||
|
_msg["vacancy_"+msg[i].id]=msg[i].day;
|
||
|
|
||
|
var vcost=parseInt(msg[i].cost)*parseInt(msg[i].day);
|
||
|
str+='<li>'+
|
||
|
'<div style="width:15%" id="mynumber_'+msg[i].id+'">'+msg[i].number+'</div>'+
|
||
|
'<div style="width:5%"> </div>'+
|
||
|
'<div style="width:15%"><span id="myday_'+msg[i].id+'">'+msg[i].day+'</span>天</div>'+
|
||
|
'<div style="width:45%"><span><input type="checkbox" id="mycb_'+msg[i].id+'" name="design[]" value="'+msg[i].id+'" /> 需要设计 (</span><span id="design_'+msg[i].id+'">'+msg[i].design+'</span>元/次)</div>'+
|
||
|
'<div style="width:5%"> </div>'+
|
||
|
'<div style="width:15%"><span id="vacancycost_'+msg[i].id+'">'+vcost+'</span>元</div>'+
|
||
|
'</li>';
|
||
|
_total=parseInt(_total)+parseInt(vcost);
|
||
|
|
||
|
_tmp.push(adid);
|
||
|
_tmp.push(msg[i].id);
|
||
|
_tmp.push(msg[i].day);
|
||
|
_tmp.push(msg[i].cost);
|
||
|
_tmp.push(msg[i].design);
|
||
|
_tmp.push(0);
|
||
|
_tmp.push(vcost);
|
||
|
_tmp.push(0);
|
||
|
orderMsg.push(_tmp);
|
||
|
}
|
||
|
$("#mybuy_list").html(str);
|
||
|
$("#total_cost").html(_total);
|
||
|
}
|