utils.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. define(['jquery'], function ($) {
  2. // 活跃导航条
  3. function handleNavbarStatus (index) {
  4. index = index === undefined ? $('#navbarIndex').val() : index;
  5. $('.navbar_item').eq(index).addClass('active').siblings().removeClass('active');
  6. }
  7. $('.js-robGift').on('click', function () {
  8. $('#GiftDetailDialog').fadeIn(200);
  9. });
  10. $('#GiftDetailDialog .CloseDialog').on('click', function () {
  11. $('#GiftDetailDialog').fadeOut(200);
  12. });
  13. $("#successDialog .closeSuccessDialog").on('click', function () {
  14. $('#successDialog').fadeOut();
  15. window.location.reload();
  16. });
  17. // 锁定Y轴,纵向不可滚动
  18. function lockY () {
  19. $('body').css({height:'100vh',overflow: 'hidden'});
  20. }
  21. // 解锁Y轴
  22. function unlockY () {
  23. $('body').css({height:'auto',overflow: 'auto'});
  24. }
  25. // 底部背景图片的显示隐藏
  26. function handleFixedBanner () {
  27. var isShow = sessionStorage.getItem('showFixedBanner');
  28. if (isShow !== '0') {
  29. $('.banner_pic').show();
  30. $('.banner_pic i').on('click', function () {
  31. sessionStorage.setItem('showFixedBanner', 0);
  32. $(this).parent().fadeOut(1000);
  33. $('.footer').css('margin-bottom', 0);
  34. });
  35. }
  36. }
  37. // 关于我们页面切换
  38. function switchPage(){
  39. var url = window.location.search.split('=')[1];
  40. if(url == "1"){
  41. $('.contact-us').show().siblings().hide();
  42. }else if(url == '2'){
  43. $('.sincere-hire').show().siblings().hide();
  44. }else if(url == '3'){
  45. $('.customer-center').show().siblings().hide();
  46. }else if(url == '4'){
  47. $('.parents-care').show().siblings().hide();
  48. }else{
  49. $('.inner-about-us').show().siblings().hide();
  50. }
  51. }
  52. return {
  53. handleNavbarStatus: handleNavbarStatus,
  54. lockY: lockY,
  55. unlockY: unlockY,
  56. handleFixedBanner: handleFixedBanner,
  57. switchPage: switchPage
  58. };
  59. });