import Vue from 'vue'
import App from './App'
import store from './vuex/index'
import router from './router'

import 'element-ui/lib/theme-chalk/index.css'
import ElementUI from 'element-ui';

Vue.use(ElementUI);

import VueWechatTitle from 'vue-wechat-title';

Vue.use(VueWechatTitle)

import 'babel-polyfill'
import Es6Promise from 'es6-promise'

require('es6-promise').polyfill()
Es6Promise.polyfill()

require('./assets/js/filter')
import './assets/icons'

Vue.config.productionTip = false

import Viewer from 'v-viewer'
import 'viewerjs/dist/viewer.css'
import $ from 'jquery'

Vue.use(Viewer, {
  defaultOptions: {
    zIndex: 9999,
    url: "data-source",
    title: true,
    view: function (e) {
      setTimeout(function () {
        $('.viewer-canvas img').css('height',(document.body.clientHeight-150)+'px')
      },100)
      if(e.detail.originalImage.title){
        $('.viewer-title').hide()
        $('.viewer-new-title').remove()
        $('.viewer-footer').prepend('<div class="viewer-new-title">'+e.detail.originalImage.title+'</div>')
        setTimeout(function () {
          $('.viewer-title').html(e.target.innerText)
        },100)
      }
    },
  }
})

import VueLazyload from 'vue-lazyload'

Vue.use(VueLazyload, {
  preLoad: 1.3,
  error: require('./assets/img/404.jpg'),
  loading: require('./assets/img/loading.svg'),
  attempt: 1,
  listenEvents: ['scroll']
})

new Vue({
  el: '#app',
  store,
  router,
  render: h => h(App)
})
