register.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  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. $('.head_login_').click(function(e){
  11. e.preventDefault();
  12. $('.login_').fadeIn(800)
  13. })
  14. $('.login_close_').click(function(){
  15. $('.login_').fadeOut(800)
  16. })
  17. //登陆
  18. var hht=$(window).height();
  19. $('.login').height(hht);
  20. $('.login').hide()
  21. $('.head_login').click(function(e){
  22. e.preventDefault();
  23. $('.login').fadeIn(800)
  24. })
  25. $('.login_close').click(function(){
  26. $('.login').fadeOut(800)
  27. })
  28. //选择专家和企业时要切换
  29. var panduan;
  30. $("#qiye").click(function(){
  31. panduan=$('#zhuangjia').prop("checked") ? '0' : '1';
  32. if(panduan==1){
  33. $(".businessName").css("display","block");
  34. $(".linkmanName").css("display","block");
  35. $(".zhuangjiaName").css("display","none");
  36. }
  37. });
  38. $("#zhuangjia").click(function(){
  39. panduan=$('#zhuangjia').prop("checked") ? '0' : '1';
  40. if(panduan==0){
  41. $(".businessName").css("display","none");
  42. $(".linkmanName").css("display","none");
  43. $(".zhuangjiaName").css("display","block");
  44. }
  45. });
  46. //点击账号后面那个×,清空账号
  47. $(".log_del").click(function(){
  48. $("#username").val("");
  49. $("#photo").css("color","#ccc");
  50. });
  51. //修改单选框的样式
  52. $("#qiye").prop('checked',true);
  53. $('#qiye').click(function(){
  54. var Cheack=$(this).prop('checked')
  55. if(Cheack){
  56. $(this).parent().addClass('cheackeds').removeClass('cheackeds_no');
  57. $('#zhuangjia').prop('checked',false)
  58. $('#zhuangjia').parent().addClass('cheackeds_no').removeClass('cheackeds');
  59. }else{
  60. $('#zhuangjia').prop('checked',true)
  61. $('#zhuangjia').parent().addClass('cheackeds').removeClass('cheackeds_no');
  62. $(this).parent().addClass('cheackeds_no').removeClass('cheackeds');
  63. }
  64. })
  65. $('#zhuangjia').click(function(){
  66. var Cheack_no=$(this).prop('checked')
  67. if(Cheack_no){
  68. $(this).parent().addClass('cheackeds').removeClass('cheackeds_no');
  69. $('#qiye').prop('checked',false)
  70. $('#qiye').parent().addClass('cheackeds_no').removeClass('cheackeds');
  71. }else{
  72. $('#qiye').prop('checked',true)
  73. $('#qiye').parent().addClass('cheackeds').removeClass('cheackeds_no');
  74. $(this).parent().removeClass('cheackeds').addClass('cheackeds_no');
  75. }
  76. })
  77. var xieyi=$('#protocol').prop("checked",false);
  78. $('.sub').attr('disabled', true)
  79. $('.sub').css({background: '#CCCCCC',border: 'none'})
  80. $('#protocol').click(function(){
  81. var Cheack_no=$(this).prop('checked')
  82. if(Cheack_no){
  83. $(this).parent().removeClass('cheackeds_no').addClass('cheackeds');
  84. $('.sub').attr('disabled', false);
  85. $('.sub').css({background: '#F18101',border: 'none'})
  86. }else{
  87. $(this).prop('checked',false)
  88. $(this).parent().addClass('cheackeds_no').removeClass('cheackeds');
  89. $('.sub').attr('disabled', true)
  90. $('.sub').css({background: '#CCCCCC',border: 'none'})
  91. }
  92. })
  93. //密码
  94. function pass1(){
  95. $('#userpassword').blur(function () {
  96. var pass_pattern=/^\w{6,12}$/;
  97. var pass1 = $(this).val();
  98. var tt=$('#userpassword2').val();
  99. if (pass1==''||!pass_pattern.test(pass1)) {
  100. $(this).val('');
  101. $(this).attr('placeholder', '请输入6-12位数密码');
  102. } ;
  103. if ($(this).val() == ''||tt!==pass1) {
  104. $('#userpassword2').val('')
  105. $('#userpassword2').attr('placeholder', '确认密码')
  106. } ;
  107. });
  108. }
  109. pass1();
  110. //密码相同
  111. pass2();
  112. function pass2(){
  113. //密码相同验证
  114. $('#userpassword2').blur(function () {
  115. var orepeat = $(this).val();
  116. var passw = $('#userpassword').val();
  117. if (passw !== orepeat||passw == '') {
  118. $(this).val('');
  119. $(this).attr('placeholder', '确认密码')
  120. }
  121. });
  122. }
  123. //手机号码
  124. function photo1(){
  125. var pho_pattern=/^1[3|4|5|7|8][0-9]{9}$/;
  126. $("#username").keyup(function(){
  127. var phol= $(this).val();
  128. if(pho_pattern.test(phol)){
  129. $('#photo').attr('disabled', false);
  130. $("#photo").css("color","#F18101");
  131. }else if(!pho_pattern.test(phol)){
  132. $('#photo').attr('disabled', true);
  133. $("#photo").css("color","#ccc");
  134. }
  135. });
  136. $('#username').blur(function () {
  137. var pho= $(this).val();
  138. if (pho==''||!pho_pattern.test(pho)) {
  139. $(this).val('');
  140. $(this).attr('placeholder', '请输入正确的号码')
  141. } else{
  142. $('#photo').attr('disabled', false);
  143. $("#photo").css("color","#F18101");
  144. }
  145. })
  146. }
  147. photo1();
  148. //手机验证码
  149. function photo_num(){
  150. $('#photo_num').blur(function () {
  151. var phoa = $(this).val();
  152. if (phoa=='') {
  153. $(this).val('');
  154. $(this).attr('placeholder', '请输入手机上的验证码');
  155. }
  156. })
  157. }
  158. photo_num();
  159. //单位名称
  160. function photo_name(){
  161. $('#business').blur(function () {
  162. var name = $(this).val();
  163. if (name=='') {
  164. $(this).val('');
  165. $(this).attr('placeholder', '单位名称');
  166. }
  167. })
  168. }
  169. photo_name();
  170. //联系人名称
  171. function lxr_name(){
  172. $('#linkman').blur(function () {
  173. var name = $(this).val();
  174. if (name=='') {
  175. $(this).val('');
  176. $(this).attr('placeholder', '单位联系人姓名');
  177. }
  178. })
  179. }
  180. lxr_name();
  181. //专家名称
  182. function zj_name(){
  183. $('#man').blur(function () {
  184. var name = $(this).val();
  185. if (name=='') {
  186. $(this).val('');
  187. $(this).attr('placeholder', '请填写您的姓名');
  188. }
  189. })
  190. }
  191. zj_name();
  192. //表单提交
  193. $("#form_register").submit(function(e) {
  194. var user = $("#username").val();
  195. var password1 = $("#userpassword").val();
  196. var password2 = $("#userpassword2").val();
  197. var types = $('#zhuangjia').prop("checked") ? '0' : '1';//团体/个人
  198. var oname = $('#business').val();//企业名称
  199. var opeople = $('#linkman').val();//企业联系人
  200. var people=$('#man').val();//企业联系人
  201. var Code = $("#piccode").val();
  202. var mobileCode = $('#photo_num').val();//手机验证码
  203. e.preventDefault();
  204. if(user==''||password1==''||password2==''||Code==''||mobileCode==''){
  205. return false;
  206. }else if(types==0){
  207. if(people==''){
  208. return false;
  209. }else{
  210. $.ajax({
  211. type: "POST",
  212. dataType: "json",
  213. url: globalConfig.context + "/register",
  214. data: {
  215. "mobile": user,
  216. "password": password1,
  217. "type": types,
  218. "contacts": people,
  219. "verficationCode":Code,
  220. "mobileCode": mobileCode
  221. },
  222. success: function (rest) {
  223. if (rest.error && rest.error.length) {
  224. $('#msg').val(rest.error[0].message);
  225. msg();
  226. } else {
  227. var data = rest.data;
  228. if (data && data.requestURI) {
  229. var path = globalConfig.context + data.requestURI
  230. if (data.queryString) {
  231. path += '?' + data.queryString;
  232. }
  233. if (window.location.hash) {
  234. path += window.location.hash;
  235. }
  236. window.location.href = path;
  237. } else {
  238. window.location.href = globalConfig.context + "/user/account/index.html";
  239. }
  240. return true;
  241. }
  242. }
  243. })
  244. }
  245. }
  246. else if(types==1){
  247. if(opeople==''||oname==''){
  248. return false;
  249. }else{
  250. $.ajax({
  251. type: "POST",
  252. dataType: "json",
  253. url: globalConfig.context + "/register",
  254. data: {
  255. "mobile": user,
  256. "password": password1,
  257. "type": types,
  258. "companyName": oname,
  259. "contacts": opeople,
  260. "verficationCode":Code,
  261. "mobileCode": mobileCode
  262. },
  263. success: function (rest) {
  264. if (rest.error && rest.error.length) {
  265. $('#msg').val(rest.error[0].message);
  266. msg();
  267. } else {
  268. var data = rest.data;
  269. if (data && data.requestURI) {
  270. var path = globalConfig.context + data.requestURI
  271. if (data.queryString) {
  272. path += '?' + data.queryString;
  273. }
  274. if (window.location.hash) {
  275. path += window.location.hash;
  276. }
  277. window.location.href = path;
  278. } else {
  279. window.location.href = globalConfig.context + "/user/account/index.html";
  280. }
  281. return true;
  282. }
  283. }
  284. })
  285. }
  286. }
  287. })
  288. //点击刷新图片验证码
  289. $('.yanzhengma_cont').click(function () {
  290. $('.yanzhengma_cont img').attr('src', (globalConfig.context + "/open/getVCode?t=" + Math.random()))
  291. })
  292. var tt = 30;
  293. $('#photo').click(function () {
  294. //手机验证功能
  295. var ophoto = $('#username').val();
  296. var types = $('#zhuangjia').prop("checked") ? '0' : '1';
  297. var phott = $('#piccode').val();
  298. //验证码倒计时
  299. $('#photo').attr('disabled', true);
  300. $(this).attr('disabled', true);
  301. var timer = setInterval(function () {
  302. tt -= 1;
  303. $('#photo').attr('disabled', true);
  304. $(this).val("发送"+'('+tt+'s'+')');
  305. $(this).css({color:'#cccccc'})
  306. if (tt == 0) {
  307. clearInterval(timer);
  308. $('#photo').attr('disabled', false);
  309. $(this).attr('disabled', false);
  310. tt=30;
  311. $(this).css({color:'rgb(241, 129, 1)'})
  312. $(this).val('重新发送');
  313. }
  314. }.bind(this), 1000);
  315. $.ajax({
  316. type: "GET",
  317. url: globalConfig.context + "/open/getMCode",
  318. data: {
  319. "mobile": ophoto,
  320. "sign": false,
  321. "type": types,
  322. "verificationCode": phott
  323. },
  324. success: function (data) {
  325. if (data.error && data.error.length) {
  326. $('#msg').val(data.error[0].message);
  327. msg();
  328. } else {
  329. $('#msg').val('发送成功');
  330. msg();
  331. }
  332. return true;
  333. }
  334. });
  335. });
  336. //提示框渐隐函数
  337. $('.smg').hide();
  338. function msg(){
  339. var lit=$('#msg').val();
  340. if(lit!==''){
  341. $('.smg').fadeIn(500);
  342. }
  343. setTimeout(function(){
  344. $('.smg').fadeOut(500);
  345. $('#msg').val('');
  346. },2000)
  347. }
  348. });