register.js 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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. $('#photo').attr('disabled', true);
  46. function photo1() {
  47. var pho_pattern = /^1[2|3|4|5|6|7|8|9][0-9]{9}$/;
  48. $("#usePhoto").keyup(function () {
  49. oldPhoto = $(this).val();
  50. if (pho_pattern.test(oldPhoto)) {
  51. tipFun.call(this,false,'')
  52. $('#photo').attr('disabled', false);
  53. $("#photo").css("color", "#F18101");
  54. } else {
  55. tipFun.call(this,true,'请填写正确的手机号码')
  56. $('#photo').attr('disabled', true);
  57. $("#photo").css("color", "#ccc");
  58. }
  59. });
  60. $("#usePhoto").blur(function(){
  61. if (pho_pattern.test(oldPhoto)) {
  62. tipFun.call(this,false,'')
  63. } else {
  64. tipFun.call(this,true,'请填写正确的手机号码')
  65. }
  66. })
  67. }
  68. photo1();
  69. //手机验证码
  70. function photo_num() {
  71. $('#photo_num').blur(function () {
  72. var phoa = $(this).val().trim();
  73. if (phoa == '') {
  74. tipFun.call(this,true,'验证码不能为空')
  75. }else{
  76. tipFun.call(this,false,'')
  77. }
  78. })
  79. }
  80. photo_num();
  81. /*失去焦点处理 */
  82. blurFun();
  83. /* 提示框函数处理 */
  84. function tipFun(state,txt){
  85. let _this=this;
  86. if(state){
  87. $(_this).siblings('.Tips').text(txt);
  88. $(_this).siblings('.Tips').addClass('active')
  89. }else{
  90. $(_this).siblings('.Tips').text('');
  91. $(_this).siblings('.Tips').removeClass('active')
  92. }
  93. }
  94. function blurFun(){
  95. $('#username').blur(function(){
  96. if(!$(this).val().trim()){
  97. tipFun.call(this,true,'请填写用户名')
  98. }else {
  99. tipFun.call(this,false,'')
  100. }
  101. })
  102. $('#userpassword').blur(function () {
  103. var pass_pattern = /^[a-zA-Z\d_]{6,12}$/;
  104. var pass1 = $(this).val().trim();
  105. var tt = $('#userpassword2').val().trim();
  106. if (!pass1|| !(pass_pattern.test(pass1))) {
  107. tipFun.call(this,true,'请输入6-12位数的密码')
  108. }else if(pass1===tt){
  109. tipFun.call($('#userpassword2'),false,'');
  110. }else{
  111. tipFun.call(this,false,'')
  112. tipFun.call($('#userpassword2'),true,'两次密码不一致');
  113. }
  114. });
  115. $('#customerName').blur(function(){
  116. if(!$(this).val().trim()){
  117. tipFun.call(this,true,'请填写客户名称')
  118. }else{
  119. tipFun.call(this,false,'')
  120. }
  121. });
  122. $('#userpassword2').blur(function () {
  123. var orepeat = $(this).val();
  124. var passw = $('#userpassword').val();
  125. if (passw !== orepeat || passw == '') {
  126. tipFun.call(this,true,'两次密码不一致')
  127. }else{
  128. tipFun.call(this,false,'')
  129. }
  130. });
  131. }
  132. function initVal(){
  133. $('#protocol').prop("checked", false)
  134. $(this).prop('checked', false)
  135. $(this).parent().addClass('cheackeds_no').removeClass('cheackeds');
  136. $('.sub').attr('disabled', true)
  137. $('.sub').css({
  138. background: '#CCCCCC',
  139. border: 'none'
  140. })
  141. }
  142. //表单提交
  143. if(window.location.search.indexOf('code')>-1){
  144. let code = (window.location.search).split('=');
  145. $('#beInviteCode').val(code[1]);
  146. }
  147. $("#form_register").submit(function (e) {
  148. e.preventDefault();
  149. var user = $("#username").val(),
  150. usePhoto = $('#usePhoto').val(),
  151. password1 = $("#userpassword").val(),
  152. password2 = $("#userpassword2").val(),
  153. customerType = $('#customerTypes').val(),
  154. mobileCode = $('#photo_num').val(),//手机验证码
  155. codeV = $('#beInviteCode').val();
  156. if(password1!==password2){
  157. tipFun.call($('#userpassword2'),true,'两次密码不一致');
  158. return;
  159. };
  160. if(!usePhoto&&!password1&&!mobileCode){
  161. $('.Tips').text('请输入内容.');
  162. $('.Tips').addClass('active');
  163. return ;
  164. }
  165. if($('.Tips.active').length){
  166. return;
  167. } else {
  168. $('.loading').show();
  169. $.ajax({
  170. type: "POST",
  171. dataType: "json",
  172. url: globalConfig.context + "/register",
  173. data: {
  174. "unitName": user,
  175. "password": password1,
  176. "mobile": usePhoto,
  177. "mobileCode": mobileCode,
  178. "type":customerType,
  179. "beInviteCode":codeV
  180. },
  181. success: function (rest) {
  182. $('.loading').hide()
  183. if (rest.error && rest.error.length) {
  184. msg(rest.error[0].message);
  185. } else {
  186. setTimeout(()=>{
  187. msg("注册成功,请登录个人中心操作");
  188. initVal();
  189. if($('.header ul li a').hasClass('head_login')){
  190. $('.login').fadeIn(800);
  191. $('#form_register').fadeOut(800)
  192. }
  193. },2000)
  194. }
  195. }
  196. })
  197. }
  198. })
  199. agreement();
  200. function agreement(){
  201. $('.head_login_').click(function(){
  202. $('.login_').show();
  203. })
  204. $('.login_close_').click(function(){
  205. $('.login_').hide();
  206. })
  207. }
  208. var tt = 30;
  209. $('#photo').click(function () {
  210. var ophoto = $('#usePhoto').val().trim();
  211. if (ophoto) {
  212. $.ajax({
  213. type: "GET",
  214. url: globalConfig.context + "/open/getMCode",
  215. data: {
  216. "mobile": ophoto,
  217. "sign": false,
  218. },
  219. success: function (data) {
  220. if (data.error && data.error.length) {
  221. msg(data.error[0].message);
  222. } else {
  223. //验证码倒计时
  224. $('#photo').attr('disabled', true);
  225. var timer = setInterval(function () {
  226. tt -= 1;
  227. $('#photo').val("发送" + '(' + tt + 's' + ')');
  228. $('#photo').css({
  229. color: '#cccccc'
  230. })
  231. if (tt == 0) {
  232. clearInterval(timer);
  233. $('#photo').attr('disabled', false);
  234. tt = 30;
  235. $('#photo').css({
  236. color: '#f18101'
  237. })
  238. $('#photo').val('重新发送');
  239. }
  240. }.bind(this), 1000);
  241. msg('发送成功');
  242. }
  243. return true;
  244. }
  245. });
  246. } else {
  247. msg('请填写手机号码!');
  248. }
  249. });
  250. //提示框渐隐函数
  251. function msg(mess) {
  252. if($('.smg').hasClass('active')){
  253. return ;
  254. }
  255. $('.smg').addClass('active')
  256. $('#msg').val(mess);
  257. setTimeout(function () {
  258. $('.smg').removeClass('active')
  259. $('#msg').val('');
  260. }, 2000)
  261. }
  262. //底部图片处理
  263. footerImg()
  264. function footerImg(){
  265. $('.cont_left img').attr('src','');
  266. $('.cont_center img').attr('src','');
  267. }
  268. });