main.js 1.5 KB

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