/** //表单提交 var clickState = 0; function checkform($this) { var id = $this.id; var url = $this.action; var data = $("#" + id).serialize(); if (clickState == 1) { var dialog = art.dialog( { id: $this.id, time: 2, width: 300, height: 100, content: "正在提交中 请勿重复点击" } ); return false; } else { var dialog = art.dialog( { id: $this.id, time: 2, width: 300, height: 100, content: "正在提交中 请稍等" } ); } clickState = 1; $.post(url, data, function (data2, status) { var list = art.dialog.list; for (var i in list) { list[i].close(); } ; if (data2.code == 1) { setTimeout("dialog_alert('" + data2.msg + "')", 1000); } else { dialog_url(data2) } return false; }, "json"); return false; } function dialog_alert(msg) { var list = art.dialog.list; for (var i in list) { list[i].close(); } ; var dialog = art.dialog( { time: 2, width: 300, height: 100, content: msg } ); clickState = 0; } //删除提示 function delete_alert($url) { var dialog = art.dialog( { time: 5000, width: 300, height: 100, content: "您确定要删除吗", cancelVal: '关闭', cancel: true }, function () { $.get($url, function (data, status) { alert_url(data) }, "json"); } ); } //修改密码 function updatePassword() { var password = $("#password").val(); var password1 = $("#password1").val(); var password2 = $("#password2").val(); var url = $("#url").val(); $.post(url, {password: password, password1: password1, password2: password2}, function (data, status) { if (data.code == 1) { dialog(data); } else { dialog_url(data) } }, "json"); } //重置密码 function resetPassword() { document.getElementById("password1").value = ""; document.getElementById("password2").value = ""; } /*正常弹窗*/ function dialog(data) { var dialog = art.dialog( { time: 2, width: 300, height: 100, content: data.msg } ); } //跳转 function url_Jump(d_url) { window.location.replace(d_url); } /*弹窗跳转*/ function dialog_url(data) { clickState = 0; if (data.code == 2) { var dialog = art.dialog( { time: 2, width: 300, height: 100, content: data.msg } ); var url_1 = data.url; if (data.url) { setTimeout("url_Jump('" + url_1 + "')", 2000); } } } /*alert弹窗跳转或刷新*/ function alert_url(data) { if (data.code == 2) { var dialog = art.dialog( { time: 2, width: 300, height: 100, content: data.msg } ); var url_1 = data.url; if (data.url) { setTimeout("url_Jump('" + url_1 + "')", 2000); } else { window.location.reload(); } } } //图片预览 function img_show($img_show, $rl) { var img_url = $("#" + $img_show).val();//1347092855_407.jpg] if (img_url.substr(0, 4) == 'http') { var url = img_url; } else { var url = "; } //var url = "https://posppay.020leader.com" + img_url; var img = "<img src=" + $rl + " width='800' height='600'>"; art.dialog({ padding: 0, title: '照片', content: img, lock: true }); } //除银行意外使用这个图片上传 function imgUploadClick($file) { $("#" + $file).click(); } function imgUpload($file, $documents_img1, $token) { var img = $("#" + $file).val();//1347092855_407.jpg] if (img) { var fileObj = document.getElementById($file).files[0]; if (fileObj.size > 524288) { alert('你上传的图片太大,请重新上传'); return; } var formData = new FormData(); // 可以增加表单数据 formData.append("fileElem", fileObj); $.ajax({ url: "", type: "POST", data: formData, dataType: 'json', processData: false, contentType: false, timeout: 5000, success: function (data, textStatus, jqXHR) { //typeof if (data.code == 1) { document.getElementById("" + $documents_img1 + "").value = data.url; } else { var dialog = art.dialog( { time: 2, width: 300, height: 100, content: data.msg } ); } }, error: function (jqXHR, textStatus, errorThrown) { //if fails } }); } } //压缩不变型图片支持20兆以内 function uploadImageBase64($file_class, $img, $documents_img1) { $("#" + $file_class).click(); $('#' + $file_class).localResizeIMG({ width: 1000, quality: 0.7, success: function (result) { var submitData = { base64_string: result.clearBase64, }; $.ajax({ type: "POST", url: '', data: submitData, dataType: "json", success: function (data) { if (data.code == 1) { document.getElementById("" + $img + "").value = data.url; document.getElementById("" + $documents_img1 + "").value = data.url; } else { var dialog = art.dialog( { time: 2, width: 300, height: 100, content: data.msg } ); } }, }); } }); } //压缩不变型图片支持20兆以内 兼容苹果手机 function uploadImageBase64s($file_class, $img) { $('#' + $file_class).localResizeIMG({ width: 1000, quality: 0.7, success: function (result) { var submitData = { base64_string: result.clearBase64, }; $.ajax({ type: "POST", url: '', data: submitData, dataType: "json", success: function (data) { if (data.code == 1) { document.getElementById("" + $img + "").value = data.url; } else { var dialog = art.dialog( { time: 2, width: 300, height: 100, content: data.msg } ); } }, }); } }); } //压缩不变型图片支持20兆以内 兼容苹果手机 ,微信第三方图片上传 function uploadImagemeida($file_class, $img, $media) { $('#' + $file_class).localResizeIMG({ width: 1000, quality: 0.7, success: function (result) { var submitData = { base64_string: result.clearBase64, }; $.ajax({ type: "POST", url: '', data: submitData, dataType: "json", success: function (data) { if (data.code == 1) { var b = { merchantnum: "000000000019224", image: "" + data.url, }; //请求微信上传图片接口,获取media_id $.ajax({ type: "POST", url: "", data: b, dataType: "json", success: function (mediadata) { if (mediadata.result_code == "success") { document.getElementById("" + $img + "").value = data.url; document.getElementById("" + $media + "").value = mediadata.media_id; } else { var msg = "图片上传失败" + mediadata.result_msg; var dialog = art.dialog( { time: 2, width: 300, height: 100, content: msg } ); } } }); } else { var dialog = art.dialog( { time: 2, width: 300, height: 100, content: data.msg } ); } }, }); } }); } //压缩不变型图片支持20兆以内 兼容苹果手机 function uploadImageBase64Size($file_class, $img, Width, Height) { $('#' + $file_class).localResizeIMG({ width: 1000, quality: 0.7, success: function (result) { var submitData = { width: $Width, height: $Height, base64_string: result.clearBase64, }; $.ajax({ type: "POST", url: '', data: submitData, dataType: "json", success: function (data) { if (data.code == 1) { document.getElementById("" + $img + "").value = data.url; } else { var dialog = art.dialog( { time: 2, width: 300, height: 100, content: data.msg } ); } }, }); } }); } /** * 图片上传识别功能. * ctl 控制器名. * mtd 方法名. */ function imageRecognitionBase64($file_class, $img, $type_img, ctl, mtd) { $('#' + $file_class).localResizeIMG({ width: 1000, quality: 0.7, success: function (result) { var submitData = { base64_string: result.clearBase64, }; $.ajax({ type: "POST", url: '', data: submitData, dataType: "json", success: function (result) { if (result.code == 1) { document.getElementById("" + $img + "").value = result.url; var img_url = result.url; var img_name = document.getElementById("" + $type_img + "").getAttribute("name"); var url = '/index.php?g=User&m=' + ctl + '&a=' + mtd; var data = {img_url: img_url, img_name: img_name}; $.post(url, data, function (res) { if (res.code == 1) { dialog_alert(res.msg); } else { //处理数据填充 var datum = res.data; $.each(datum, function (key, val, datum) { $('#' + key).val(val); }) } }, 'json'); } else { dialog_alert(result.msg); } }, }); } }); } $("#jq_search_btn_merchant").click(function () { $(this).submit(); }); function checkform_search($this) { var id = $this.id; var url = $this.action; var data = $("#" + id).serialize(); window.location.href = url + '&' + data; }
通用js
最新推荐文章于 2020-07-20 14:42:10 发布