模板代码
<script>
window.onload=function(){
showDetail('{$shops.id}');
doProduct('{$shops.id}','{$shops.name}','{$shops.old_price}','{$shops.y_price}');
$('#cart').click();
}
</script>
</div>
</dl>
</section>
</section>
</div>
<div id="cart-container" style="display: block;">
<div class="orderlist">
<ul id="cartinfo">
<li class="ccbg2" id="emptyLii">{$shops.name}</li>
</ul>
<if condition="$buy_cnt neq 0">
<ul id="cartinfo">
<li class="ccbg2" id="emptyLii">已选:<span id="totalNum">0</span> 份,共计:<span id="totalPrice">0</span> 元</li>
<li style="display:none"><span id="totalLirun">0</span></li>
</ul>
</if>这个下面是引用JS的function doProduct (id , name , price,lirun) {
var bgcolor = $('#'+id).children().css('background-color').colorHex().toUpperCase();
if (bgcolor == '#FFFFFF') {
$('#'+id).children().css('background-color','#D00A0A');
var cartMenuN = parseFloat($('#cartN2').html())+1;
$('#totalNum').html( cartMenuN );
$('#cartN2').html( cartMenuN );
var totalPrice = parseFloat($('#totalPrice').html())+ parseFloat(price);
$('#totalPrice').html( totalPrice.toFixed(2) );
var totalLirun = parseFloat($('#totalLirun').html())+ parseFloat(lirun);
$('#totalLirun').html( totalLirun.toFixed(2) );
var weshopId = 'weshop_'+id;
var html = '<li class="ccbg2" id="'+weshopId+'"><div class="orderdish"><span name="title" style="display:none;">'+name+'</span>选择份数:<span class="price" id="v_0" style="display:none;">'+price+'</span><span style="display:none; class="price">元</span></div><div class="orderchange"><a href=javascript:addProductN("'+weshopId+'_'+price+'") class="increase"><b class="ico_increase">加一份</b></a><span class="count" id="num_1_499">1</span><a href=javascript:reduceProductN("'+weshopId+'_'+price+'") class="reduce"><b class="ico_reduce">减一份</b></a></div></li>';
$('#ullist').append(html);
}else{
$('#'+id).children().css('background-color','');
var cartMenuN = parseFloat($('#cartN2').html())-1;
$('#totalNum').html( cartMenuN );
$('#cartN2').html( cartMenuN );
var totalPrice = parseFloat($('#totalPrice').html())- parseFloat(price);
$('#totalPrice').html( totalPrice.toFixed(2) );
var totalLirun = parseFloat($('#totalLirun').html())- parseFloat(lirun);
$('#totalLirun').html( totalLirun.toFixed(2) );
var weshopId = 'weshop_'+id;
$('#'+weshopId).remove();
}
} 最佳答案