base.js 2.39 KB
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import GlsxVueComponents from 'glsx-vue-components'
import 'glsx-vue-components/dist/glsx-vue-components.css'
import '@/styles/index.scss'
import { Request as request } from 'glsx-vue-common'
import moment from 'moment'
import XLSX from 'xlsx'
import { utils } from 'glsx-common'
// import axios from 'axios'
Vue.use(GlsxVueComponents)
Vue.use(XLSX)
// Vue.prototype.getAddrUrl = 'https://dj.test.glsx.com.cn/web-dj-site/common/address/getAddressByLngLat'
Vue.prototype.getAddrUrl =
  'http://dj.glsx.com.cn/web-dj-site/common/address/getAddressByLngLat'
Vue.prototype.size = 'mini'
Vue.prototype.$moment = moment
moment.locale('zh-cn')
var mixin = {
  mounted() {
    const _this = this
    const theme = new this.$Theme()
    const connection = this.$Penpal.connectToParent({
      methods: {
        setTheme(color) {
          theme.change(color)
        },
        height() {
          return document.height || document.body.offsetHeight // document.documentElement.clientHeight || document.body.clientHeight //
        }
      }
    })
    connection.promise.then(parent => {
      const cfg = _this.$get_session_config()
      if (cfg) return
      parent.getResources().then(config => {
        _this.$set_session_config(config)
      })
    })
  }
}
// const URL = 'https://oss-config.test.glsx.com.cn/mock/5be17454f31545347559d499/config'
// const getConfig = (url = URL + '/insurance') => {
//   return new Promise((resolve, reject) => {
//     request({ url }).then(res => {
//       if (res.status === 'success') {
//         resolve({ 'vue': Vue, 'config': JSON.parse(res.data) })
//       } else {
//         reject('ERROR.')
//       }
//     })
//   })
// }
const getConfig = () => {
  let params = {
    moduleName: 'glsx-oss-insurance',
    mockUrl:
      'https://oss-config.test.glsx.com.cn/mock/5be17454f31545347559d499/config/insurance',
    httpOptions: {
      Headers: { refererurl: location.href },
      request: { timeout: 30000 }
    }
  }
  return new Promise((resolve, reject) => {
    utils.getConfig(params).then(res => {
      resolve({ vue: Vue, config: res })
    })
  })
}
/* eslint-disable no-new */
const render = App => {
  new Vue({
    el: '#app',
    mixins: [mixin],
    render: h => h(App)
  })
}

export default { render, getConfig }