1.取list中的值时候总是取到第一个值
<div class="brands pro_hd my_co">
<#assign collectTag = newTag("collectTag") />
<#assign collect = collectTag()!'' />
<#assign collectList = collect.result />
<div class="bd">
<#if collectList?exists && (collectList?size > 0) >
<ul class="">
<#list collectList as favorite>
<li>
<a href="javascript:void(0);"></a>
<div class="goods-img">
<a href="javascript:;" class="tap" data-href="${ctx}/goods-${favorite.goods_id}.html"><@image src="${favorite.thumbnail!''}"/></a>
</div>
<div class="li_ri">
<h3><span class="tap" data-href=""><@substring title="${favorite.name!''}" length=74 dot='...' /></span></h3>
<span class="sm">${favorite.goods_model_id!''}</span>
<span class="pr">${favorite.sale_price?string.currency}起</span>
<span class="kc">库存 :${favorite.own_store!'0'}</span>
<#assign own_store = favorite.own_store!''/>
<#if (own_store > 0 ) >
<i class="huo youhuo f26">现在有货</i>
<#else/>
<i class="huo youhuo f26">现在无货</i>
</#if>
<div class="goods-detai-buttons del">
<span class="btn-item delete" data-id="${favorite.favorite_id}"><img src="${ctx}${themes_path}/images2.0/zvcxxc03-05.jpg"></span>
</div>
</div>
</a>
</li>
</#list>
</ul>
</div>
</div>
2.js取值
$(function(){
var deviceWidth = document.documentElement.clientWidth;
if(deviceWidth > 750) deviceWidth = 750;
document.documentElement.style.fontSize = deviceWidth / 7.5 + 'px';
var module = new Module();
$('.delete').click(function () {
var _this = $(this),
// 防止取到总是第一个值
_id = _this.attr('data-id');
module.loading.open();
module.layerConfirm({
content: '删除收藏该商品吗?',
yes: function () {
_ajax();
}
})
function _ajax() {
$.ajax({
url : ctx + '/api/shop/collect/cancel-collect.do',
data: {favorite_id: _id},
type: 'POST',
success: function (res) {
if(res.result == 1){
module.message.success('删除成功!', function () {
location.replace(ctx + '/member/my-collect.html?type=goods');
});
}else {
module.loading.close();
module.message.error(res.message);
}
},
error: function () {
module.loading.close();
module.message.error('出现错误,请重试!');
}
})
}
return false
})
});