项目中有个需求是判断商品是否为VIP专享,是的话就带VIP图标,在模版直接读取数据使用if condition是可以实现的,但是在用js实现“点击加载更多”时,在js代码块里无法实现if condition判断,该怎么办?
初始加载代码:
<volist name="goods" id="vo">
<section>
<if condition='$vo.is_vip eq 1'>
<img src="/Application/Home/View/default/img/vip.png" class="vipPic">
</if>
<a href="__APP__/Home/Goods/goods/id/{$vo.gid}">
<div class="totleInfoPic"><img src="/Application/Home/View/default/{$vo.goods_thumb}"></div>
<div class="totleInfo">
<h2>{$vo.goods_title}</h2>
<div class="fundinginfo"><span>{$vo.goods_title2}</span><b></b></div>
</div>
<div class="q_actionBid">起拍价:¥{$vo.start_price}</div>
<div class="q_actionstatu">倒计时 <span class="counttime" endTime="{$vo.start_time}"></span></div>
</a>
</section>
</volist>
然后通过ajax实现点击加载更多,代码如下:
var nStart = 5;
$('#more').click(function() {
var _this = $(this);
if (nStart >= {$total}) {
_this.text('更多商品正在上架中...');
return false;
}else{
$.post("{:U('articleAjax')}", {start: nStart},function(res) {
$.each(res['result'],function(i, item) {
_this.before('<section><if condition='item.is_vip eq 1'><img src="/Application/Home/View/default/img/vip.png" class="vipPic"></if><a href="__APP__/Home/Goods/goods/id/'+item.gid+'"><div class="totleInfoPic"><img src="/Application/Home/View/default/'+item.goods_thumb+'"></div><div class="totleInfo"><h2>'+item.goods_title+'</h2><div class="fundinginfo"><span>'+item.goods_title2+'</span><b></b></div></div><div class="q_actionBid">起拍价:¥'+item.start_price+'</div><div class="q_actionstatu">倒计时 <span class="counttime" endTime="'+item.start_time+'"></span></div></a></section>');
});
});
nStart += 5;
}
});
问题就出在js中<if condition='item.is_vip eq 1'>这个位置,无法实现判断,换了好几种写法都不行,怎么办?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…