1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- layui.use(['form','layer','laytpl','layedit','upload'],function(){
- var form = layui.form,
- layer = layui.layer ,
- $ = layui.jquery,
- upload = layui.upload;
- //添加图片上传
- upload.render({
- elem: '#test1'
- ,url: '/house/createimg'
- ,data:{token:csrfToken}
- ,field:'template'
- ,size:1000 //限制上传图片的大小,单位为KB
- ,exts: 'png|jpg|jpeg' //只允许上传压缩文件
- ,auto:false
- ,bindAction:'#addcity'
- ,choose: function(obj){
- obj.preview(function(index, file, result){
- $('#demo1').attr('src', result); //图片链接(base64)
- });
- }
- });
- // 点击放大图片
- $('#demo1').on('click', function(){
- var _src = $(this).attr('src');
- layui.layer.open({
- type: 1,
- title: false, //是否显示标题
- area: ['50%', '40%'],
- shade: 0.6, //透明度
- closeBtn: 1, //按钮 1有,0无
- shadeClose: true,
- content: '<img style="width:90%;background:rgba(0,0,0,0.5);display:block;margin:13% auto 0" src="'+_src+'">',
- });
- });
- form.on('submit(watermark)',function (data) {
- var index = layer.msg('数据提交中,请稍候',{icon: 16,time:false,shade:0.8}); //数据提交提示
- var formData = new FormData($('#start_form')[0]);
- $.ajax({
- cache : true,
- type : "post",
- url : "/othersiteset/editwatermarkform",
- data : formData, // 你的formid
- // async : false, //async 默认为true异步,修改为false为同步
- contentType: false, //jax 中 contentType 设置为 false 是为了避免 JQuery 对其操作,从而失去分界符,而使服务器不能正常解析文件
- processData: false, //当设置为true的时候,jquery ajax 提交的时候不会序列化 data,而是直接使用data
- error : function(request) {
- layer.close(index); //关闭数据提交信息
- layer.alert("网络超时");
- },
- success : function(data) {
- if (data.code == 200) {
- layer.msg(data.msg);
- } else if(data.code == 300){
- layer.msg(data.msg);
- layer.msg(ReturnInfo(data.data),{icon:5});
- }
- }
- });
- return false;
- })
- })
|