productmanagement.html
productmanagement.css
.row-product { border: 1px solid #999; padding: .5rem; border-bottom: none;}.row-product* { white-space: nowrap; overflow: scroll;}.row-product:last-child { border-bottom: 1px solid #999;}.product-name { white-space: nowrap; overflow-x: scroll;}.product-wrap a { margin-right: 1rem;}
productmanagement.js
$(function() { var listUrl = '/o2o/shopadmin/getproductlistbyshop?pageIndex=1&pageSize=9999'; var statusUrl = '/o2o/shopadmin/changestatus'; getList(); function getList() { $.getJSON(listUrl, function(data) { if (data.success) { var productList = data.productList; var tempHtml = ''; productList.map(function(item, index) { var textOp = "下架"; var contraryStatus = 0; if (item.enableStatus == 0) { textOp = "上架"; contraryStatus = 1; } else { contraryStatus = 0; } tempHtml += '' + '' + ''; }); $('.product-wrap').html(tempHtml); } }); } $('.product-wrap') .on( 'click', 'a', function(e) { var target = $(e.currentTarget); if (target.hasClass('edit')) { window.location.href = '/o2o/shopadmin/productoperation?productId=' + e.currentTarget.dataset.id; } else if (target.hasClass('status')) { changeStatus(e.currentTarget.dataset.id, e.currentTarget.dataset.status); } else if (target.hasClass('preview')) { // TODO window.location.href = '/o2o/frontend/productdetail?productId=' + e.currentTarget.dataset.id; } }); /** * 下架操作 */ function changeStatus(id, enableStatus) { //定义product json对象并添加productId以及状态 var product = { }; product.productId = id; product.enableStatus = enableStatus; $.confirm('确定么?', function() { $.ajax({ url : statusUrl, type : 'POST', data : { productStr : JSON.stringify(product), statusChange : true }, dataType : 'json', success : function(data) { if (data.success) { $.toast("操作成功"); getList(); } else { $.toast("操作失败"); } } }); }); } $('#new').click(function() { window.location.href = '/o2o/shopadmin/productoperation'; });});' + item.productName + '' + '' + item.priority + '' + ' ' + '