user-reg.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
  6. <meta http-equiv="x-ua-compatible" content="ie=edge">
  7. <title>用户注册-大司空云计价</title>
  8. <link rel="stylesheet" href="/lib/bootstrap/css/bootstrap.min.css">
  9. <link rel="stylesheet" href="/web/building_saas/css/main.css">
  10. <link rel="stylesheet" href="/lib/font-awesome/font-awesome.min.css">
  11. <link rel="shortcut icon" href="/web/building_saas/css/favicon.ico">
  12. <style>
  13. html{height:100%;}
  14. </style>
  15. </head>
  16. <body class="login-body">
  17. <div class="container">
  18. <form class="form-signin mt-5" method="post" onsubmit="return checkForm();">
  19. <h1 class="d-flex justify-content-center mb-0"><img src="/web/building_saas/img/building.png" width="40" height="40" class="mr-3" style="margin-top:5px"> 大司空云计价</h1>
  20. <p class="text-center mb-4 text-muted">市政、房建、轨道、管廊管线等专业工程计价软件</p>
  21. <p class="h3 text-center mb-3" id="tips">用户注册</p>
  22. <div class="form-group">
  23. <input id="mobile" name="mobile" class="form-control" type="number" placeholder="输入手机号" required="">
  24. <small id="mobiletips" style="display: none" class="form-text text-danger">手机号格式不对</small>
  25. <!-- <small id="e" class="form-text text-danger alert alert-danger">手机号已注册</small> -->
  26. </div>
  27. <div class="form-group">
  28. <button type="button" class="btn btn-outline-primary btn-block" id="get-code">获取验证码</button>
  29. </div>
  30. <div class="form-group">
  31. <input id="code" name="code" class="form-control " placeholder="输入验证码" required="" type="number">
  32. </div>
  33. <div class="form-group" id="error-tips" <% if (err === '') { %>style="display: none;"<% } %>>
  34. <div class="alert alert-danger" role="alert">
  35. <strong>失败</strong> <span id="message"><%= err %></span>
  36. </div>
  37. </div>
  38. <div class="form-group">
  39. <button type="button" id="check-user" class="btn btn-primary btn-block">确认</button>
  40. </div>
  41. <div id="msg" style="display: none">
  42. <hr>
  43. <input id="type" name="type" type="hidden">
  44. <div class="form-group">
  45. <input id="password" disabled name="password" class="form-control " placeholder="输入您的密码" required="" type="password">
  46. <small id="pwd-tips" style="display: none" class="form-text text-danger">密码长度为6~16位,建议使用数字与英文混合</small>
  47. </div>
  48. <div class="form-group">
  49. <select id="province" name="province" class="form-control ">
  50. <option value="-1">企业所在地区</option>
  51. <% provinceList.forEach(function(province, index) {%>
  52. <option value="<%= index %>"><%= province %></option>
  53. <% })%>
  54. </select>
  55. <small id="province-tips" style="display: none" class="form-text text-danger">请选择企业地区</small>
  56. </div>
  57. <div class="form-group">
  58. <input id="company" disabled name="company" class="form-control " placeholder="输入单位信息" required="" type="text">
  59. <small id="company-tips" style="display: none" class="form-text text-danger">请输入单位信息</small>
  60. </div>
  61. <div class="form-group">
  62. <input id="realname" disabled name="real_name" class="form-control " placeholder="输入您的姓名" required="" type="text">
  63. <small id="name-tips" style="display: none" class="form-text text-danger">姓名存在特殊字符或空格</small>
  64. </div>
  65. <div class="form-group">
  66. <input id="qq" disabled name="qq" class="form-control " placeholder="输入您的QQ号" required="" type="text">
  67. <small id="qq-tips" style="display: none" class="form-text text-danger">请输入正确的QQ号码</small>
  68. </div>
  69. <div class="form-group">
  70. <button type="submit" class="btn btn-primary btn-block">注册</button>
  71. </div>
  72. </div>
  73. <div class="form-group mt-5">
  74. <a href="/wap/checkuser" class="btn btn-success btn-block">查询注册状态</a>
  75. </div>
  76. </form>
  77. <!-- <div class="text-white fixed-bottom"><p class="text-center mb-1">Copyright © 2019 <a href="https://smartcost.com.cn" target="_blank" class="text-white">珠海纵横创新软件有限公司</a>.All Rights Reserved.<a class="text-white ml-2" href="http://www.miitbeian.gov.cn" target="_blank">粤ICP备14032472号</a></p></div> -->
  78. </div>
  79. <!-- JS. -->
  80. <script src="/lib/jquery/jquery-3.2.1.min.js"></script>
  81. <script src="/lib/popper/popper.min.js"></script>
  82. <script src="/lib/bootstrap/bootstrap.min.js"></script>
  83. <script src="/web/building_saas/js/global.js"></script>
  84. <script type="text/javascript" src="/web/users/js/gt.js"></script>
  85. <script>
  86. $(function () {
  87. $("#get-code").click(function() {
  88. $('#mobiletips').hide();
  89. const mobile = $("#mobile").val();
  90. if(!validMobile(mobile)){
  91. return false;
  92. }
  93. const btn = $(this);
  94. if(!btn.hasClass('disabled')){
  95. $.ajax({
  96. url: '/sms/code',
  97. type: 'post',
  98. data: { mobile: mobile, type: 3},
  99. error: function() {
  100. $('#mobiletips').text('短信接口出错!').show();
  101. },
  102. beforeSend: function() {
  103. },
  104. success: function(response) {
  105. if (response.err === 0) {
  106. codeSuccess(btn);
  107. } else {
  108. $('#mobiletips').text(response.msg).show();
  109. }
  110. }
  111. });
  112. }
  113. });
  114. $('#check-user').click(function () {
  115. const mobile = $("#mobile").val();
  116. const code = $('#code').val();
  117. $("#error-tips").hide();
  118. $('#mobiletips').hide();
  119. if(!validMobile(mobile)){
  120. return false;
  121. }
  122. if(code === '') {
  123. return false;
  124. }
  125. $.ajax({
  126. type: 'post',
  127. url: '/wap/checkuser',
  128. async: false,
  129. data: { mobile: mobile, code: code },
  130. dataType: 'json',
  131. success: function (result) {
  132. if (result.error === 0) {
  133. if (result.existUser === 1) {
  134. window.location.href = '/wap/checkuser?mobile=' + mobile;
  135. } else {
  136. // $('#mobiletips').text('当前手机号未注册').show();
  137. $('#mobile').attr('readOnly', true);
  138. // $('#tips').text('用户注册');
  139. $('#msg').show();
  140. $('#msg input').removeAttr('disabled');
  141. // $('#check-user').parents('div').addClass('mt-5');
  142. // $('#check-user').siblings('a').show();
  143. $('#check-user').remove();
  144. $('#code').parents('.form-group').remove();
  145. $('#get-code').parents('.form-group').remove();
  146. if (result.existUser === 2) {
  147. $('#password').parents('.form-group').remove();
  148. $('#type').val(2); // 代表sso已有账号
  149. } else {
  150. $('#type').val(1); // 代表同时注册sso
  151. }
  152. }
  153. } else {
  154. showError(result.msg, null);
  155. }
  156. }
  157. })
  158. })
  159. });
  160. /**
  161. * 获取成功后的操作
  162. *
  163. * @param {Object} btn - 点击的按钮
  164. * @return {void}
  165. */
  166. function codeSuccess(btn) {
  167. let counter = 60;
  168. btn.removeClass('btn-primary').addClass('btn-outline-secondary disabled').text('重新获取('+ counter +')');
  169. btn.parents().siblings('div').children('input').removeAttr('readonly');
  170. const countDown = setInterval(function() {
  171. const countString = counter - 1 <= 0 ? '' : counter - 1;
  172. // 倒数结束后
  173. if (countString === '') {
  174. clearInterval(countDown);
  175. btn.removeClass('btn-outline-secondary disabled').addClass('btn-primary').text('获取验证码');
  176. }
  177. const text = '重新获取' + (countString === '' ? '' : '('+ countString +')');
  178. btn.text(text);
  179. counter -= 1;
  180. }, 1000);
  181. }
  182. /**
  183. * 提示错误
  184. *
  185. * @param {string} msg
  186. * @param {object} element
  187. * @return {void}
  188. */
  189. function showError(msg, element) {
  190. if (element !== null) {
  191. element.parent().addClass('has-danger');
  192. }
  193. $("#message").html(msg);
  194. $("#error-tips").show("fast");
  195. }
  196. /**
  197. * 提示错误
  198. *
  199. * @param {string} msg
  200. * @param {object} element
  201. * @return {void}
  202. */
  203. function showError2(msg, element) {
  204. if (element !== null) {
  205. element.parent().addClass('has-danger');
  206. }
  207. $("#message2").html(msg);
  208. $("#error-tips2").show("fast");
  209. }
  210. /**
  211. * 验证手机号是否正确
  212. *
  213. * @return {boolean}
  214. */
  215. function validMobile(mobile, status = 1) {
  216. let result = true;
  217. if($.trim(mobile) === ''){
  218. $('#mobiletips').text('手机号不能为空').show();
  219. return false;
  220. }
  221. let mobileValid = /^1[3456789]\d{9}$/;
  222. if(!mobileValid.test(mobile)){
  223. $('#mobiletips').text('手机号码格式有误!').show();
  224. return false;
  225. }
  226. return result;
  227. }
  228. function checkForm() {
  229. let flag = true;
  230. if (parseInt($('#type').val()) === 1) {
  231. $('#pwd-tips').hide();
  232. const pwd = $('#password').val();
  233. if (pwd.length < 6 || pwd.length > 16) {
  234. flag = false;
  235. $('#pwd-tips').show();
  236. }
  237. }
  238. $('#province-tips').hide();
  239. $('#company-tips').hide();
  240. $('#name-tips').hide();
  241. $('#qq-tips').hide();
  242. const province = parseInt($('#province').val());
  243. if (province === -1) {
  244. flag = false;
  245. $('#province-tips').show();
  246. }
  247. const company = $('#company').val();
  248. if (company === '') {
  249. flag = false;
  250. $('#company-tips').show();
  251. }
  252. const realname = $('#realname').val();
  253. const pattern2 = /^[A-Za-z0-9\u4e00-\u9fa5]+$/gi;
  254. if (!pattern2.test(realname) && realname != '') {
  255. flag = false;
  256. $('#name-tips').show();
  257. }
  258. const qq = $('#qq').val();
  259. const pattern = /^[1-9][0-9]{4,14}$/;
  260. if(!pattern.test(qq) && qq !== ''){
  261. flag = false;
  262. $('#qq-tips').show();
  263. }
  264. if (flag) {
  265. $('button[type="submit"]').text('注册中,请勿退出...').attr('disabled', true);
  266. }
  267. return flag;
  268. }
  269. </script>
  270. </body>
  271. </html>