123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- layui.use(['form','layer','laydate','table','laytpl','layedit','upload'],function(){
- var form = layui.form,
- layer = parent.layer === undefined ? layui.layer : top.layer,
- $ = layui.jquery,
- table = layui.table,
- upload = layui.upload;
- //添加图片上传
- upload.render({
- elem: '#test1'
- ,url: '/house/createimg'
- ,data:{token:csrfToken}
- ,field:'img'
- ,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: ['60%', '80%'],
- shade: 0.6, //透明度
- closeBtn: 1, //按钮 1有,0无
- shadeClose: true,
- content: '<img style="width:100%;height:100%" src="'+_src+'">',
- });
- });
- form.on('submit(watermark)',function (data) {
- var index = top.layer.msg('数据提交中,请稍候',{icon: 16,time:false,shade:0.8}); //数据提交提示
- var formData = new FormData($('#start_form')[0]);
- $.ajax({
- cache : true,
- type : "post",
- url : "/watermark/aa",
- data : formData, // 你的formid
- async : false,
- contentType: false, //jax 中 contentType 设置为 false 是为了避免 JQuery 对其操作,从而失去分界符,而使服务器不能正常解析文件
- processData: false, //当设置为true的时候,jquery ajax 提交的时候不会序列化 data,而是直接使用data
- error : function(request) {
- top.layer.close(index); //关闭数据提交信息
- layer.alert("网络超时");
- },
- success : function(data) {
- top.layer.close(index); //关闭数据提交信息
- if (data.code == 200) {
- layer.msg(data.msg);
- parent.layui.table.reload('tablerReload');
- } else if(data.code == 300){
- layer.msg(data.msg);
- layer.msg(ReturnInfo(data.data),{icon:5});
- }
- }
- });
- return false;
- })
- })
|