register.js 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. import '../css/bootstrap.less';
  2. // import 'bootstrap/dist/js/bootstrap.js';
  3. import 'css/newMenu/public.css';
  4. import 'css/newMenu/header.css'
  5. import '../css/register.css';
  6. import './public.js';
  7. $(function () {
  8. //查看技淘网协议
  9. var hht = $(window).height();
  10. $('.login_').height(hht);
  11. //登陆
  12. var hht = $(window).height();
  13. $('.login').hide();
  14. //点击账号后面那个×,清空账号
  15. $(".log_del").click(function () {
  16. $("#username").focus().val("").css('color','#666');
  17. });
  18. var xieyi = $('#protocol').prop("checked", false);
  19. $('.sub').attr('disabled', true)
  20. $('.sub').css({
  21. background: '#CCCCCC',
  22. border: 'none'
  23. })
  24. $('#protocol').click(function () {
  25. var Cheack_no = $(this).prop('checked')
  26. if (Cheack_no) {
  27. $(this).parent().removeClass('cheackeds_no').addClass('cheackeds');
  28. $('.sub').attr('disabled', false);
  29. $('.sub').css({
  30. background: '#fe6e42',
  31. border: 'none'
  32. })
  33. } else {
  34. $(this).prop('checked', false)
  35. $(this).parent().addClass('cheackeds_no').removeClass('cheackeds');
  36. $('.sub').attr('disabled', true)
  37. $('.sub').css({
  38. background: '#CCCCCC',
  39. border: 'none'
  40. })
  41. }
  42. })
  43. //手机号码
  44. let oldPhoto='';
  45. var phopoVal=[];
  46. $('#photo').attr('disabled', true);
  47. function photo1() {
  48. var pho_pattern = /^1[2|3|4|5|6|7|8|9][0-9]{9}$/;
  49. $("#usePhoto").keyup(function () {
  50. oldPhoto = $(this).val();
  51. if (pho_pattern.test(oldPhoto)) {
  52. tipFun.call(this,false,'')
  53. $('#photo').attr('disabled', false);
  54. $("#photo").css("color", "#F18101");
  55. } else {
  56. tipFun.call(this,true,'请填写正确的手机号码')
  57. $('#photo').attr('disabled', true);
  58. $("#photo").css("color", "#ccc");
  59. }
  60. });
  61. $("#usePhoto").blur(function(){
  62. if (pho_pattern.test(oldPhoto)) {
  63. tipFun.call(this,false,'')
  64. } else {
  65. tipFun.call(this,true,'请填写正确的手机号码')
  66. }
  67. })
  68. }
  69. photo1();
  70. //手机验证码
  71. function photo_num() {
  72. $('#photo_num').blur(function () {
  73. var phoa = $(this).val().trim();
  74. if (phoa == '') {
  75. tipFun.call(this,true,'验证码不能为空')
  76. }else{
  77. tipFun.call(this,false,'')
  78. }
  79. })
  80. }
  81. photo_num();
  82. /*失去焦点处理 */
  83. blurFun();
  84. /* 提示框函数处理 */
  85. function tipFun(state,txt){
  86. let _this=this;
  87. if(state){
  88. $(_this).siblings('.Tips').text(txt);
  89. $(_this).siblings('.Tips').addClass('active')
  90. }else{
  91. $(_this).siblings('.Tips').text('');
  92. $(_this).siblings('.Tips').removeClass('active')
  93. }
  94. }
  95. function blurFun(){
  96. $('#username').blur(function(){
  97. if(!$(this).val().trim()){
  98. tipFun.call(this,true,'请填写用户名')
  99. }else {
  100. tipFun.call(this,false,'')
  101. }
  102. })
  103. $('#userpassword').blur(function () {
  104. var pass_pattern = /^[a-zA-Z\d_]{6,12}$/;
  105. var pass1 = $(this).val().trim();
  106. var tt = $('#userpassword2').val().trim();
  107. if (!pass1|| !(pass_pattern.test(pass1))) {
  108. tipFun.call(this,true,'请输入6-12位数的密码')
  109. }else if(pass1===tt){
  110. tipFun.call($('#userpassword2'),false,'');
  111. }else{
  112. tipFun.call(this,false,'')
  113. tipFun.call($('#userpassword2'),true,'两次密码不一致');
  114. }
  115. });
  116. $('#customerName').blur(function(){
  117. if(!$(this).val().trim()){
  118. tipFun.call(this,true,'请填写客户名称')
  119. }else{
  120. tipFun.call(this,false,'')
  121. }
  122. });
  123. $('#userpassword2').blur(function () {
  124. var orepeat = $(this).val();
  125. var passw = $('#userpassword').val();
  126. if (passw !== orepeat || passw == '') {
  127. tipFun.call(this,true,'两次密码不一致')
  128. }else{
  129. tipFun.call(this,false,'')
  130. }
  131. });
  132. }
  133. function initVal(){
  134. $('#protocol').prop("checked", false)
  135. $(this).prop('checked', false)
  136. $(this).parent().addClass('cheackeds_no').removeClass('cheackeds');
  137. $('.sub').attr('disabled', true)
  138. $('.sub').css({
  139. background: '#CCCCCC',
  140. border: 'none'
  141. })
  142. }
  143. //表单提交
  144. if(window.location.search.indexOf('code')>-1){
  145. let code = (window.location.search).split('=');
  146. $('#beInviteCode').val(code[1]);
  147. }
  148. $("#form_register").submit(function (e) {
  149. e.preventDefault();
  150. var user = $("#username").val(),
  151. usePhoto = $('#usePhoto').val(),
  152. password1 = $("#userpassword").val(),
  153. password2 = $("#userpassword2").val(),
  154. customerType = $('#customerTypes').val(),
  155. mobileCode = $('#photo_num').val(),//手机验证码
  156. codeV = $('#beInviteCode').val();
  157. if(password1!==password2){
  158. tipFun.call($('#userpassword2'),true,'两次密码不一致');
  159. return;
  160. };
  161. if(!usePhoto&&!password1&&!mobileCode){
  162. $('.Tips').text('请输入内容.');
  163. $('.Tips').addClass('active');
  164. return ;
  165. }
  166. // if(phopoVal[0]!==usePhoto){
  167. // tipFun.call($('#usePhoto'),true,'当前手机号与获得验证码的手机号不一致.')
  168. // return ;
  169. // }
  170. // if($('.Tips.active').length){
  171. // return;
  172. // } else {
  173. // $('.loading').show();
  174. // $.ajax({
  175. // type: "POST",
  176. // dataType: "json",
  177. // url: globalConfig.context + "/register",
  178. // data: {
  179. // "unitName": user,
  180. // "password": password1,
  181. // "mobile": usePhoto,
  182. // "mobileCode": mobileCode,
  183. // "type":customerType,
  184. // "beInviteCode":codeV
  185. // },
  186. // success: function (rest) {
  187. // $('.loading').hide()
  188. // if (rest.error && rest.error.length) {
  189. // msg(rest.error[0].message);
  190. // } else {
  191. // setTimeout(()=>{
  192. msg("恭喜您,注册成功!入驻发布信息,请联系平台管理员激活账户,谢谢");
  193. setTimeout(() => {
  194. window.location.pathname = 'portal/index';
  195. }, 1000)
  196. // initVal();
  197. // if($('.header ul li a').hasClass('head_login')){
  198. // $('.login').fadeIn(800);
  199. // $('#form_register').fadeOut(800)
  200. // }
  201. // },2000)
  202. // }
  203. // }
  204. // })
  205. // }
  206. })
  207. agreement();
  208. function agreement(){
  209. $('.head_login_').click(function(){
  210. $('.login_').show();
  211. })
  212. $('.login_close_').click(function(){
  213. $('.login_').hide();
  214. })
  215. }
  216. var tt = 30;
  217. $('#tipFun').click(function () {
  218. phopoVal=[];
  219. var ophoto = $('#usePhoto').val().trim();
  220. if (ophoto) {
  221. phopoVal.push(ophoto);
  222. $.ajax({
  223. type: "GET",
  224. url: globalConfig.context + "/open/getMCode",
  225. data: {
  226. "mobile": ophoto,
  227. "sign": false,
  228. },
  229. success: function (data) {
  230. if (data.error && data.error.length) {
  231. msg(data.error[0].message);
  232. } else {
  233. //验证码倒计时
  234. $('#photo').attr('disabled', true);
  235. var timer = setInterval(function () {
  236. tt -= 1;
  237. $('#photo').val("发送" + '(' + tt + 's' + ')');
  238. $('#photo').css({
  239. color: '#cccccc'
  240. })
  241. if (tt == 0) {
  242. clearInterval(timer);
  243. $('#photo').attr('disabled', false);
  244. tt = 30;
  245. $('#photo').css({
  246. color: '#f18101'
  247. })
  248. $('#photo').val('重新发送');
  249. }
  250. }.bind(this), 1000);
  251. msg('发送成功');
  252. }
  253. return true;
  254. }
  255. });
  256. } else {
  257. msg('请填写手机号码!');
  258. }
  259. });
  260. //提示框渐隐函数
  261. function msg(mess) {
  262. if($('.smg').hasClass('active')){
  263. return ;
  264. }
  265. $('.smg').addClass('active')
  266. $('#msg').val(mess);
  267. setTimeout(function () {
  268. $('.smg').removeClass('active')
  269. $('#msg').val('');
  270. }, 2000)
  271. }
  272. //注册 底部图片处理
  273. footerImg()
  274. function footerImg(){
  275. $('.cont_left img').css('display','none');
  276. $('.cont_center img').css('display','none');
  277. $('.cont_left div').css('display','block');
  278. $('.cont_center div').css('display','block');
  279. }
  280. });