main.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import App from './App'
  2. import Vue from 'vue'
  3. Vue.prototype.$token = false
  4. Vue.prototype.$userInfo = null
  5. uni.getStorage({
  6. key: "userInfo",
  7. success(_data) {
  8. Vue.prototype.$userInfo = _data.data
  9. },
  10. fail() {
  11. Vue.prototype.$userInfo = null
  12. }
  13. })
  14. Vue.prototype.$token = uni.getStorageSync('Authorization')
  15. //公用链接
  16. import env from '@/util/env.js'
  17. Vue.prototype.$baseUrl = env.baseUrl
  18. //公用请求
  19. import httpServer from "@/util/http.js"
  20. Vue.prototype.$get = httpServer.get
  21. Vue.prototype.$post = httpServer.post
  22. import w_md5 from "js_sdk/zww-md5/w_md5.js"
  23. Vue.prototype.$w_md5 = w_md5;
  24. import Mixin from './polyfill/mixins'
  25. Vue.mixin(Mixin)
  26. import VueI18n from 'vue-i18n';
  27. Vue.use(VueI18n)
  28. const i18n = new VueI18n({
  29. // #ifdef MP
  30. locale: 'zh-CN', //初始化,保证刷新页面也保留
  31. // #endif
  32. // #ifdef APP-PLUS
  33. locale: plus.storage.getItem('locale') || 'zh-CN', //初始化,保证刷新页面也保留
  34. // #endif
  35. // #ifdef H5
  36. locale: localStorage.getItem('locale') || 'zh-CN', //初始化,保证刷新页面也保留
  37. // #endif
  38. // 加载语言文件的内容
  39. messages: {
  40. 'zh-CN': require('./lang/cn.js').lang,
  41. 'en': require('./lang/en.js').lang
  42. }
  43. })
  44. Vue.config.productionTip = false
  45. App.mpType = 'app'
  46. const app = new Vue({
  47. i18n,
  48. ...App
  49. })
  50. app.$mount()