/**
 * Created by liaili on 16/10/13.
 */

import "./index.less";
import "./index.html";
import $ from 'jquery';
import template from '../../common/template';
import 'swiper/dist/css/swiper.css';


if (location.pathname == '/index.html' || location.pathname == '/') {

  const Swiper = require('swiper/dist/js/swiper.jquery');

  const banners = [{
    title: '', img: require('./images/banner-1.jpg'), link: ''
  }, {
    title: '', img: require('./images/banner-2.jpg'), link: ''
  }, {
    title: '', img: require('./images/banner-3.jpg'), link: ''
  }];

  $('#main-banner .swiper-wrapper').html(
    banners.map(banner =>
      template('<a class="swiper-slide" title="{{title}}"><img width="100%" src="{{img}}"/></a>', banner)
    ).join('')
  );

// 初始化页面Banner swiper 组件
  var mySwiper = new window.Swiper('.swiper-container', {
    autoplay: 3000,//可选选项，自动滑动
    autoplayDisableOnInteraction: false,
    paginationClickable: true,
    pagination: '.swiper-pagination',
    loop: true
  });
  mySwiper.startAutoplay();
}
