registered.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. //import '../css/bootstrap.less';
  2. //import 'bootstrap/dist/js/bootstrap.js';
  3. //import '../css/public.css';
  4. //import '../css/registered.css';
  5. //import './public.js'
  6. (function(){
  7. //选择专家和企业时要切换
  8. var panduan;
  9. $("#zhuangjia").click(function(){
  10. panduan=$("#zhuangjia").val();
  11. if(panduan==0){
  12. $(".businessName").css("display","block");
  13. $(".linkmanName").css("display","block");
  14. $(".zhuangjiaName").css("display","none");
  15. }
  16. });
  17. $("#qiye").click(function(){
  18. panduan=$("#qiye").val();
  19. if(panduan==1){
  20. $(".businessName").css("display","none");
  21. $(".linkmanName").css("display","none");
  22. $(".zhuangjiaName").css("display","block");
  23. }
  24. });
  25. //点击账号后面那个×,清空账号
  26. $(".log_del").click(function(){
  27. $("#username").val("");
  28. });
  29. //修改单选框的样式
  30. //$('.leibie input').css("display","none");
  31. $(".leibie").css({"background":"url(../img/unchecked.jpg) no-repeat center left","background-size":"13px 13px"});
  32. $('.leibie input').click(function(){
  33. var Cheack=$(this).prop('checked');
  34. if(Cheack){
  35. //$(this).css("display","none");
  36. $(".leibie").css({"background":"url(../img/unchecked.jpg) no-repeat center left","background-size":"13px 13px"});
  37. $(this).parent().css({"background":"url(../img/checked.jpg) no-repeat center left","background-size":"13px 13px"})
  38. }else{
  39. // $(this).css("display","none");
  40. $(".leibie").css({"background":"url(../img/unchecked.jpg) no-repeat center left","background-size":"13px 13px"});
  41. $(this).parent().css({"background":"url(../img/unchecked.jpg) no-repeat center left","background-size":"13px 13px"})
  42. }
  43. });
  44. //表单验证
  45. $('.sub').attr('disabled', true)
  46. $('.sub').css({background: '#CCCCCC',border: 'none'})
  47. var pattern = /^1[3|4|5|7|8][0-9]{9}$/;//手机验证正则
  48. var pass_pattern=/^\w{6,12}$/; //密码验证正则
  49. $('#username,#userpassword,#piccode,#photo_num,#business,#linkman,#man').keyup(function() {
  50. $('.sub').attr('disabled', true)
  51. $('.sub').css({background: '#CCCCCC',border: 'none'})
  52. var pp = $('#username').val();//手机号码
  53. var mim = $('#userpassword').val();//密码
  54. var toname = $('#business').val();//企业名称
  55. var lxr = $('#linkman').val();//企业联系人
  56. var zj=$('#man').val();//联系人
  57. var yzm = $('#piccode').val();//验证码
  58. var sjyzm = $('#photo_num').val();//手机验证码
  59. var typel = $('#zhuangjia').prop("checked") ? '1' : '0';
  60. if(typel==1){
  61. if(pp!==''&&toname!==''&&lxr!==''&&mim!==''&& pass_pattern.test(mim) && sjyzm!==''&& yzm!==''&&pattern.test(pp)){
  62. $('.sub').attr('disabled', false);
  63. $('.sub').css({background: '#F18101',border: 'none'})
  64. }
  65. }
  66. if(typel==0){
  67. if(pp!==''&&zj!==''&&mim!==''&& pass_pattern.test(mim) && sjyzm!==''&& yzm!==''&&pattern.test(pp)){
  68. $('.sub').attr('disabled', false);
  69. $('.sub').css({background: '#F18101',border: 'none'})
  70. }
  71. }
  72. })
  73. //密码
  74. function pass1(){
  75. $('#userpassword').blur(function () {
  76. var pass1 = $(this).val();
  77. if (pass1=='') {
  78. $(this).val('');
  79. $(this).attr('placeholder', '请输入6-12位数密码');
  80. } else if (!pass_pattern.test(pass1)) {
  81. $(this).val('');
  82. $(this).attr('placeholder', '格式:字母、数字、下划线');
  83. }
  84. });
  85. }
  86. pass1();
  87. //密码相同
  88. pass2();
  89. function pass2(){
  90. //密码相同验证
  91. $('#userpassword2').blur(function () {
  92. var orepeat = $(this).val();
  93. var passw = $('#userpassword').val();
  94. if (passw !== orepeat) {
  95. $(this).val('');
  96. $(this).attr('placeholder', '两次密码不相同')
  97. } else if (passw == '') {
  98. $(this).val('');
  99. $(this).attr('placeholder', '请再次输入密码')
  100. }
  101. });
  102. $('#userpassword').blur(function () {
  103. var tt=$(userpassword2).val();
  104. var kk=$(this).val();
  105. if ($(this).val() == '') {
  106. $('#userpassword2').attr('placeholder', '请再次输入密码')
  107. }else if(tt!==kk){
  108. $('#userpassword2').val('');
  109. $('#userpassword2').attr('placeholder', '两次密码不相同')
  110. }
  111. })
  112. }
  113. //手机号码
  114. function photo1(){
  115. var pho_pattern=/^1[3|4|5|7|8][0-9]{9}$/;
  116. $('#username').blur(function () {
  117. var pho = $(this).val();
  118. if (pho=='') {
  119. $(this).val('');
  120. $(this).attr('placeholder', '请输入您的手机号码');
  121. } else if (!pho_pattern.test(pho)) {
  122. $(this).val('');
  123. $(this).attr('placeholder', '请输入正确的手机号码');
  124. }else if(pho_pattern.test(pho)){
  125. $('#photo').attr('disabled', false);
  126. $("#photo").css("color","#F18101");
  127. }
  128. })
  129. }
  130. photo1();
  131. //手机号码验证
  132. function photo_num(){
  133. $('#photo_num').blur(function () {
  134. var phoa = $(this).val();
  135. if (phoa=='') {
  136. $(this).val('');
  137. $(this).attr('placeholder', '请输入手机上的验证码');
  138. }
  139. })
  140. }
  141. photo_num();
  142. //单位名称
  143. function photo_name(){
  144. $('#business').blur(function () {
  145. var name = $(this).val();
  146. if (name=='') {
  147. $(this).val('');
  148. $(this).attr('placeholder', '请填写工商局注册的全称');
  149. }
  150. })
  151. }
  152. photo_name();
  153. //联系人名称
  154. function lxr_name(){
  155. $('#linkman').blur(function () {
  156. var name = $(this).val();
  157. if (name=='') {
  158. $(this).val('');
  159. $(this).attr('placeholder', '请填写单位联系人的姓名');
  160. }
  161. })
  162. }
  163. lxr_name();
  164. //专家名称
  165. function zj_name(){
  166. $('#man').blur(function () {
  167. var name = $(this).val();
  168. if (name=='') {
  169. $(this).val('');
  170. $(this).attr('placeholder', '请填写您的姓名');
  171. }
  172. })
  173. }
  174. zj_name();
  175. //手机号码验证
  176. //$('#username').blur(function() {
  177. // var kk = $(this).val();
  178. // if (pattern.test(kk) && kk !=='') {
  179. // $('.sub').attr('disabled', false);
  180. // $('.sub').css({
  181. // background: '#428bca',
  182. // border: '1px solid #428bca'
  183. // })
  184. // } else {
  185. // $('.sub').attr('disabled', true)
  186. // $('.sub').css({
  187. // background: '#CCCCCC',
  188. // border: 'none'
  189. // })
  190. // };
  191. //
  192. //});
  193. //表单提交
  194. $("form").submit(function(e) {
  195. var user = $("#username").val();
  196. var password = $("#userpassword").val();
  197. var types = $('#zhuangjia').prop("checked") ? '0' : '1';//团体/个人
  198. var oname = $('#business').val();//企业名称
  199. var opeople = $('#linkman').val();//联系人
  200. var Code = $("#piccode").val();
  201. var mobileCode = $('#photo_num').val();//手机验证码
  202. e.preventDefault();
  203. console.log(user, password, types, oname, opeople, Code, mobileCode);
  204. $.ajax({
  205. type: "POST",
  206. dataType: "json",
  207. url: globalConfig.context + "/register",
  208. data: {
  209. "mobile": user,
  210. "password": password,
  211. "type": types,
  212. "companyName": oname,
  213. "contacts": opeople,
  214. "verficationCode":Code,
  215. "mobileCode": mobileCode
  216. },
  217. success: function (data) {
  218. if (data.error && data.error.length) {
  219. $('.msg span').html(data.error[0].message);
  220. console.log(data.error[0].message);
  221. } else {
  222. console.log(data);
  223. $('.msg span').html("恭喜注册成功!")
  224. return true;
  225. }
  226. }
  227. })
  228. })
  229. //点击刷新图片验证码
  230. $('.yanzhengma_cont').click(function () {
  231. $('.yanzhengma_cont img').attr('src', (globalConfig.context + "/open/getVCode?t=" + Math.random()))
  232. })
  233. var tt = 30;
  234. $('#photo').click(function () {
  235. //手机验证功能
  236. var ophoto = $('#username').val();
  237. var types = $('#zhuangjia').prop("checked") ? '0' : '1';
  238. console.log(types);
  239. var phott = $('#piccode').val();
  240. //验证码倒计时
  241. $('#photo').attr('disabled', true);
  242. $(this).attr('disabled', true);
  243. var timer = setInterval(function () {
  244. tt -= 1;
  245. $('#photo').attr('disabled', true);
  246. $(this).val(tt + ' s');
  247. if (tt == 0) {
  248. clearInterval(timer);
  249. $('#photo').attr('disabled', false);
  250. $(this).attr('disabled', false);
  251. tt=30;
  252. $(this).val('重新发送');
  253. }
  254. }.bind(this), 1000);
  255. $.ajax({
  256. type: "GET",
  257. url: globalConfig.context + "/open/getMCode",
  258. data: {
  259. "mobile": ophoto,
  260. "sign": false,
  261. "type": types,
  262. "verificationCode": phott
  263. },
  264. success: function (data) {
  265. if (data.error && data.error.length) {
  266. $('.msg span').html(data.error[0].message);
  267. console.log(data.error[0].message);
  268. } else {
  269. console.log(data);
  270. $('#photo').html("发送成功!")
  271. }
  272. return true
  273. }
  274. });
  275. })
  276. })();