//layui 根目录配置 layui.config({ base: '/static/layui/', }) //载入layui组建 layui.use(['layer', 'form','element','upload','flow'], function(){ var form = layui.form; var layer = layui.layer; var element = layui.element; var upload = layui.upload; var flow = layui.flow; //图片懒加载 flow.lazyimg({ elem:'#found-img img' }); flow.lazyimg({ elem:'#adminpic img' }); //图片查看器 layer.photos({ photos: '#adminpic' ,anim: 5 //0-6的选择,指定弹出图片动画类型,默认随机(请注意,3.0之前的版本用shift参数) }); layer.photos({ photos: '#found-img' ,anim: 5 //0-6的选择,指定弹出图片动画类型,默认随机(请注意,3.0之前的版本用shift参数) }); //首页拖拽上传 upload.render({ elem: '#upimg' ,url: 'functions/upload.php' ,size: 2048 //限制上传大小为2M ,before: function(obj){ //obj参数包含的信息,跟 choose回调完全一致,可参见上文。 layer.load(); //上传loading } ,done: function(res){ //如果上传失败 if(res.code == 0){ layer.open({ title: '温馨提示' ,content: res.msg }); layer.closeAll('loading'); } else if(res.code == 1){ layer.closeAll('loading'); $("#showpic a").attr('href',res.url); $("#showpic img").attr('src',res.url); $("#url").val(res.url); $("#html").val(""); $("#markdown").val("![](" + res.url + ")"); $("#bbcode").val("[img]" + res.url + "[/img]"); $("#upok").show(); //请求接口处理图片 $.get("./dispose.php?id="+res.id,function(data,status){ var obj = eval('(' + data + ')'); if(obj.level == 3){ layer.open({ title: '温馨提示' ,content: '请勿上传违规图片!' }); } if(obj.level == null){ $.get("./dispose.php?id="+res.id,function(data,status){ var obj = eval('(' + data + ')'); if(obj.level == 3){ layer.open({ title: '温馨提示' ,content: '请勿上传违规图片!' }); } }); } }); } } }); //上传到sm.ms upload.render({ elem: '#sm' ,url: 'https://sm.ms/api/upload' ,before: function(obj){ //obj参数包含的信息,跟 choose回调完全一致,可参见上文。 layer.load(); //上传loading } ,done: function(res){ //如果上传失败 if(res.code == 'error'){ layer.open({ title: '温馨提示' ,content: res.msg }); layer.closeAll('loading'); } else if(res.code == 'success'){ layer.closeAll('loading'); $("#showpic a").attr('href',res.data.url); $("#showpic img").attr('src',res.data.url); $("#url").val(res.data.url); $("#html").val(""); $("#markdown").val("![](" + res.data.url + ")"); $("#bbcode").val("[img]" + res.data.url + "[/img]"); $("#upok").show(); $.post("./functions/sm.php",{data:res.data},function(data,status){ }); } } }); //上传到sm.ms end }); //复制链接 function copy(info){ var copy = new clipBoard(document.getElementById('piclink'), { beforeCopy: function() { info = $("#" + info).val(); }, copy: function() { return info; }, afterCopy: function() { } }); layui.use('layer', function(){ var layer = layui.layer; layer.msg('复制成功!', {time: 2000}) }); } //后台复制URL function copyurl(url){ var copy = new clipBoard(document.getElementById('adminpic'), { beforeCopy: function() { }, copy: function() { return url; }, afterCopy: function() { } }); layui.use('layer', function(){ var layer = layui.layer; layer.msg('链接已复制!', {time: 2000}) }); } //用户登录方法 function login(){ // 获取用户提交的信息 var user = $("#user").val(); var password = $("#password").val(); $.post("../functions/Controller.php?type=login",{user:user,password:password},function(data,status){ layer.msg(data,{time:2000}); }); } //用户前台预览图片 function userpreview(imgurl,id){ var showimg = "