appeal.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. // 判断选中手机还是邮箱
  2. $("#radio1").click(function () {
  3. if ($('#radio1:checked').length) {
  4. $(".phonenum").show();
  5. $(".mailnum").hide();
  6. }
  7. });
  8. $("#radio2").click(function () {
  9. if ($('#radio2:checked').length) {
  10. $(".phonenum").hide();
  11. $(".mailnum").show();
  12. }
  13. });
  14. if ($('#radio1:checked').length) {
  15. $(".phonenum").show();
  16. $(".mailnum").hide();
  17. }
  18. if ($('#radio2:checked').length) {
  19. $(".phonenum").hide();
  20. $(".mailnum").show();
  21. }
  22. // 点击下一步
  23. $(".next").click(function () {
  24. var preg = /^1[3456789]{1}\d{9}$/;
  25. var sszh = $('input[name=sszh]').val();
  26. var phonenum = $('input[name=phonenum]').val();
  27. var reasons = $('.select').val();
  28. var mailnum = $('input[name=mailnum]').val();
  29. var reg = /^[a-z0-9]+([._-][a-z0-9]+)*@([0-9a-z]+\.[a-z]{2,14}(\.[a-z]{2})?)$/i;
  30. var type = '';
  31. // 手机号
  32. if ($('#radio1:checked').length) {
  33. type = 'mobile';
  34. if (sszh == "" || phonenum == "" || !preg.test(phonenum) || reasons == 0 || $("#but1").prop("checked") == false) {
  35. if (sszh == "") {
  36. $(".no_account").show();
  37. $(".no_account").text("请输入申诉账号");
  38. $("#sszh").css("border", "1px solid #FC6A68")
  39. }
  40. if (phonenum == "" || !preg.test(phonenum)) {
  41. $(".phone_error").show();
  42. $(".phone_error").text("请输入正确的手机号");
  43. $("#phonenum").css("border", "1px solid #FC6A68")
  44. }
  45. if (reasons == 0) {
  46. $(".no_select").show();
  47. $(".no_select").text("请选择申诉原因");
  48. $(".select").css("border", "1px solid #FC6A68")
  49. }
  50. if ($("#but1").prop("checked") == false) {
  51. $(".no_agree").show();
  52. }
  53. } else {
  54. // 跳转手机号验证
  55. toverify(sszh,type,phonenum,reasons,$("#but1").prop("checked"));
  56. }
  57. }
  58. // 邮箱
  59. if ($('#radio2:checked').length) {
  60. type = 'email';
  61. if (sszh == "" || mailnum == "" || !reg.test(mailnum) || reasons == 0 || $("#but1").prop("checked") == false) {
  62. if (sszh == "") {
  63. $(".no_account").show();
  64. $(".no_account").text("请输入申诉账号");
  65. $("#sszh").css("border", "1px solid #FC6A68")
  66. }
  67. if (mailnum == "" || !reg.test(mailnum)) {
  68. $(".mail_error").show();
  69. $(".mail_error").text("请输入正确的邮箱");
  70. $("#mailnum").css("border", "1px solid #FC6A68")
  71. }
  72. if (reasons == 0) {
  73. $(".no_select").show();
  74. $(".no_select").text("请选择申诉原因");
  75. $(".select").css("border", "1px solid #FC6A68")
  76. }
  77. if ($("#but1").prop("checked") == false) {
  78. $(".no_agree").show();
  79. }
  80. } else {
  81. // 跳转邮箱验证
  82. toverify(sszh,type,mailnum,reasons,$("#but1").prop("checked"));
  83. }
  84. }
  85. if ($("#but1").prop("checked") == true) {
  86. $(".no_agree").hide();
  87. }
  88. })
  89. // 失去焦点
  90. $("#sszh").on('blur', function () {
  91. var sszh = $('input[name=sszh]').val();
  92. if (sszh == "") {
  93. $(".no_account").show();
  94. $(".no_account").text("请输入申诉账号");
  95. $("#sszh").css("border", "1px solid #FC6A68")
  96. } else {
  97. $(".no_account").hide();
  98. $("#sszh").css("border", "1px solid #eee")
  99. }
  100. })
  101. $("#phonenum").on('blur', function () {
  102. var preg = /^1[3456789]{1}\d{9}$/;
  103. var phonenum = $('input[name=phonenum]').val();
  104. if (phonenum == "" || !preg.test(phonenum)) {
  105. $(".phone_error").show();
  106. $(".phone_error").text("请输入正确的手机号");
  107. $("#phonenum").css("border", "1px solid #FC6A68")
  108. } else {
  109. $(".phone_error").hide();
  110. $("#phonenum").css("border", "1px solid #eee")
  111. }
  112. })
  113. $("#mailnum").on('blur', function () {
  114. var reg = /^[a-z0-9]+([._-][a-z0-9]+)*@([0-9a-z]+\.[a-z]{2,14}(\.[a-z]{2})?)$/i;
  115. var mailnum = $('input[name=mailnum]').val();
  116. if (mailnum == "" || !reg.test(mailnum)) {
  117. $(".mail_error").show();
  118. $(".mail_error").text("请输入正确的邮箱");
  119. $("#mailnum").css("border", "1px solid #FC6A68")
  120. } else {
  121. $(".mail_error").hide();
  122. $("#mailnum").css("border", "1px solid #eee")
  123. }
  124. })
  125. $(".select").on('blur', function () {
  126. var reasons = $(this).val();
  127. if (reasons == 0) {
  128. $(".no_select").show();
  129. $(".no_select").text("请选择申诉原因");
  130. $(".select").css("border", "1px solid #FC6A68")
  131. } else {
  132. $(".no_select").hide();
  133. $(".select").css("border", "1px solid #eee")
  134. }
  135. })
  136. function toverify(sszh,type,number,reason,agreexy) {
  137. $.ajax({
  138. type: 'POST',
  139. url: "/kefu/zhss",
  140. dataType: 'json',
  141. data: {type:type,username:sszh,number:number,reason:reason,$agreexy:agreexy},
  142. success: function(res) {
  143. //console.log(res);
  144. if (!res.code){
  145. layer.alert(res.msg);
  146. return;
  147. }
  148. window.location.href = res.url;
  149. },
  150. error: function () {
  151. layer.alert('网络错误,请刷新页面重试');
  152. }
  153. });
  154. }
  155. //判断IE浏览器版本(IE8及以下)
  156. var DEFAULT_VERSION = 8.0;
  157. var ua = navigator.userAgent.toLowerCase();
  158. var isIE = ua.indexOf("msie")>-1;
  159. var safariVersion;
  160. if(isIE){
  161. safariVersion = ua.match(/msie ([\d.]+)/)[1];
  162. }
  163. if(safariVersion <= DEFAULT_VERSION ){
  164. $(".remember input").show();
  165. $(".remember label").hide();
  166. };