index.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. <template>
  2. <div class="wrap" :style="{backgroundImage:'url('+bodyBg+')'}">
  3. <div id="certify">
  4. <div class="swiper-container">
  5. <div class="swiper-wrapper">
  6. <div
  7. class="swiper-slide"
  8. v-for="(item,index) in lists"
  9. @click="goPage(item.type)"
  10. :key="index"
  11. :style="{backgroundImage:'url('+item.imgUrl+')'}"
  12. ></div>
  13. </div>
  14. </div>
  15. <div class="swiper-button-prev" :style="{backgroundImage:'url('+btnBg+')'}"></div>
  16. <div class="swiper-button-next" :style="{backgroundImage:'url('+btnBg+')'}"></div>
  17. <div class="swiper-pagination"></div>
  18. </div>
  19. <div class="btn-box">
  20. <ul>
  21. <li
  22. :class="{'active':aIndex==index}"
  23. @click="switchTo(index)"
  24. v-for="(item,index) in lists"
  25. :key="index"
  26. >{{item.name}}</li>
  27. </ul>
  28. </div>
  29. </div>
  30. </template>
  31. <script>
  32. import Swiper from 'swiper'
  33. import 'swiper/dist/css/swiper.min.css'
  34. export default {
  35. data() {
  36. return {
  37. bodyBg: require('@/assets/images/bigdata/home/bg.jpg'),
  38. btnBg: require('@/assets/images/bigdata/home/button_icon.png'),
  39. certifySwiper: '',
  40. aIndex: 0,
  41. lists: [
  42. {
  43. type: '/bCbd',
  44. name: '虫情测报系统',
  45. imgUrl: require('@/assets/images/bigdata/home/cbd.png')
  46. },
  47. // {
  48. // type: '/jk',
  49. // name: '监控系统',
  50. // imgUrl: require('@/assets/images/bigdata/home/jk.png')
  51. // },
  52. {
  53. type: '/bBzy',
  54. name: '孢子仪系统',
  55. imgUrl: require('@/assets/images/bigdata/home/bzy.png')
  56. },
  57. {
  58. type: '/bQxz',
  59. name: '气象监测系统',
  60. imgUrl: require('@/assets/images/bigdata/home/qxz.png')
  61. },
  62. // {
  63. // type: '/farm',
  64. // name: '农场管理系统',
  65. // imgUrl: require('@/assets/images/bigdata/home/farm.png')
  66. // },
  67. {
  68. type: '/bSy',
  69. name: '溯源系统',
  70. imgUrl: require('@/assets/images/bigdata/home/sy.png')
  71. },
  72. {
  73. type: '/equipDistribute',
  74. name: '设备分布展示',
  75. imgUrl: require('@/assets/images/bigdata/home/distribute.png')
  76. },
  77. {
  78. type: '/bFourSituations',
  79. name: '设备综合展示',
  80. imgUrl: require('@/assets/images/bigdata/home/fourSituations.png')
  81. }
  82. ]
  83. }
  84. },
  85. mounted() {
  86. this.swiperInit()
  87. },
  88. methods: {
  89. switchTo(i) {
  90. this.aIndex = i
  91. this.certifySwiper.slideTo(i+5, 1000, false)
  92. },
  93. swiperInit() {
  94. let _this = this
  95. this.certifySwiper = new Swiper('#certify .swiper-container', {
  96. watchSlidesProgress: true,
  97. slidesPerView: 'auto',
  98. centeredSlides: true,
  99. loop: true,
  100. loopedSlides: 5,
  101. autoplay: 3000,
  102. prevButton: '.swiper-button-prev',
  103. nextButton: '.swiper-button-next',
  104. pagination: '.swiper-pagination',
  105. paginationClickable :true,
  106. //paginationClickable :true,
  107. onProgress: function(swiper, progress) {
  108. for (var i = 0; i < swiper.slides.length; i++) {
  109. var slide = swiper.slides.eq(i);
  110. var slideProgress = swiper.slides[i].progress;
  111. var modify = 1;
  112. if (Math.abs(slideProgress) > 1) {
  113. modify = (Math.abs(slideProgress) - 1) * 0.3 + 1;
  114. }
  115. var translate = slideProgress * modify * 260 + 'px';
  116. var scale = 1 - Math.abs(slideProgress) / 5;
  117. var zIndex = 999 - Math.abs(Math.round(10 * slideProgress));
  118. slide.transform('translateX(' + translate + ') scale(' + scale + ')');
  119. slide.css('zIndex', zIndex);
  120. slide.css('opacity', 1);
  121. if (Math.abs(slideProgress) > 3) {
  122. slide.css('opacity', 0);
  123. }
  124. }
  125. },
  126. onSetTransition: function(swiper, transition) {
  127. for (var i = 0; i < swiper.slides.length; i++) {
  128. var slide = swiper.slides.eq(i)
  129. slide.transition(transition);
  130. }
  131. },
  132. //处理分页器bug
  133. onSlideChangeStart: function(swiper) {
  134. if (swiper.activeIndex == 4) {
  135. swiper.bullets.eq(9).addClass('swiper-pagination-bullet-active');
  136. console.log(swiper.bullets.length);
  137. }
  138. },
  139. //使右边菜单跟着动
  140. onSlideChangeEnd: function(swiper){
  141. _this.aIndex = swiper.realIndex //切换结束时,告诉我现在是第几个slide
  142. }
  143. })
  144. },
  145. goPage(type) {
  146. const { href } = this.$router.resolve({
  147. path: type
  148. })
  149. window.open(href, '_blank')
  150. }
  151. }
  152. }
  153. </script>
  154. <style lang='less' scoped>
  155. body {
  156. overflow: hidden;
  157. }
  158. .wrap {
  159. width: 100%;
  160. height: 100%;
  161. background-repeat: no-repeat;
  162. background-size: 100% 100%;
  163. background-position: center;
  164. overflow: hidden;
  165. #certify {
  166. position: relative;
  167. width: 1200px;
  168. margin: 0 auto;
  169. margin-top: 150px;
  170. }
  171. #certify .swiper-container {
  172. padding-bottom: 60px;
  173. }
  174. #certify .swiper-slide {
  175. width: 500px;
  176. height: 488px;
  177. background-size: 75% 100%;
  178. background-position: center center;
  179. background-repeat: no-repeat;
  180. }
  181. #certify .swiper-slide img {
  182. display: block;
  183. }
  184. #certify .swiper-slide p {
  185. line-height: 98px;
  186. padding-top: 0;
  187. text-align: center;
  188. color: #636363;
  189. font-size: 1.1em;
  190. margin: 0;
  191. }
  192. #certify /deep/.swiper-pagination {
  193. width: 100%;
  194. bottom: 20px;
  195. }
  196. #certify /deep/.swiper-pagination-bullets .swiper-pagination-bullet {
  197. outline: none;
  198. margin: 0 5px;
  199. border: 2px solid #fff;
  200. background-color: transparent;
  201. width: 10px;
  202. height: 10px;
  203. opacity: 1;
  204. }
  205. #certify /deep/.swiper-pagination-bullets .swiper-pagination-bullet-active {
  206. border: 2px solid #00aadc;
  207. background-color: transparent;
  208. }
  209. #certify .swiper-button-prev {
  210. left: -30px;
  211. width: 45px;
  212. height: 46px;
  213. background-repeat: no-repeat;
  214. background-position: 0 0;
  215. background-size: 100%;
  216. outline: none;
  217. }
  218. #certify .swiper-button-prev:hover {
  219. background-position: 0 -46px;
  220. background-size: 100%;
  221. }
  222. #certify .swiper-button-next {
  223. right: -30px;
  224. width: 45px;
  225. height: 46px;
  226. background-repeat: no-repeat;
  227. background-position: 0 -93px;
  228. background-size: 100%;
  229. outline: none;
  230. }
  231. #certify .swiper-button-next:hover {
  232. background-position: 0 -139px;
  233. background-size: 100%;
  234. }
  235. .btn-box {
  236. position: absolute;
  237. right: 0;
  238. color: #fff;
  239. top: 50%;
  240. transform: translateY(-50%);
  241. line-height: 36px;
  242. font-size: 15px;
  243. font-weight: 600;
  244. text-align: left;
  245. li {
  246. padding: 0 30px;
  247. cursor: pointer;
  248. }
  249. li.active {
  250. background: rgba(255, 255, 255, 0.3);
  251. border-top-left-radius: 30px;
  252. border-bottom-left-radius: 30px;
  253. }
  254. }
  255. }
  256. </style>