新媒体-合同签约,CA签约

signing.js 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. var qs = parseQueryString(window.location.href),user_id,userInfoData;
  2. // var request = 'http://182.92.118.1:5090';
  3. var request = '',signatureUrl='';
  4. $().ready(function(){
  5. if(qs.user_id){
  6. user_id = qs.user_id;
  7. }
  8. if(qs.tpl_id){
  9. tpl_id = qs.tpl_id;
  10. }
  11. // if(!getCookie('user_id') || getCookie('user_id') != user_id){
  12. // window.location.href="index.html"
  13. // }
  14. // userInfo();//用户信息
  15. })
  16. function userInfo () {
  17. //用户信息
  18. $(".loading").show();
  19. $.ajax({
  20. type: 'get',
  21. url: request + '/userInfo',
  22. data:{
  23. 'user_id':user_id
  24. },
  25. success: function (res) {
  26. $(".loading").hide();
  27. console.log(res)
  28. if(res.status == 200){
  29. userInfoData = res.data;
  30. var party_B_html = '<p>甲方(姓名):' + res.data.name + '</p><p>地址:' + res.data.address + '</p><p>身份证号:' + res.data.id_card_num + '</p><p>快手ID:' + res.data.platform_account + '</p><p>移动电话:' + res.data.mobile + '</p>';
  31. var detailTimeHtml = '<div class="">甲方:' + res.data.name + '</div><div>签字:' + res.data.name + '</div><div></div>日期:' + format() + '</div>';
  32. $('.party_B').html(party_B_html)
  33. $('#nail').html(detailTimeHtml)
  34. $(".detailTime .time").html('日期:' + format())
  35. }else{
  36. showMsg(res.msg)
  37. }
  38. },
  39. fail: function () {
  40. showMsg('网络错误,请稍后再试~')
  41. $(".loading").hide();
  42. }
  43. })
  44. }
  45. function format(){
  46. //shijianchuo是整数,否则要parseInt转换
  47. var time = new Date();
  48. var y = time.getFullYear();
  49. var m = time.getMonth() + 1;
  50. var d = time.getDate();
  51. var h = time.getHours();
  52. var mm = time.getMinutes();
  53. var s = time.getSeconds();
  54. return y + '年' + m + '月' + d + '日';
  55. }
  56. function signingEvent() {
  57. //阅读并签约
  58. console.log('签约')
  59. $(".loading").show();
  60. $.ajax({
  61. type: 'get',
  62. url: request + '/contract',
  63. data:{
  64. 'user_id':user_id,
  65. 'tpl_id':tpl_id,
  66. 'signPic':signatureUrl
  67. },
  68. success: function (res) {
  69. $(".loading").hide();
  70. console.log(res)
  71. if(res.status == 200 || res.status == 201){
  72. if(res.status == 201){
  73. showMsg(res.msg);//已经签约过
  74. }
  75. // contract_view(res.order_id)
  76. // window.open(res.view_url)
  77. window.location.href = decodeURIComponent(res.view_url)
  78. // window.location.href="lookPdf.html?contract_url=" + res.view_url + '&user_id=' + user_id
  79. // window.location.href=decodeURIComponent();
  80. }else{
  81. showMsg(res.msg)
  82. }
  83. },
  84. fail: function () {
  85. showMsg('网络错误,请稍后再试~')
  86. $(".loading").hide();
  87. }
  88. })
  89. }
  90. //获取地址栏参数
  91. function parseQueryString(url) {
  92. var urlObj = {};
  93. var reg = /([^?=&]+)=([^?=&]+)/g;
  94. url.replace(reg, function($0, $1, $2) {
  95. urlObj[$1] = decodeURIComponent($2);
  96. })
  97. return urlObj;
  98. }
  99. // 展示错误提示信息
  100. function showMsg(msg) {
  101. var msgBox = document.getElementsByClassName('alert-info')[0];
  102. msgBox.getElementsByTagName("p")[0].innerHTML=msg;
  103. msgBox.style.display="block";
  104. setTimeout(function() {
  105. msgBox.style.display="none";
  106. }, 2000);
  107. }
  108. //取Cookie的值
  109. function getCookie(name) {
  110. var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
  111. if (arr = document.cookie.match(reg)){
  112. return arr[2];
  113. }else{
  114. return false
  115. }
  116. }
  117. //写入到Cookie
  118. //name:cookie名称 value:cookie值
  119. function setCookie(name,value){
  120. var exp = new Date();
  121. exp.setTime(exp.getTime() + 12 * 60 * 60000);//过期时间 12小时
  122. // exp.setTime(exp.getTime() + 60 * 10000);//过期时间 10分钟
  123. document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
  124. }
  125. function goSignature () {//去签名
  126. $(".signatureDiv").show();
  127. $('.js-signature').jqSignature();
  128. $('.js-signature').on('jq.signature.changed', function() {
  129. $('#saveBtn').attr('disabled', false);
  130. });
  131. document.getElementsByClassName("js-signature")[0].addEventListener('touchstart', startEventHandler, {passive: false});
  132. function startEventHandler(event) {
  133. event.preventDefault();
  134. }
  135. }
  136. function clearCanvas() {
  137. // $('#signature').html('<p><em>Your signature will appear here when you click "Save Signature"</em></p>');
  138. $('.js-signature').jqSignature('clearCanvas');
  139. $('#saveBtn').attr('disabled', true);
  140. }
  141. function saveSignature() {
  142. $('#signature').empty();
  143. var dataUrl = $('.js-signature').jqSignature('getDataURL');
  144. signatureUrl = dataUrl
  145. var img = $('<img>').attr('src', dataUrl);
  146. // $('#signature').append($('<p>').text("Here's your signature:"));
  147. $('#signature').append(img);
  148. $(".signatureDiv").hide();
  149. $(".contract_button2").show();
  150. $(".contract_button1").hide();
  151. }