/** * Created by yfzhangguangming on 2016/6/29. */ $(function () { var list = { init: function () { var _this = this; $(".p-price").each(function () { var skuIds = $(this).attr("skuids"); if (skuIds) { _this.getPrice(skuIds, $(this).children()) } }); _this.getCheck(); }, getPrice: function (skuIds, $dom) { $.ajax({ url: '//p.3.cn/prices/mgets?skuIds=' + skuIds + '&area=0&type=1', dataType: 'jsonp', success: function (r) { if (r && r.length > 0) { var totalPrice = 0.0; for (var i = 0; i < r.length; i++) { var p = parseFloat(r[i].p); if (p > 0) { totalPrice += p; } } totalPrice = totalPrice.toFixed(2); if (totalPrice > 0) { $dom.html(totalPrice); } else { $dom.html("暂无报价"); } } } }); }, getCheck: function () { var queryTerm = window.location.search; if (!queryTerm) { queryTerm = "?page=1" } $.ajax({ url: '/collsync/check' + queryTerm, dataType: 'json', success: function (r) { if (r && r.length > 0) { $(".selector-line li a").each(function () { var jishu=0; for (var i = 0, j = r.length; i < j; i++) { if ($(this).attr("id") == r[i]) { jishu++; } } if(jishu==0){ $(this).addClass("disabled"); $(this).attr("href","#none"); } }); } } }); } } list.init(); });