import './index.scss'
import PayH5 from './src/PayH5.vue'
import PayWeChart from './src/PayWeChart.vue'

const components = [
  PayH5,
  PayWeChart
]

const install = function (Vue, opts = {}) {
  /* 存在国际化 */
  if (opts.i18n) {
    const msgs = opts.i18n.messages
    for (const k in msgs) {
      opts.i18n.setLocaleMessage(k, Object.assign(msgs[k], require('./assets/languages/' + k + '.json')))
    }
  }

  components.forEach(component => {
    Vue.component(component.name, component)
  })
}

/* istanbul ignore if */
if (typeof window !== 'undefined' && window.Vue) {
  install(window.Vue)
}

export default {
  install,
  PayH5,
  PayWeChart
}
