86 lines
2.8 KiB
Plaintext
86 lines
2.8 KiB
Plaintext
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="signation.aspx.cs" Inherits="SystemManage_signation" %>
|
|
|
|
<!DOCTYPE html>
|
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head runat="server">
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<title><%=System.Configuration.ConfigurationManager.AppSettings["SYSTitle"]%></title>
|
|
<script src="../JS/jquery-1.4.1.min.js"></script>
|
|
<script src="../JS/jSignature.min.js"></script>
|
|
<script>
|
|
$(function () {
|
|
var signature = jQuery("#signature"); //此处jquery 获取对象 否则对jSignature不起作用
|
|
signature.jSignature({
|
|
width: "100%",
|
|
height: "100%"
|
|
});
|
|
|
|
$("#btnClear").click(function () {
|
|
signature.jSignature("reset");
|
|
})
|
|
|
|
$("#btnSave").click(function () {
|
|
var imgdata = signature.jSignature("getData", "image");
|
|
|
|
var url2 = "signation.aspx/setSignation";
|
|
$.ajax({
|
|
type: 'POST',
|
|
url: url2,
|
|
data: {qianming: imgdata.toString().split(",")[1]},
|
|
contentType: "application/json; charset=utf-8",
|
|
dataType: "json",
|
|
success: function (data) {
|
|
console.log(data);
|
|
alert("保存失败");
|
|
},
|
|
error: function (a, b, c) {
|
|
|
|
alert("ajax请求失败");
|
|
}
|
|
});
|
|
});
|
|
|
|
//加载
|
|
var imgPath = "<%=getSignation()%>"
|
|
var imgData = getBase64Image(imgPath, signature);
|
|
})
|
|
|
|
//远程图片转成base64
|
|
function getBase64Image(path, signature) {
|
|
var img = document.createElement('img');
|
|
img.src = path; //此处自己替换本地图片的地址
|
|
|
|
img.onload = function () {
|
|
var canvas = document.createElement("canvas");
|
|
canvas.width = img.width;
|
|
canvas.height = img.height;
|
|
var ctx = canvas.getContext("2d");
|
|
ctx.drawImage(img, 0, 0, img.width, img.height);
|
|
var dataURL = canvas.toDataURL("image/png");
|
|
|
|
signature.jSignature("setData", dataURL);
|
|
}
|
|
}
|
|
</script>
|
|
<style>
|
|
.container {
|
|
background-color: white;
|
|
height: 350px;
|
|
}
|
|
|
|
.button {
|
|
width: 49%;
|
|
height: 45px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="mui-content">
|
|
<div id="signature" class="container"></div>
|
|
<button type="button" id="btnClear" class="button">清空</button>
|
|
<button type="button" id="btnSave" class="button">修改</button>
|
|
</div>
|
|
</body>
|
|
</html>
|