index.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. var homeData = new Vue({
  2. el: '#container',
  3. data: {
  4. images: [],
  5. recommends: [],
  6. bigTopicData: [],
  7. topicData3: [],
  8. topicData4: [],
  9. topicData5: [],
  10. advertising: [],
  11. asideNav: []
  12. },
  13. methods: {
  14. getBanners: function(){
  15. var _self = this;
  16. $.getJSON("/home/banner").done(function (r) {
  17. if (r.code === 0 && r.data) {
  18. _self.images = r.data;
  19. setTimeout(function(){
  20. if (isPC) {
  21. $('#swiper-container').slide({
  22. mainCell:".swiper-wrapper"
  23. ,titCell:".swiper-pagination span"
  24. ,effect: "leftLoop"
  25. ,prevCell:".swiper-button-prev"
  26. ,nextCell:".swiper-button-next"
  27. ,interTime: 3000
  28. ,autoPlay: true
  29. ,autoPage: false
  30. ,trigger: "mouseover"
  31. });
  32. } else {
  33. var swiper = new Swiper('#swiper-container', {
  34. loop : true,
  35. autoplay: {
  36. delay: 3000,
  37. disableOnInteraction: false
  38. },
  39. navigation: {
  40. nextEl: '.swiper-button-next',
  41. prevEl: '.swiper-button-prev'
  42. },
  43. pagination: {
  44. el: '.swiper-pagination',
  45. type: 'bullets',
  46. clickable :true
  47. }
  48. });
  49. }
  50. },500);
  51. }
  52. });
  53. },
  54. getRecommends: function(){
  55. var _self = this;
  56. $.getJSON("/home/recommend").done(function (r) {
  57. if (r.code === 0 && r.data) {
  58. _self.recommends = r.data;
  59. setTimeout(function(){
  60. $('#recommendBox').slide({
  61. mainCell:"ul.bd"
  62. ,titCell:"ul.hd li"
  63. ,effect: "leftLoop"
  64. ,interTime: 2000
  65. ,autoPlay: true
  66. ,scroll:3
  67. ,vis:3
  68. ,pnLoop:false
  69. });
  70. },500);
  71. }
  72. });
  73. },
  74. getAdvertising: function(){
  75. var _self = this;
  76. $.getJSON("/home/advertising").done(function (r) {
  77. if (r.code === 0 && r.data) {
  78. _self.advertising = r.data;
  79. }
  80. });
  81. },
  82. getTopicData: function(){
  83. var _self = this;
  84. $.getJSON("/home/topic").done(function (r) {
  85. if (r.code === 0 && r.data) {
  86. _self.bigTopicData = r.data.bigTopicData;
  87. _self.topicData3 = r.data.topicData3;
  88. _self.topicData4 = r.data.topicData4;
  89. _self.topicData5 = r.data.topicData5;
  90. setTimeout(function(){
  91. _self.setAsideNav();
  92. },500)
  93. }
  94. });
  95. },
  96. setAsideNav: function(){
  97. var _self = this;
  98. var titArr = $('.floorTit').find('h2,h3');
  99. for (var i=0; i<titArr.length; i++){
  100. _self.asideNav.push({
  101. id: $(titArr[i]).attr("data-id"),
  102. value: $(titArr[i]).text()
  103. })
  104. }
  105. }
  106. },
  107. created: function() {
  108. this.getBanners();
  109. this.getRecommends();
  110. this.getTopicData();
  111. },
  112. mounted: function() {
  113. this.getAdvertising();
  114. }
  115. });