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

index.js 5.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. var qs = parseQueryString(window.location.href),user_id;
  2. var request = '';
  3. $().ready(function(){
  4. console.log(getCookie('user_id'))
  5. if(getCookie('user_id')){
  6. user_id = getCookie('user_id')
  7. userAuth();//检查用户信息完整性 和 用户信息审核结果
  8. }
  9. })
  10. //取Cookie的值
  11. function getCookie(name) {
  12. var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
  13. if (arr = document.cookie.match(reg)){
  14. return arr[2];
  15. }else{
  16. return false
  17. }
  18. }
  19. //写入到Cookie
  20. //name:cookie名称 value:cookie值
  21. function setCookie(name,value){
  22. var exp = new Date();
  23. exp.setTime(exp.getTime() + 12 * 60 * 60000);//过期时间 12小时
  24. // exp.setTime(exp.getTime() + 60 * 10000);//过期时间 10分钟
  25. document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
  26. }
  27. function registerButton () {
  28. //注册
  29. var phoneNumber = $("#phone").val();
  30. var codeYzm = $("#yzm").val();
  31. if(phoneNumber.length != 11){
  32. showMsg('请正确填写手机号')
  33. return;
  34. }
  35. if(codeYzm.length == 0){
  36. showMsg('请输入手机验证码')
  37. return;
  38. }
  39. $(".loading").show();
  40. $.ajax({
  41. type: 'post',
  42. url: request + '/api/register',
  43. data:{
  44. 'mobile':$("#phone").val(),
  45. 'code':$("#yzm").val()
  46. },
  47. success: function (res) {
  48. $(".loading").hide();
  49. console.log(res)
  50. if(res.status == 200){
  51. setCookie('user_id',res.user_id)
  52. if(res.user_info_is_full == 1){
  53. //用户信息是否完整 0: 不完整 1: 完整
  54. if(res.user_auth_status == 1){ //1: 审核通过, 2, 审核中, 3审核不通过
  55. window.location.href = 'mySigning.html?user_id=' + res.user_id
  56. }else if(res.user_auth_status == 2){
  57. window.location.href='examine.html?type=' + 1 + '&user_id=' + res.user_id;
  58. }else if(res.user_auth_status == 3){
  59. window.location.href='examine.html?type=' + 2 + '&user_id=' + res.user_id + '&reason=' + encodeURI(res.user_auth_deny_cause);
  60. }
  61. }else{
  62. window.location.href = 'perfectInfo.html?user_id=' + res.user_id
  63. }
  64. }else{
  65. showMsg(res.msg)
  66. }
  67. },
  68. fail: function () {
  69. showMsg('网络错误,请稍后再试~')
  70. $(".loading").hide();
  71. }
  72. })
  73. }
  74. function getYzmEvent () {
  75. //获取验证码
  76. var phoneNumber = $("#phone").val();
  77. if(phoneNumber.length != 11){
  78. showMsg('请正确填写手机号')
  79. return;
  80. }
  81. if($(".inputDiv .yzmButton").attr('class').indexOf('yzmButtonActive') != -1){
  82. return;
  83. }
  84. sendCms();
  85. }
  86. function sendCms () {
  87. //发送验证码
  88. $(".loading").show();
  89. $.ajax({
  90. type: 'post',
  91. url: request + '/api/register/sendCms',
  92. data:{
  93. 'mobile':$("#phone").val(),
  94. },
  95. success: function (res) {
  96. $(".loading").hide();
  97. console.log(res)
  98. if(res.status == 200){
  99. $(".inputDiv .yzmButton").addClass('yzmButtonActive');
  100. var downCount = 60;
  101. var time = setInterval(function () {
  102. $(".inputDiv .yzmButton").html(downCount + 's');
  103. downCount--;
  104. if(downCount < 0){
  105. clearInterval(time);
  106. $(".inputDiv .yzmButton").removeClass('yzmButtonActive');
  107. $(".inputDiv .yzmButton").html('获取验证码');
  108. }
  109. },1000)
  110. }else{
  111. showMsg(res.msg)
  112. }
  113. },
  114. fail: function () {
  115. showMsg('网络错误,请稍后再试~')
  116. $(".loading").hide();
  117. }
  118. })
  119. }
  120. function userAuth () {
  121. //发送验证码
  122. $(".loading").show();
  123. $.ajax({
  124. type: 'post',
  125. url: request + '/api/user/auth',
  126. data:{
  127. 'user_id':user_id
  128. },
  129. success: function (res) {
  130. $(".loading").hide();
  131. console.log(res)
  132. if(res.status == 200){
  133. if(res.data.user_info_is_full == 1){
  134. //用户信息是否完整 0: 不完整 1: 完整
  135. if(res.data.user_auth_status == 1){ //1: 审核通过, 2, 审核中, 3审核不通过
  136. window.location.href = 'mySigning.html?user_id=' + res.data.user_id
  137. }else if(res.data.user_auth_status == 2){
  138. window.location.href='examine.html?type=' + 1 + '&user_id=' + res.data.user_id;
  139. }else if(res.data.user_auth_status == 3){
  140. window.location.href='examine.html?type=' + 2 + '&user_id=' + res.data.user_id + '&reason=' + encodeURI(res.data.user_auth_deny_cause);
  141. }
  142. }else{
  143. window.location.href = 'perfectInfo.html?user_id=' + res.data.user_id
  144. }
  145. }else{
  146. showMsg(res.msg)
  147. }
  148. },
  149. fail: function () {
  150. showMsg('网络错误,请稍后再试~')
  151. $(".loading").hide();
  152. }
  153. })
  154. }
  155. //获取地址栏参数
  156. function parseQueryString(url) {
  157. var urlObj = {};
  158. var reg = /([^?=&]+)=([^?=&]+)/g;
  159. url.replace(reg, function($0, $1, $2) {
  160. urlObj[$1] = decodeURIComponent($2);
  161. })
  162. return urlObj;
  163. }
  164. // 展示错误提示信息
  165. function showMsg(msg) {
  166. var msgBox = document.getElementsByClassName('alert-info')[0];
  167. msgBox.getElementsByTagName("p")[0].innerHTML=msg;
  168. msgBox.style.display="block";
  169. setTimeout(function() {
  170. msgBox.style.display="none";
  171. }, 2000);
  172. }