index.html 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width,initial-scale=1">
  6. <title>签名</title>
  7. <script type="text/javascript" src="js/jquery-1.11.0.min.js"></script>
  8. <script type="text/javascript" src="js/layer/layer.js"></script>
  9. <script type="text/javascript" src="js/Signature/jSignature.js"></script>
  10. <style type="text/css">
  11. body {
  12. position: absolute;
  13. top: 0;
  14. bottom: 0;
  15. right: 0;
  16. left: 0;
  17. }
  18. h3 {
  19. margin: 5px auto;
  20. font-size: 22px;
  21. color: #515e7e;
  22. word-break: break-all;
  23. }
  24. .inputbtn {
  25. display: inline-block;
  26. width: 100px;
  27. height: 52px;
  28. border-radius: 5px;
  29. font-size: 16px;
  30. font-weight: bold;
  31. vertical-align: middle;
  32. line-height: 52px;
  33. text-align: center;
  34. margin-top: 10px;
  35. border: none;
  36. background-color: #108EE9;
  37. color: #FFFFFF;
  38. }
  39. .inputbtn:hover {
  40. cursor: pointer;
  41. background-color: crimson;
  42. }
  43. </style>
  44. </head>
  45. <body>
  46. <h3>请在下方签名</h3>
  47. <div id="signature" style="border: 1px dashed #000; width: calc(100%); height: calc(100% - 150px);"></div>
  48. <div id="tools" style="text-align: center; width: 100%;">
  49. <input id="clear" class="inputbtn " type="button" value="清除">
  50. <input id="btnSignConfirm" class="inputbtn " type="button" value="确认完成">
  51. </div>
  52. <script type="text/javascript" charset="utf-8">
  53. $(document).ready(function () {
  54. $("#signature").jSignature({
  55. 'width': '100%',
  56. 'height': '100%'
  57. });
  58. });
  59. $("#clear").bind('click', function () {
  60. $("#signature").jSignature("reset");
  61. });
  62. $("#btnSignConfirm").bind('click', function () {
  63. var datapair = $("#signature").jSignature("getData", "image");
  64. var array = datapair.splice(",");
  65. var data = $("#signature").jSignature('getData', 'image');
  66. var hasimg = $("#signature").jSignature('getData', 'native').length;
  67. var signbase64 = "";
  68. if (hasimg == 0) {
  69. var strdivyy = '<div ><p class="auto-close">未签字,请先签字!</p></div>';
  70. layer.open({
  71. type: 1,
  72. title: "温馨提示",
  73. area: ['400px', '200px'],
  74. content: strdivyy,
  75. skin: 'layer-ext-iframe',
  76. move: false,
  77. btn: "",
  78. time: 2000
  79. });
  80. } else {
  81. //获取签字图片的base64
  82. if (typeof data === 'string') {
  83. signbase64 = data.replace('image/png;base64,', '');
  84. } else if ($.isArray(data) && data.length === 2) {
  85. signbase64 = data.join(',').replace('image/png;base64,', '');
  86. } else {
  87. signbase64 = "";
  88. }
  89. if (successfunc) {
  90. successfunc(signbase64);
  91. }
  92. }
  93. });
  94. function successfunc(signbase64) {
  95. var load = layer.msg("提交中,请稍等", {
  96. icon: 16,
  97. shade: [0.1, '#fff'],
  98. time: false //取消自动关闭
  99. });
  100. $.ajax({
  101. url: '../DataHandle.ashx',
  102. type: 'POST',
  103. async: false,
  104. data: {
  105. "InitType": "updateSign",
  106. "RowGuid": "b8a694b2-984e-4a3c-9961-a300a8e13f0f",
  107. "tno": "794027",
  108. "Sign": signbase64
  109. },
  110. dataType: 'json',
  111. contentType: "application/x-www-form-urlencoded; charset=utf-8",
  112. success: function (data) {
  113. if (data.Flag) {
  114. layer.closeAll();
  115. layer.alert("签名成功,请关闭!");
  116. $("#clear").unbind('click');
  117. $("#btnSignConfirm").unbind('click');
  118. }
  119. else {
  120. layer.alert(data.Message);
  121. }
  122. },
  123. error: function (err) {
  124. layer.alert('系统异常!');
  125. console.error(err);
  126. }
  127. });
  128. }
  129. </script>
  130. </body>
  131. </html>