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

mySigning.js 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. var qs = parseQueryString(window.location.href),user_id,contractList;
  2. var request = '';
  3. $().ready(function(){
  4. if(qs.user_id){
  5. user_id = qs.user_id;
  6. }
  7. if(!getCookie('user_id') || getCookie('user_id') != user_id){
  8. window.location.href="index.html"
  9. }
  10. contract();//合同列表
  11. })
  12. function contract () {
  13. //合同列表
  14. $(".loading").show();
  15. $.ajax({
  16. type: 'post',
  17. url: request + '/api/contract/index',
  18. data:{
  19. 'user_id':user_id
  20. },
  21. success: function (res) {
  22. $(".loading").hide();
  23. console.log(res)
  24. if(res.status == 200){
  25. contractList = res.data;
  26. var contractListHtml = '',user_info = '';
  27. user_info = res.user_info;
  28. $(".userImg").attr('src',user_info.user_header_url)
  29. contractList.forEach(function(item,index){
  30. var signStatus = '',signStatusColor = '',contractType = '';
  31. if(item.sign_status == 1){signStatus = '待签约';signStatusColor = 'color:red'}
  32. if(item.sign_status == 2){signStatus = '正在签约';signStatusColor = 'color:green'}
  33. if(item.sign_status == 3){signStatus = '签约成功'}
  34. if(item.sign_status == 4){signStatus = '签约失败';signStatusColor = 'color:red'}
  35. if(item.platform_name != 'null' && item.platform_name){contractType = item.platform_name}
  36. var goSigningData = {'sign_status':item.sign_status,'tpl_id':item.tpl_id,'sign_id':item.sign_id,'contract_url':encodeURIComponent(item.contract_url)};
  37. goSigningData = JSON.stringify(goSigningData)
  38. contractListHtml+= "<li onclick='goSigning(" + goSigningData + ")'><div class='orderId'>订单编号:"+ item.sign_id + '</div><div class="contractLi"><img class="contractImg" src=' + user_info.id_card_facade_url + '><div class="contractInfo"><div class="info_one"><span class="name">' + user_info.name + '</span><div class="phone"><img src="img/phone.png"/><span>' + user_info.mobile + '</span></div></div><div class="ID">身份证号:' + user_info.id_card_num + '</div><div class="info_status"><span style=' + signStatusColor + '>状态:' + signStatus + '</span><span>合同类型:' + contractType + '</span></div></div><img class="right_icon" src="img/jiantou.png" /></div></li>';
  39. })
  40. $(".contractList").html(contractListHtml)
  41. }else{
  42. showMsg(res.msg)
  43. }
  44. },
  45. fail: function () {
  46. showMsg('网络错误,请稍后再试~')
  47. $(".loading").hide();
  48. }
  49. })
  50. }
  51. function goSigning (data) {
  52. //去签约页面
  53. console.log(data)
  54. if(data.sign_status == 1 || data.sign_status == 4){
  55. //未签约 签约失败
  56. window.location.href='signing.html?user_id=' + user_id + '&tpl_id=' + data.tpl_id
  57. }
  58. if(data.sign_status == 2){
  59. //正在签约
  60. showMsg('签约中,请稍后查看')
  61. }
  62. if(data.sign_status == 3){
  63. //签约成功
  64. window.location.href = decodeURIComponent(data.contract_url)
  65. // window.location.href="lookPdf.html?contract_url=" + data.contract_url + '&user_id=' + user_id
  66. // contract_view(data.sign_id);//查看合同
  67. }
  68. }
  69. // function contract_view (order_id) {
  70. // $(".loading").show();
  71. // $.ajax({
  72. // type: 'get',
  73. // url: request + '/contract/view',
  74. // data:{
  75. // 'order_id':order_id
  76. // },
  77. // success: function (res) {
  78. // $(".loading").hide();
  79. // console.log(res)
  80. // if(res.status == 200){
  81. // var iframeUrl = decodeURIComponent(res.data);
  82. // window.location.href=iframeUrl;
  83. // }else{
  84. // showMsg(res.msg)
  85. // }
  86. // },
  87. // fail: function () {
  88. // showMsg('网络错误,请稍后再试~')
  89. // $(".loading").hide();
  90. // }
  91. // })
  92. // }
  93. //获取地址栏参数
  94. function parseQueryString(url) {
  95. var urlObj = {};
  96. var reg = /([^?=&]+)=([^?=&]+)/g;
  97. url.replace(reg, function($0, $1, $2) {
  98. urlObj[$1] = decodeURIComponent($2);
  99. })
  100. return urlObj;
  101. }
  102. // 展示错误提示信息
  103. function showMsg(msg) {
  104. var msgBox = document.getElementsByClassName('alert-info')[0];
  105. msgBox.getElementsByTagName("p")[0].innerHTML=msg;
  106. msgBox.style.display="block";
  107. setTimeout(function() {
  108. msgBox.style.display="none";
  109. }, 2000);
  110. }
  111. function goPerfectInfo(){
  112. window.location.href="personalInfo.html?user_id=" + user_id;
  113. }
  114. //取Cookie的值
  115. function getCookie(name) {
  116. var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
  117. if (arr = document.cookie.match(reg)){
  118. return arr[2];
  119. }else{
  120. return false
  121. }
  122. }
  123. //写入到Cookie
  124. //name:cookie名称 value:cookie值
  125. function setCookie(name,value){
  126. var exp = new Date();
  127. exp.setTime(exp.getTime() + 12 * 60 * 60000);//过期时间 12小时
  128. // exp.setTime(exp.getTime() + 60 * 10000);//过期时间 10分钟
  129. document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
  130. }