main.js 2.67 KB
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import '@u/util'
import Vant from 'vant'
import 'vant/lib/index.css'
import VueWechatTitle from 'vue-wechat-title'
import '@a/scss/common.scss'
import store from "./store"
import axios from 'axios'
Vue.use(VueWechatTitle)
import { Lazyload } from 'vant';

Vue.use(Lazyload);
Vue.use(Vant)
import preview from 'vue-photo-preview'
import 'vue-photo-preview/dist/skin.css'
Vue.use(preview)
Vue.config.productionTip = false
Vue.prototype.isMiniprogram = window.__wxjs_environment === 'miniprogram'
Vue.prototype.track = track;

if (!localStorage['sessionId'] || !localStorage['expirationTime'] || (localStorage['sessionId'] && (new Date().getTime() - localStorage['expirationTime']) > 60 * 60 * 1000)) {
  const ua = navigator.userAgent.toLowerCase();
  let terminal;
  if (ua.match(/MicroMessenger/i) == 'micromessenger') {
    terminal = 'h5'
  } else {
    if (Vue.prototype.checkPhoneType() == 'ios') {
      terminal = 'ios'
    } else {
      terminal = 'android'
    }
  }
  let project_id = process.env.VUE_APP_PROJECR_VERSION;
  let secret = process.env.VUE_APP_PROJECR_SECRET;
  let client_id = '';
  let user_id = '';
  track.setCommonConfig({ project_id, secret, client_id, user_id })
  let user = JSON.stringify({
    "user_id": user_id,
    "client_ip": returnCitySN.cip,
    "client_id": localStorage['client_id'],
    "wx_open_id": '',
    "loc_city": returnCitySN.name,
    "loc_province": returnCitySN.name,
    "loc_country": '',
    "network_carrier": '',
    "device_model": '',
    "brand": Vue.prototype.getDetect().brand,
    "resolution": window.screen.width + '*' + window.screen.height,
    "browser_version": window.navigator.appVersion,
    "browser": Vue.prototype.getDetect().userAgent,
    "os_name": Vue.prototype.getDetect().os_name,
    "os_version": Vue.prototype.getDetect().version,
    "network_type": window.navigator.connection ? window.navigator.connection.effectiveType : '',
    "terminal": terminal
  })
  track.getSessionId('/collectdata/login', user, function () {
    axios({
      baseURL: process.env.VUE_APP_REPO + '/scrm-equity-mobile-config',
      method: 'get'
    }).then(({
      data: config
    }) => {
      window.$baseConfig = config
      window.vm = new Vue({
        router,
        store,
        render: h => {
          return h(App)
        }
      }).$mount('#app')
    })
  })
} else {
  axios({
    baseURL: process.env.VUE_APP_REPO + '/scrm-equity-mobile-config',
    method: 'get'
  }).then(({
    data: config
  }) => {
    window.$baseConfig = config
    window.vm = new Vue({
      router,
      store,
      render: h => {
        return h(App)
      }
    }).$mount('#app')
  })
}