main.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import Vue from 'vue'
  2. import App from './App'
  3. import store from '@/store'
  4. import getConfig from '@/config'
  5. Vue.config.productionTip = false
  6. App.mpType = 'app'
  7. import uView from "uview-ui"
  8. Vue.use(uView)
  9. let vuexStore = require("@/store/$u.mixin.js")
  10. Vue.mixin(vuexStore)
  11. // 系统配置
  12. Vue.prototype.$config = function (key) {
  13. const envText = {pro:'生产环境',dev:'开发环境',uat:'预发布环境'}
  14. const theme = getApp().globalData.theme
  15. const config = getConfig(theme)
  16. if(key == 'init'){
  17. let buildType = getApp().globalData.buildType
  18. let baseUrl = config[buildType+'_URL']
  19. getApp().globalData.baseUrl = baseUrl
  20. getApp().globalData.envTips = envText[buildType]
  21. }
  22. return config[key]
  23. }
  24. /**
  25. * 权限检查
  26. */
  27. Vue.prototype.$hasPermissions = function (value) {
  28. let isExist = false;
  29. let permissionsStr = store.state.vuex_userData.permCodes;
  30. // console.log(permissionsStr,'permissionsStr')
  31. if (permissionsStr == undefined || permissionsStr == null) {
  32. return false;
  33. }
  34. let has = permissionsStr.find(item => {
  35. return item == value
  36. })
  37. if (has) {
  38. isExist = true;
  39. }
  40. return isExist;
  41. }
  42. /*
  43. * 提示信息
  44. */
  45. Vue.prototype.toashMsg = function (title) {
  46. title = title == undefined ? "系统繁忙" : title;
  47. uni.showToast({
  48. title:title,
  49. icon:'none'
  50. })
  51. }
  52. const app = new Vue({
  53. store,
  54. ...App
  55. })
  56. app.$mount()