$(document).ready(function () { $('body').on('click', '.addTempalte', function () { $(this).parent().parent().find('.equip-container').append( "
\n" + "
\n" + "装备*\n" + "\n" + "
\n" + "
\n" + "装备购买网址\n" + "\n" + "
\n" + "
\n" + "\n" + "
\n" + "
"); }); //删除本地追加的item var delObj; $('body').on('click', '.del-btn', function () { // layer.msg('右侧删除操作',{icon:5,time:1500}); var delObj = $(this).parent() qikoo.dialog.confirm('确认要删除?', function () { delObj.remove(); }, function () { }); }); //删除已经上传到服务器的item var removeApiItemObj; $('body').on('click', '.remove-api', function () { var id = $(this).attr('data-id'); removeApiItemObj = $(this).parents('.equip-item'); // layer.msg('删除api删除操作 id:'+id,{icon:5,time:1500}); qikoo.dialog.confirm('确认要删除?', function () { $.ajax({ url: '/gk/equip/del', data: {id: id}, success: function (data) { if (data.status) { if (removeApiItemObj != null) { removeApiItemObj.remove(); } } else { layer.msg('操作失败', {icon: 5, time: 1500}); } }, error: function () { layer.msg('操作失败', {icon: 5, time: 1500}); } }) }, function () { }); }); $('body').on('click', '.save', function () { var param = []; var isNecessary = true; $('.force .equip-item').each(function (i, e) { var id = $(e).find('div[data-id]').attr('data-id'); // layer.msg('保存api操作id:'+id,{icon:5,time:1500}); var name = $(e).find('input').val(); var url = $(e).find('input').parent().next().find('input').val(); var obj = {id: id, name: name, type: 2, cmptId: getCmptId(), url: url}; param.push(obj) if (name == "") { document.getElementById("save-suc-hint").style.display = "none" document.getElementById("save-fail-hint").style.display = "none" document.getElementById("necessary-hint").style.display = "" isNecessary = false; return; } }); $('.recommend .equip-item').each(function (i, e) { var id = $(e).find('div[data-id]').attr('data-id'); var name = $(e).find('input').val(); var url = $(e).find('input').parent().next().find('input').val(); var obj = {id: id, name: name, type: 1, cmptId: getCmptId(), url: url}; param.push(obj) if (name == "") { document.getElementById("save-suc-hint").style.display = "none" document.getElementById("save-fail-hint").style.display = "none" document.getElementById("necessary-hint").style.display = "" isNecessary = false; return; } }); if (!isNecessary) { return; } var obj = $(this); $.ajax({ url: '/gk/equip/save', dataType: 'json', contentType: 'application/json', type: 'post', data: JSON.stringify(param), success: function (data) { if (data.status) { document.getElementById("save-suc-hint").style.display = "" document.getElementById("save-fail-hint").style.display = "none" document.getElementById("necessary-hint").style.display = "none" layer.msg('操作成功', {icon: 1, time: 1500}); window.location.reload(); } else { document.getElementById("save-suc-hint").style.display = "none" document.getElementById("save-fail-hint").style.display = "" document.getElementById("necessary-hint").style.display = "none" layer.msg('操作失败', {icon: 5, time: 1500}); } }, error: function () { layer.msg('操作失败', {icon: 5, time: 1500}); } }) }); // $(function(){ // $(".del").click(function(){ // }) // }) })