portal html css js resource

cmp-setBind.js 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. //账号绑定
  2. $(function() {
  3. var emailCookieshow;
  4. var orgid = $.cookie('orgId');
  5. if(orgid == "" || orgid == null || orgid == "null"){
  6. location.href = "cmp-settled-log.html";
  7. }
  8. var orgEmail = $.cookie('orgEmail');
  9. var setemail = false;
  10. $(".bindEmailbtn").click(function() {
  11. modelOpen();
  12. })
  13. $(".modelClosebtn").click(function() {
  14. modelClose();
  15. })
  16. /*回填cookie邮件*/
  17. showEmail();
  18. /*校验邮箱按钮显示状态*/
  19. $('#companyEmail').on('keyup', function() {
  20. if($(this).val() == "") {
  21. $("#saveSubmit").attr("disabled", true);
  22. } else {
  23. $("#saveSubmit").attr("disabled", false);
  24. }
  25. });
  26. /*校验企业邮箱*/
  27. $('#companyEmail').on('focus', function() {
  28. $(".msgBind1 span").text("");
  29. });
  30. $('#companyEmail').on('blur', function() {
  31. checkEmail();
  32. });
  33. /*发送验证邮件*/
  34. $('#saveSubmit').on('click', function() {
  35. reqBindOrgMail();
  36. });
  37. function emailhome(emailset) {
  38. var emailq = emailset.replace(/@.*/, "");
  39. var emailh = emailset.replace(emailq, "");
  40. if(emailq.length >= 6) {
  41. emailCookieshow = emailq.substring(emailq.length - 4, 0) + "****" + emailh;
  42. }
  43. if(emailq.length == 5) {
  44. emailCookieshow = emailq.substring(emailq.length - 3, 0) + "***" + emailh;
  45. }
  46. if(emailq.length == 4) {
  47. emailCookieshow = emailq.substring(emailq.length - 2, 0) + "**" + emailh;
  48. }
  49. if(emailq.length == 3) {
  50. emailCookieshow = emailq.substring(emailq.length - 1, 0) + "*" + emailh;
  51. }
  52. if(emailq.length < 3) {
  53. emailCookieshow = emailq + emailh;
  54. }
  55. return emailCookieshow;
  56. }
  57. function checkEmail() {
  58. companyEmailVal = $("#companyEmail").val();
  59. var gunf = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
  60. if(gunf.test(companyEmailVal.trim())) {
  61. $.ajax("/ajax/isRegOrg", {
  62. data: {
  63. "email": companyEmailVal
  64. },
  65. type: "GET",
  66. dataType: 'json',
  67. async: false,
  68. success: function($data) {
  69. console.log($data)
  70. if($data.data == false) {
  71. $(".msgBind1").prev().addClass("frmmsg-warning");
  72. $(".msgBind1 span").text("该邮箱已绑定,请使用其他邮箱");
  73. } else {
  74. $(".msgBind1").prev().removeClass("frmmsg-warning");
  75. $(".msgBind1 span").text("");
  76. setemail = true;
  77. }
  78. },
  79. error: function() {
  80. $.MsgBox.Alert('提示', '服务器请求失败')
  81. },
  82. });
  83. } else {
  84. $(".msgBind1").prev().addClass("frmmsg-warning");
  85. $(".msgBind1 span").text("请输入正确是邮箱地址");
  86. }
  87. }
  88. function reqBindOrgMail() {
  89. if(setemail) {
  90. $.ajax("/ajax/reqBindOrgMail", {
  91. data: {
  92. "id": orgid,
  93. "mail": companyEmailVal
  94. },
  95. type: "GET",
  96. dataType: 'json',
  97. async: false,
  98. success: function($data) {
  99. console.log($data)
  100. if($data.data) {
  101. $("#emailone").addClass("displayNone");
  102. $("#emailtwo").removeClass("displayNone");
  103. $("#emailShow").text(companyEmailVal);
  104. $("#emailGo").on("click", function() {
  105. var url = companyEmailVal.split('@')[1];
  106. for(var j in hash) {
  107. if(hash[url]==undefined){
  108. window.open("http://mail." + url);
  109. }else{
  110. $(this).attr("href", hash[url]);
  111. window.open(hash[url]);
  112. }
  113. }
  114. location.reload(true);
  115. });
  116. } else {
  117. $.MsgBox.Alert('提示', '发送邮箱验证失败')
  118. }
  119. },
  120. error: function() {
  121. $.MsgBox.Alert('提示', '服务器请求失败')
  122. },
  123. });
  124. }else{
  125. checkEmail();
  126. }
  127. }
  128. function showEmail() {
  129. $.ajax("/ajax/orgUser/orgEmail", {
  130. data: {
  131. "id": orgid
  132. },
  133. type: "GET",
  134. dataType: 'json',
  135. async: false,
  136. success: function($data) {
  137. console.log($data)
  138. if($data.success) {
  139. var orgEmail = $data.data;
  140. emailhome(orgEmail);
  141. $("#orgEmail").text(emailCookieshow);
  142. }
  143. },
  144. error: function() {
  145. $.MsgBox.Alert('提示', '服务器请求失败')
  146. },
  147. });
  148. }
  149. })