layui.use(['layer', 'element'], function() { var layer = layui.layer, element = layui.element; }); function logout() { $.post('/user/logout', {'exit': true}, function() { return location.href = '/'; }); } var btnLoad = function(a, b) { var element = $(a), V = element.html(); try { element.html(' ' + (b ? b : '保存中...')); element.attr('disabled', true); element.css('cursor', 'not-allowed'); } catch (e) { element.html(V); element.attr('disabled', false); element.css('cursor', 'pointer'); } } var closeBtnLoad = function(a, b) { var element = $(a); element.html(b); element.attr('disabled', false); element.css('cursor', 'pointer'); } function picDel(id) { layer.confirm('您真的要删除这张图片吗?', { title: '删除图片', btn: ['删除', '取消'] //按钮 }, function() { layer.load(2); $.post('/user/picDel', {'id': id}, function(res) { layer.msg(res.msg, {icon: res.code ? 1 : 2}); if(res.code) { fadeRemove('.pic-' + id); } layer.closeAll('loading'); }); }); } function fadeRemove(a) { $(a).fadeTo("slow", 0.01, function() { $(this).slideUp("slow", function() { $(this).remove(); }); }); } function picBatchDel() { var array = []; $('.fa-check-circle-o').each(function() { array.push($(this).attr('data-id')); }); if(array.length > 0) { return layer.confirm('您真的要删除这 '+ array.length +' 张图片吗?', { title: '删除图片', btn: ['删除', '取消'] //按钮 }, function() { layer.load(2); $.post('/user/picBatchDel', {'array': array}, function(res) { if(res.code) { for (var i = 0; i < array.length; i++) { fadeRemove('.pic-' + array[i]); } } layer.msg(res.msg, {icon: res.code ? 1 : 2}); layer.closeAll('loading'); }); }); } return layer.msg('没有选中项'); } function checkBoxAll() { var t = $('.pic-del'); if(t.hasClass('fa-check-circle-o')) { t.removeClass('fa-check-circle-o'); t.addClass('fa-circle-thin'); $('.checkBoxAll').html('全选'); } else { t.removeClass('fa-circle-thin'); t.addClass('fa-check-circle-o'); $('.checkBoxAll').html('反选'); } } function forgot() { layer.open({ type: 1, //area: ['500px', '300px'], title: '找回密码', shade: 0.6, content: '