public.js 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. $(function(){
  2. //导航
  3. $(".index_blur").html("×");
  4. $(".pub_fix").after("<div class='right_cebian'>侧边导航</div>");
  5. $(".index_blur").click(function(){
  6. $(".pub_fix").animate({right:"-70px"},"fast",function(){
  7. $(".right_cebian").show("fast");
  8. });
  9. });
  10. $(".right_cebian").click(function(){
  11. $(".right_cebian").hide("fast");
  12. $(".pub_fix").animate({right:"20px"},"fast",function(){
  13. });
  14. });
  15. //二级导航
  16. $('.nav ul li').mouseenter(function(){
  17. $(this).find('.subnavigation').slideDown(100);
  18. });
  19. $('.nav ul li').mouseleave(function(){
  20. $(this).find('.subnavigation').slideUp(100);
  21. $('.nav ul li').stop(false,true);
  22. });
  23. //挂件
  24. $('.pendent_box').click(function(e){
  25. e.preventDefault();
  26. $("body,html").animate({scrollTop:0},500)
  27. });
  28. //登陆页面
  29. var hht=$(window).height();
  30. $('.login').height(hht);
  31. //点击x
  32. $('.log_del').click(function(){
  33. $('#Lo_user').val('');
  34. $('#Lo_user').focus();
  35. $('#Lo_user').css({color:'#333333'});
  36. })
  37. // 登陆事件
  38. $('.head_login').click(function(e){
  39. e.preventDefault();
  40. $('.login').fadeIn(800)
  41. $('#form_register').fadeOut(800)
  42. })
  43. $('.login_close').click(function(){
  44. $('.login').fadeOut(800)
  45. $('#form_register').fadeIn(800)
  46. })
  47. $('#form_login').submit(function(e){
  48. e.preventDefault();
  49. var Suser=$('#Lo_user').val();
  50. var Spass=$('#Lo_pass').val();
  51. var check_experts=$('#checks').prop('checked');
  52. if(Suser==''||Spass==''){
  53. msg('请填写用户名/密码.');
  54. return false;
  55. }else{
  56. $.ajax({
  57. method: "POST",
  58. dataType: "json",
  59. url: globalConfig.context + "/signin",
  60. data: {
  61. "username": Suser,
  62. "password": Spass,
  63. },
  64. success: function (rest) {
  65. if (rest.error && rest.error.length) {
  66. msg(rest.error[0].message);
  67. } else {
  68. var data = rest.data;
  69. if (data && data.requestURI) {
  70. var path = globalConfig.context + data.requestURI;
  71. if (data.queryString) {
  72. path += '?' + data.queryString;
  73. }
  74. if (window.location.hash) {
  75. path += window.location.hash;
  76. }
  77. window.location.href = path;
  78. } else {
  79. window.location.href = globalConfig.context + "/user/account/index.html";
  80. }
  81. }
  82. }
  83. })
  84. }
  85. })
  86. //提示框渐隐函数
  87. function msg(mess) {
  88. if($('.smg').hasClass('active')){
  89. return ;
  90. }
  91. $('.smg').addClass('active');
  92. $('#msg').val(mess);
  93. setTimeout(function () {
  94. $('.smg').removeClass('active')
  95. $('#msg').val('');
  96. }, 2000)
  97. }
  98. //在线客服
  99. (function(m, ei, q, i, a, j, s) {
  100. m[i] = m[i] || function() {
  101. (m[i].a = m[i].a || []).push(arguments)
  102. };
  103. j = ei.createElement(q),
  104. s = ei.getElementsByTagName(q)[0];
  105. j.async = true;
  106. j.charset = 'UTF-8';
  107. j.src = 'https://static.meiqia.com/dist/meiqia.js?_=t';
  108. s.parentNode.insertBefore(j, s);
  109. })(window, document, 'script', '_MEIQIA');
  110. _MEIQIA('entId', 77931);
  111. _MEIQIA('withoutBtn');
  112. //点击登录界面的忘记密码 ,将会弹出忘记密码界面
  113. $('.login_check a').click(function(e){
  114. e.preventDefault();
  115. $('.login').fadeOut(800);
  116. $('#form_register').fadeOut(800);
  117. $("#forget").fadeIn(800);
  118. });
  119. //点击忘记密码右上角的×,将会关闭界面并清空里面的内容
  120. $('#forget .login_close').click(function(){
  121. $('#forget').fadeOut(800);
  122. $('#form_register').fadeIn(800);
  123. $("#forget_phone").val("");
  124. $("#forget_yanzheng").val("");
  125. $("#photo_n").val("");
  126. });
  127. //点击取消,相当于点击×
  128. $("#forget .fastener_right").click(function(){
  129. $('#forget .login_close').click();
  130. });
  131. //点击重置密码右上角的×,将会关闭界面并清空里面的内容
  132. $('#new_password .login_close').click(function(){
  133. $('#new_password').fadeOut(800)
  134. $('#form_register').fadeIn(800)
  135. });
  136. //点击取消,相当于点击×
  137. $("#new_password .fastener_right").click(function(){
  138. $('#new_password .login_close').click();
  139. });
  140. let use_forget,phone_forget;
  141. //点击忘记密码里面的确认,则发送一个请求,并跳转到重置密码界面
  142. $('#forget_form').submit(function(e){
  143. e.preventDefault();
  144. use_forget = $('#forget_user').val();
  145. phone_forget=$("#forget_phone").val();
  146. var phone_n_forget=$("#photo_n").val();
  147. if(!(use_forget).trim()){
  148. msg('亲,请填写用户名')
  149. return;
  150. };
  151. if(!(phone_forget).trim()){
  152. msg('亲,请填写正确的手机号码')
  153. return;
  154. };
  155. if(!(phone_n_forget).trim()){
  156. msg('亲,请填写手机验证码')
  157. return;
  158. };
  159. $.ajax({
  160. type: "POST",
  161. dataType: "json",
  162. url: globalConfig.context + "/open/checkMNCode",
  163. data: {
  164. 'userName': use_forget,
  165. 'mobile':phone_forget,
  166. 'mobileCode': phone_n_forget
  167. },
  168. success: function (rest) {
  169. if (rest.error && rest.error.length) {
  170. msg(rest.error[0].message);
  171. } else {
  172. $('#forget').fadeOut(800);
  173. $('#form_register').fadeOut(800);
  174. $("#new_password").fadeIn(800);
  175. $(".password_top>h4").attr("val",rest.data);
  176. }
  177. }
  178. })
  179. });
  180. //点击重置密码里面的确认,则发送一个请求,并关闭重置密码界面
  181. $('#new_password_form').submit(function(e){
  182. e.preventDefault();
  183. var pass_pattern=/^[a-zA-Z0-9]{6,12}$/;
  184. var new_pass=$("#new_pass").val();
  185. var new_pass_again=$("#new_pass_again").val();
  186. var reset_code=$(".password_top>h4").attr("val");
  187. console.log(new_pass,new_pass_again)
  188. if(!new_pass||!new_pass_again){
  189. msg('亲,新旧密码必填!')
  190. return;
  191. }
  192. if(new_pass!==new_pass_again){
  193. msg('亲,两次密码不一致')
  194. return;
  195. }
  196. if(!pass_pattern.test(new_pass)){
  197. msg('亲,密码格式不正确')
  198. return ;
  199. }
  200. $.ajax({
  201. type: "post",
  202. dataType: "json",
  203. url: globalConfig.context + "/open/resetPassword",
  204. data: {
  205. 'userName':use_forget,
  206. "newPwd": new_pass,
  207. 'mobile':phone_forget,
  208. 'resetCode':reset_code
  209. },
  210. success: function (rest) {
  211. if (rest.error && rest.error.length) {
  212. msg(rest.error[0].message);
  213. } else {
  214. $('.login').fadeIn(800);
  215. $('#form_register').fadeOut(800);
  216. $("#new_password").fadeOut(800);
  217. msg('修改成功!');
  218. }
  219. }
  220. })
  221. });
  222. //手机号码的验证
  223. function photoyanzheng(){
  224. var pho_pattern=/^1[3|4|5|7|8][0-9]{9}$/;
  225. $("#forget_phone").keyup(function(){
  226. var phol= $(this).val();
  227. if(pho_pattern.test(phol)){
  228. $('#photo_m').attr('disabled', false);
  229. $("#photo_m").css("color","#F18101");
  230. }else if(!pho_pattern.test(phol)){
  231. $('#photo_m').attr('disabled', true);
  232. $("#photo_m").css("color","#ccc");
  233. }
  234. });
  235. $('#forget_phone').blur(function () {
  236. var pho= $(this).val();
  237. if (pho==''||!pho_pattern.test(pho)) {
  238. $(this).val('');
  239. $(this).attr('placeholder', '请输入正确的号码')
  240. } else{
  241. $('#photo_m').attr('disabled', false);
  242. $("#photo_m").css("color","#F18101");
  243. }
  244. })
  245. }
  246. photoyanzheng();
  247. //点击刷新图片验证码
  248. $('.yanzhengma_cont_').click(function () {
  249. $('.yanzhengma_cont_ img').attr('src', (globalConfig.context + "/open/getVCode?t=" + Math.random()))
  250. });
  251. var tt = 30;
  252. $('#photo_m').click(function () {
  253. //手机验证功能
  254. var ophoto = $('#forget_phone').val();
  255. var types = $('#forget_checks').prop("checked") ? '0' : '1';
  256. var phott = $('#forget_yanzheng').val();
  257. //验证码倒计时
  258. $('#photo_m').attr('disabled', true);
  259. $(this).attr('disabled', true);
  260. var timer = setInterval(function () {
  261. tt -= 1;
  262. $('#photo_m').attr('disabled', true);
  263. $(this).val("发送"+'('+tt+'s'+')');
  264. $(this).css({color:'#cccccc'})
  265. if (tt == 0) {
  266. clearInterval(timer);
  267. $('#photo_m').attr('disabled', false);
  268. $(this).attr('disabled', false);
  269. tt=30;
  270. $(this).css({color:'rgb(241, 129, 1)'})
  271. $(this).val('重新发送');
  272. }
  273. }.bind(this), 1000);
  274. $.ajax({
  275. type: "GET",
  276. url: globalConfig.context + "/open/getMCode",
  277. data: {
  278. "mobile": ophoto,
  279. "sign": false,
  280. "type": types,
  281. "verificationCode": phott
  282. },
  283. success: function (data) {
  284. if (data.error && data.error.length) {
  285. msg(data.error[0].message);
  286. } else {
  287. msg('发送成功');
  288. }
  289. return true;
  290. }
  291. });
  292. });
  293. //loading
  294. loading();
  295. function loading(){
  296. clearInterval(setTime)
  297. let txt = "努力加载中...",htmls=[],i=0,
  298. txtArr = txt.split('');
  299. let ps = document.createElement('p');
  300. txtArr.map(item=>{
  301. htmls.push(`
  302. <span>${item}</span>
  303. `)
  304. });
  305. ps.innerHTML=htmls.join('');
  306. $('.loading div').html(ps);
  307. function active(){
  308. i++;
  309. console.log(i)
  310. if(i>txtArr.length){
  311. i=0;
  312. };
  313. $('.loading p span').eq(i).addClass('active').siblings().removeClass('active');
  314. }
  315. var setTime =setInterval(()=>{active()},100);
  316. }
  317. });