complete.html 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <!DOCTYPE HTML>
  2. <html xmlns:th="http://www.thymeleaf.org"
  3. xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
  4. layout:decorate="~{admin/common/common}">
  5. <head>
  6. <title>完善信息</title>
  7. <style>
  8. label.error {
  9. left: 15px;
  10. top: 29px
  11. }
  12. .ke-container {
  13. width: 100% !important;
  14. }
  15. .ke-swfupload-body {
  16. height: 265px
  17. }
  18. .ke-dialog-body {
  19. height: 340px !important;
  20. }
  21. .ke-dialog-default {
  22. height: 410px !important;
  23. }
  24. </style>
  25. </head>
  26. <body layout:fragment="content">
  27. <article class="page-container">
  28. <form class="form form-horizontal" id="form-information-add">
  29. <div class="row cl">
  30. <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>姓名:</label>
  31. <div class="formControls col-xs-8 col-sm-3">
  32. <div class="add_contact">
  33. <p><input type="text" required minlength="1" maxlength="45" class="width_200 input-text user_name"
  34. placeholder="请输入联系人姓名" th:name="user_name" th:value="${user.user_name}"/></p>
  35. </div>
  36. </div>
  37. </div>
  38. <div class="row cl">
  39. <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>账号名:</label>
  40. <div class="formControls col-xs-8 col-sm-3">
  41. <div class="add_contact">
  42. <p><input type="text" required class="ml_50 width_200 input-text nick_name" th:name="nick_name" th:id="nick_name"
  43. th:value="${user.nick_name}" placeholder="账户名可以为组织机构代码等"/></p>
  44. </div>
  45. </div>
  46. </div>
  47. <div class="row cl">
  48. <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>手机号:</label>
  49. <div class="formControls col-xs-8 col-sm-3">
  50. <div class="add_contact">
  51. <p><input type="text" required isMobile="true" class="ml_50 width_200 input-text phone"
  52. placeholder="请输入手机号" th:name="phone" th:id="phone" th:value="${user.phone}"/></p>
  53. <input id="verificationCode" onClick="getVerificationCode()" type="button"
  54. class="btn btn-primary radius" value="获取验证码"/>
  55. </div>
  56. </div>
  57. </div>
  58. <div class="row cl">
  59. <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>验证码:</label>
  60. <div class="formControls col-xs-8 col-sm-3">
  61. <div class="add_contact">
  62. <p><input type="text" required class="ml_50 width_200 input-text" th:name="validateNum"
  63. placeholder="请输入短信验证码"/></p>
  64. </div>
  65. </div>
  66. </div>
  67. <input type="text" required class="ml_50 width_200 input-text" th:name="user_id" th:id="user_id" hidden th:value="${user.id}"/>
  68. <!-- 企业信息 ------------------------------------------- 结束 -->
  69. <div class="row cl">
  70. <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
  71. <button class="btn btn-primary radius" type="submit">确定</button>
  72. <button onClick="removeIframe();" class="btn btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
  73. </div>
  74. </div>
  75. </form>
  76. </article>
  77. <script th:inline="javascript">
  78. /**
  79. * 取消
  80. */
  81. function removeIframe() {
  82. var index = parent.layer.getFrameIndex(window.name);
  83. parent.layer.close(index);
  84. }
  85. //获取验证码
  86. function getVerificationCode() {
  87. var phone = $("#phone").val();
  88. var v_regex = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
  89. if (phone) {
  90. if (v_regex.test(phone)) {
  91. //checkPhoneNumber(phone)
  92. startCountDown();
  93. sendVerificationCode(phone);
  94. } else {
  95. errorMessage('手机号码格式不正确!');
  96. }
  97. } else {
  98. errorMessage('请输入手机号码!');
  99. }
  100. }
  101. //校验手机号码是否已被使用
  102. function checkPhoneNumber(phone) {
  103. $.ajax({
  104. dataType: "json",
  105. contentType: "application/json;charset=utf-8",
  106. url: pagePath + "/company/companyInfoManage/getPhone",
  107. type: "get",
  108. sync: true,
  109. data: {
  110. phone: phone
  111. },
  112. success: function (result) {
  113. if (result) {
  114. sendVerificationCode(phone);
  115. } else {
  116. errorMessage('该手机号码已被注册!');
  117. }
  118. },
  119. error: function () {
  120. errorMessage('系统错误!');
  121. }
  122. });
  123. }
  124. //发送验证码
  125. function sendVerificationCode(phone) {
  126. $.ajax({
  127. contentType: "application/json;charset=utf-8",
  128. dataType: "json",
  129. url: pagePath + "/home/sendVerificationCode",
  130. type: "get",
  131. sync: true,
  132. data: {
  133. phone: phone
  134. },
  135. success: function (result) {
  136. if (result.success) {
  137. succeedMessage(result.message);
  138. //startCountDown();
  139. } else {
  140. errorMessage(result.message);
  141. }
  142. },
  143. error: function () {
  144. errorMessage('系统错误!');
  145. }
  146. });
  147. }
  148. //验证码倒计时
  149. function startCountDown() {
  150. var second = 60;//时间默认值
  151. $("#verificationCode").attr("disabled", true);
  152. var timer = null;
  153. timer = setInterval(function () {
  154. $("#verificationCode").val(second + "秒后重发")
  155. second--;
  156. if (second < 0) {
  157. $("#verificationCode").attr("disabled", false);
  158. $("#verificationCode").val("获取验证码")
  159. clearInterval(timer);
  160. }
  161. }, 1000);
  162. }
  163. //保存信息
  164. $("#form-information-add").validate({
  165. rules: {
  166. nick_name: {
  167. minlength: 1,
  168. maxlength: 60,
  169. remote: {
  170. url: pagePath + "/company/companyInfoManage/getNickName",
  171. type: "get",
  172. data: {
  173. nick_name: function () {
  174. return $("#nick_name").val();
  175. },
  176. id: function () {
  177. return $("#user_id").val();
  178. },
  179. }
  180. },
  181. },
  182. user_name: {
  183. minlength: 1,
  184. maxlength: 20
  185. },
  186. phone: {
  187. minlength: 1,
  188. maxlength: 20,
  189. phone: true
  190. },
  191. validateNum: {
  192. minlength: 1,
  193. maxlength: 20
  194. },
  195. },
  196. messages: {
  197. nick_name: {
  198. remote: "该账号名已被注册!"
  199. },
  200. },
  201. //debug:true,
  202. onkeyup: false,
  203. focusCleanup: true,
  204. success: "valid",
  205. submitHandler: function (form) {
  206. $(form).ajaxSubmit({
  207. type: 'post',
  208. url: pagePath + "/home/complete",
  209. dataType: "json",
  210. success: function (data) {
  211. if (data.success) {
  212. succeedMessage(data.message);
  213. setTimeClose();
  214. } else {
  215. // $(form).find(":submit").attr("disabled", false);
  216. errorMessage(data.message);
  217. }
  218. },
  219. error: function () {
  220. errorMessage('系统错误!');
  221. }
  222. });
  223. return false; // 非常重要,如果是false,则表明是不跳转,在本页上处理,也就是ajax,如果是非false,则传统的form跳转。
  224. }
  225. });
  226. </script>
  227. </body>
  228. </html>