register.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  1. import '../css/bootstrap.less';
  2. import 'bootstrap/dist/js/bootstrap.js';
  3. import '../css/public.css';
  4. import '../css/register.css';
  5. import './public.js'
  6. (function(){
  7. //查看技淘网协议
  8. var hht=$(window).height();
  9. $('.login_').height(hht);
  10. $('.login_').hide()
  11. $('.head_login_').click(function(e){
  12. e.preventDefault();
  13. $('.login_').fadeIn(800)
  14. })
  15. $('.login_close_').click(function(){
  16. $('.login_').fadeOut(800)
  17. })
  18. //登陆
  19. var hht=$(window).height();
  20. $('.login').height(hht);
  21. $('.login').hide()
  22. $('.head_login').click(function(e){
  23. e.preventDefault();
  24. $('.login').fadeIn(800)
  25. })
  26. $('.login_close').click(function(){
  27. $('.login').fadeOut(800)
  28. })
  29. //选择专家和企业时要切换
  30. var panduan;
  31. $("#qiye").click(function(){
  32. panduan=$('#zhuangjia').prop("checked") ? '0' : '1';
  33. console.log(panduan);
  34. if(panduan==1){
  35. $(".businessName").css("display","block");
  36. $(".linkmanName").css("display","block");
  37. $(".zhuangjiaName").css("display","none");
  38. }
  39. });
  40. $("#zhuangjia").click(function(){
  41. panduan=$('#zhuangjia').prop("checked") ? '0' : '1';
  42. console.log(panduan);
  43. if(panduan==0){
  44. $(".businessName").css("display","none");
  45. $(".linkmanName").css("display","none");
  46. $(".zhuangjiaName").css("display","block");
  47. }
  48. });
  49. //点击账号后面那个×,清空账号
  50. $(".log_del").click(function(){
  51. $("#username").val("");
  52. $('#photo').attr('disabled', true);
  53. $("#photo").css("color","#ccc");
  54. $('.sub').attr('disabled', true)
  55. $('.sub').css({background: '#CCCCCC',border: 'none'})
  56. });
  57. //修改单选框的样式
  58. //$('.leibie input').css("display","none");
  59. $(".qiye_lab").css({"background":"url(../img/checked.jpg) no-repeat center left","background-size":"13px 13px"});
  60. $(".zhuangjia_lab").css({"background":"url(../img/unchecked.jpg) no-repeat center left","background-size":"13px 13px"});
  61. $(".protocol_lab").css({"background":"url(../img/unchecked.jpg) no-repeat center left","background-size":"13px 13px"});
  62. $('#qiye').click(function(){
  63. var Cheack=$(this).prop('checked')
  64. if(Cheack){
  65. $(this).parent().css({"background":"url(../img/checked.jpg) no-repeat center left","background-size":"13px 13px"})
  66. $('#zhuangjia').prop('checked',false)
  67. $('#zhuangjia').parent().css({"background":"url(../img/unchecked.jpg) no-repeat center left","background-size":"13px 13px"})
  68. }else{
  69. $('#zhuangjia').prop('checked',true)
  70. $('#zhuangjia').parent().css({"background":"url(../img/checked.jpg) no-repeat center left","background-size":"13px 13px"})
  71. $(this).parent().css({"background":"url(../img/unchecked.jpg) no-repeat center left","background-size":"13px 13px"})
  72. }
  73. })
  74. $('#zhuangjia').click(function(){
  75. var Cheack_no=$(this).prop('checked')
  76. if(Cheack_no){
  77. $(this).parent().css({"background":"url(../img/checked.jpg) no-repeat center left","background-size":"13px 13px"})
  78. $('#qiye').prop('checked',false)
  79. $('#qiye').parent().css({"background":"url(../img/unchecked.jpg) no-repeat center left","background-size":"13px 13px"})
  80. }else{
  81. $('#qiye').prop('checked',true)
  82. $('#qiye').parent().css({"background":"url(../img/checked.jpg) no-repeat center left","background-size":"13px 13px"})
  83. $(this).parent().css({"background":"url(../img/unchecked.jpg) no-repeat center left","background-size":"13px 13px"})
  84. }
  85. })
  86. $('#protocol').click(function(){
  87. var Cheack_no=$(this).prop('checked')
  88. if(Cheack_no){
  89. $(this).parent().css({"background":"url(../img/checked.jpg) no-repeat center left","background-size":"13px 13px"})
  90. }else{
  91. $(this).parent().css({"background":"url(../img/unchecked.jpg) no-repeat center left","background-size":"13px 13px"})
  92. }
  93. $('.sub').attr('disabled', true)
  94. $('.sub').css({background: '#CCCCCC',border: 'none'})
  95. var pp = $('#username').val();//手机号码
  96. var mim = $('#userpassword').val();//密码
  97. var mim2=$('#userpassword2').val();//密码
  98. var toname = $('#business').val();//企业名称
  99. var lxr = $('#linkman').val();//企业联系人
  100. var zj=$('#man').val();//联系人
  101. var yzm = $('#piccode').val();//验证码
  102. var sjyzm = $('#photo_num').val();//手机验证码
  103. var typel = $('#zhuangjia').prop("checked") ? '0' : '1';
  104. var xieyi=$('#protocol').prop("checked");
  105. if(typel==1){
  106. if(pp!==''&&toname!==''&&lxr!==''&&mim!==''&& pass_pattern.test(mim) && sjyzm!==''&& yzm!==''&&pattern.test(pp)&&(mim==mim2)&&(xieyi==true)){
  107. $('.sub').attr('disabled', false);
  108. $('.sub').css({background: '#F18101',border: 'none'})
  109. }
  110. }
  111. if(typel==0){
  112. if(pp!==''&&zj!==''&&mim!==''&& pass_pattern.test(mim) && sjyzm!==''&& yzm!==''&&pattern.test(pp)&&(mim==mim2)&&(xieyi==true)){
  113. $('.sub').attr('disabled', false);
  114. $('.sub').css({background: '#F18101',border: 'none'})
  115. }
  116. }
  117. })
  118. //表单验证
  119. $('.sub').attr('disabled', true)
  120. $('.sub').css({background: '#CCCCCC',border: 'none'})
  121. var pattern = /^1[3|4|5|7|8][0-9]{9}$/;//手机验证正则
  122. var pass_pattern=/^\w{6,12}$/; //密码验证正则
  123. $('#username,#userpassword,#userpassword2,#piccode,#photo_num,#business,#linkman,#man').keyup(function() {
  124. $('.sub').attr('disabled', true)
  125. $('.sub').css({background: '#CCCCCC',border: 'none'})
  126. var pp = $('#username').val();//手机号码
  127. var mim = $('#userpassword').val();//密码
  128. var mim2=$('#userpassword2').val();//密码
  129. var toname = $('#business').val();//企业名称
  130. var lxr = $('#linkman').val();//企业联系人
  131. var zj=$('#man').val();//联系人
  132. var yzm = $('#piccode').val();//验证码
  133. var sjyzm = $('#photo_num').val();//手机验证码
  134. var typel = $('#zhuangjia').prop("checked") ? '0' : '1';
  135. var xieyi=$('#protocol').prop("checked");
  136. if(typel==1){
  137. if(pp!==''&&toname!==''&&lxr!==''&&mim!==''&& pass_pattern.test(mim) && sjyzm!==''&& yzm!==''&&pattern.test(pp)&&(mim==mim2)&&(xieyi==true)){
  138. $('.sub').attr('disabled', false);
  139. $('.sub').css({background: '#F18101',border: 'none'})
  140. }
  141. }
  142. if(typel==0){
  143. if(pp!==''&&zj!==''&&mim!==''&& pass_pattern.test(mim) && sjyzm!==''&& yzm!==''&&pattern.test(pp)&&(mim==mim2)&&(xieyi==true)){
  144. $('.sub').attr('disabled', false);
  145. $('.sub').css({background: '#F18101',border: 'none'})
  146. }
  147. }
  148. })
  149. //密码
  150. function pass1(){
  151. $('#userpassword').blur(function () {
  152. var pass1 = $(this).val();
  153. if (pass1=='') {
  154. $(this).val('');
  155. $(this).attr('placeholder', '请输入6-12位数密码');
  156. } else if (!pass_pattern.test(pass1)) {
  157. //$(this).val('');
  158. $(this).attr('placeholder', '格式:字母、数字、下划线');
  159. }
  160. });
  161. }
  162. pass1();
  163. //密码相同
  164. pass2();
  165. function pass2(){
  166. //密码相同验证
  167. $('#userpassword2').blur(function () {
  168. var orepeat = $(this).val();
  169. var passw = $('#userpassword').val();
  170. if (passw !== orepeat) {
  171. //$(this).val('');
  172. $(this).attr('placeholder', '两次密码不相同')
  173. } else if (passw == '') {
  174. //$(this).val('');
  175. $(this).attr('placeholder', '请再次输入密码')
  176. }
  177. });
  178. $('#userpassword').blur(function () {
  179. var tt=$(userpassword2).val();
  180. var kk=$(this).val();
  181. if ($(this).val() == '') {
  182. $('#userpassword2').attr('placeholder', '请再次输入密码')
  183. }else if(tt!==kk){
  184. // $('#userpassword2').val('');
  185. $('#userpassword2').attr('placeholder', '两次密码不相同')
  186. }
  187. })
  188. }
  189. //手机号码
  190. function photo1(){
  191. var pho_pattern=/^1[3|4|5|7|8][0-9]{9}$/;
  192. $("#username").keyup(function(){
  193. var phol= $(this).val();
  194. console.log(pho_pattern.test(phol));
  195. if(pho_pattern.test(phol)){
  196. $('#photo').attr('disabled', false);
  197. $("#photo").css("color","#F18101");
  198. }else if(!pho_pattern.test(phol)){
  199. $('#photo').attr('disabled', true);
  200. $("#photo").css("color","#ccc");
  201. }
  202. });
  203. $('#username').blur(function () {
  204. var pho= $(this).val();
  205. if (pho=='') {
  206. $(this).val('');
  207. $(this).attr('placeholder', '请输入您的手机号码');
  208. } else if (!pho_pattern.test(pho)) {
  209. // $(this).val('');
  210. $(this).attr('placeholder', '请输入正确的手机号码');
  211. }else if(pho_pattern.test(pho)){
  212. $('#photo').attr('disabled', false);
  213. $("#photo").css("color","#F18101");
  214. }
  215. })
  216. }
  217. photo1();
  218. //手机号码验证
  219. function photo_num(){
  220. $('#photo_num').blur(function () {
  221. var phoa = $(this).val();
  222. if (phoa=='') {
  223. $(this).val('');
  224. $(this).attr('placeholder', '请输入手机上的验证码');
  225. }
  226. })
  227. }
  228. photo_num();
  229. //单位名称
  230. function photo_name(){
  231. $('#business').blur(function () {
  232. var name = $(this).val();
  233. if (name=='') {
  234. $(this).val('');
  235. $(this).attr('placeholder', '请填写工商局注册的全称');
  236. }
  237. })
  238. }
  239. photo_name();
  240. //联系人名称
  241. function lxr_name(){
  242. $('#linkman').blur(function () {
  243. var name = $(this).val();
  244. if (name=='') {
  245. $(this).val('');
  246. $(this).attr('placeholder', '请填写单位联系人的姓名');
  247. }
  248. })
  249. }
  250. lxr_name();
  251. //专家名称
  252. function zj_name(){
  253. $('#man').blur(function () {
  254. var name = $(this).val();
  255. if (name=='') {
  256. $(this).val('');
  257. $(this).attr('placeholder', '请填写您的姓名');
  258. }
  259. })
  260. }
  261. zj_name();
  262. //手机号码验证
  263. //$('#username').blur(function() {
  264. // var kk = $(this).val();
  265. // if (pattern.test(kk) && kk !=='') {
  266. // $('.sub').attr('disabled', false);
  267. // $('.sub').css({
  268. // background: '#428bca',
  269. // border: '1px solid #428bca'
  270. // })
  271. // } else {
  272. // $('.sub').attr('disabled', true)
  273. // $('.sub').css({
  274. // background: '#CCCCCC',
  275. // border: 'none'
  276. // })
  277. // };
  278. //
  279. //});
  280. //表单提交
  281. $("form").submit(function(e) {
  282. var user = $("#username").val();
  283. var password = $("#userpassword").val();
  284. var types = $('#zhuangjia').prop("checked") ? '0' : '1';//团体/个人
  285. var oname = $('#business').val();//企业名称
  286. var opeople = $('#linkman').val();//企业联系人
  287. var people=$('#man').val();//企业联系人
  288. var Code = $("#piccode").val();
  289. var mobileCode = $('#photo_num').val();//手机验证码
  290. e.preventDefault();
  291. console.log(user, password, types, oname, opeople, Code, mobileCode);
  292. if(types==0){
  293. $.ajax({
  294. type: "POST",
  295. dataType: "json",
  296. url: globalConfig.context + "/register",
  297. data: {
  298. "mobile": user,
  299. "password": password,
  300. "type": types,
  301. "contacts": people,
  302. "verficationCode":Code,
  303. "mobileCode": mobileCode
  304. },
  305. success: function (rest) {
  306. if (rest.error && rest.error.length) {
  307. message.warning(rest.error[0].message);
  308. } else {
  309. var data = rest.data;
  310. if (data && data.requestURI) {
  311. var path = globalConfig.context + data.requestURI
  312. if (data.queryString) {
  313. path += '?' + data.queryString;
  314. }
  315. if (window.location.hash) {
  316. path += window.location.hash;
  317. }
  318. window.location.href = path;
  319. } else {
  320. window.location.href = globalConfig.context + "/user/account/index.html";
  321. }
  322. return true;
  323. }
  324. }
  325. })
  326. }
  327. else if(types==1){
  328. $.ajax({
  329. type: "POST",
  330. dataType: "json",
  331. url: globalConfig.context + "/register",
  332. data: {
  333. "mobile": user,
  334. "password": password,
  335. "type": types,
  336. "companyName": oname,
  337. "contacts": opeople,
  338. "verficationCode":Code,
  339. "mobileCode": mobileCode
  340. },
  341. success: function (rest) {
  342. if (rest.error && rest.error.length) {
  343. message.warning(rest.error[0].message);
  344. } else {
  345. var data = rest.data;
  346. if (data && data.requestURI) {
  347. var path = globalConfig.context + data.requestURI
  348. if (data.queryString) {
  349. path += '?' + data.queryString;
  350. }
  351. if (window.location.hash) {
  352. path += window.location.hash;
  353. }
  354. window.location.href = path;
  355. } else {
  356. window.location.href = globalConfig.context + "/user/account/index.html";
  357. }
  358. return true;
  359. }
  360. }
  361. })
  362. }
  363. })
  364. //点击刷新图片验证码
  365. $('.yanzhengma_cont').click(function () {
  366. $('.yanzhengma_cont img').attr('src', (globalConfig.context + "/open/getVCode?t=" + Math.random()))
  367. })
  368. var tt = 30;
  369. $('#photo').click(function () {
  370. //手机验证功能
  371. var ophoto = $('#username').val();
  372. var types = $('#zhuangjia').prop("checked") ? '0' : '1';
  373. console.log(types);
  374. var phott = $('#piccode').val();
  375. //验证码倒计时
  376. $('#photo').attr('disabled', true);
  377. $(this).attr('disabled', true);
  378. var timer = setInterval(function () {
  379. tt -= 1;
  380. $('#photo').attr('disabled', true);
  381. $(this).val(tt + ' s');
  382. if (tt == 0) {
  383. clearInterval(timer);
  384. $('#photo').attr('disabled', false);
  385. $(this).attr('disabled', false);
  386. tt=30;
  387. $(this).val('重新发送');
  388. }
  389. }.bind(this), 1000);
  390. $.ajax({
  391. type: "GET",
  392. url: globalConfig.context + "/open/getMCode",
  393. data: {
  394. "mobile": ophoto,
  395. "sign": false,
  396. "type": types,
  397. "verificationCode": phott
  398. },
  399. success: function (data) {
  400. if (data.error && data.error.length) {
  401. $('.msg span').html(data.error[0].message);
  402. console.log(data.error[0].message);
  403. } else {
  404. console.log(data);
  405. $('#photo').html("发送成功!")
  406. }
  407. return true
  408. }
  409. });
  410. })
  411. })();