main.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. import Vue from 'vue'
  2. import App from './App'
  3. //store
  4. import store from '@/store';
  5. let vuexStore = require("@/store/$u.mixin.js");
  6. Vue.mixin(vuexStore);
  7. //uView
  8. import uView from "uview-ui";
  9. Vue.use(uView);
  10. import toast from '@/components/toast/toast.vue'
  11. Vue.use(toast)
  12. import loading from '@/components/loading/loading.vue'
  13. Vue.use(loading)
  14. //mescroll
  15. import MescrollBody from "@/components/mescroll-body/mescroll-body.vue"
  16. Vue.component('MescrollBody', MescrollBody)
  17. //封装api
  18. import { api } from 'assets/http/api.js'
  19. Vue.prototype.$api = api
  20. //缓存
  21. import simpleCache from "@/utils/cache.js"
  22. Vue.prototype.$cache = simpleCache
  23. //封装日期时间工具类
  24. import dateTime from 'utils/dateTime.js'
  25. Vue.prototype.$dateTime = dateTime
  26. //封装提示工具
  27. import dialog from 'utils/dialog.js'
  28. Vue.prototype.$dialog = dialog
  29. //数字处理
  30. import digital from './utils/digital.js'
  31. Vue.prototype.$digital = digital
  32. // 全局注入
  33. import Mixin from './utils/mixin'
  34. Vue.mixin(Mixin)
  35. // 微信函数封装
  36. import Mpi from './utils/mpi'
  37. Vue.prototype.$mpi = Mpi
  38. //引入工具类
  39. import util from 'utils/util.js'
  40. Vue.prototype.$util = util
  41. //校验文件
  42. import verify from 'utils/verify.js'
  43. Vue.prototype.$verify = verify
  44. //全局变量
  45. import global from './assets/http/global.js'
  46. Vue.prototype.$global = global
  47. //判断是不是微信浏览器
  48. Vue.prototype.$isWxBrowser = () => {
  49. let flag=false
  50. try{
  51. let na = navigator.userAgent.toLowerCase();
  52. flag=na.indexOf('micromessenger') !== -1
  53. }catch(e){
  54. flag=false
  55. }
  56. return flag;
  57. }
  58. //跳转
  59. Vue.prototype.$jump=function(url,events){
  60. uni.navigateTo({
  61. url,
  62. events
  63. })
  64. }
  65. Vue.prototype.$back=function(){
  66. uni.navigateBack({
  67. delta:1
  68. })
  69. }
  70. //判空函数
  71. Vue.prototype.$isEmpty=function(value){
  72. switch (typeof value) {
  73. case 'undefined':
  74. return true;
  75. case 'string':
  76. if(value=='undefined') return true
  77. if (value.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/g, '').length == 0) return true;
  78. break;
  79. case 'boolean':
  80. if (!value) return true;
  81. break;
  82. case 'number':
  83. if (0 === value || isNaN(value)) return true;
  84. break;
  85. case 'object':
  86. if (null === value || value.length === 0) return true;
  87. for (var i in value) {
  88. return false;
  89. }
  90. return true;
  91. }
  92. return false;
  93. }
  94. Vue.prototype.$isNotEmpty=function(value){
  95. switch (typeof value) {
  96. case 'undefined':
  97. return false;
  98. case 'string':
  99. if(value=='undefined') return false
  100. if (value.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/g, '').length == 0) return false;
  101. break;
  102. case 'boolean':
  103. if (!value) return false;
  104. break;
  105. case 'number':
  106. if (0 === value || isNaN(value)) return false;
  107. break;
  108. case 'object':
  109. if (null === value || value.length === 0) return false;
  110. for (var i in value) {
  111. return true;
  112. }
  113. return false;
  114. }
  115. return true;
  116. }
  117. Vue.config.productionTip = false
  118. App.mpType = 'app'
  119. const app = new Vue({
  120. store,
  121. ...App
  122. })
  123. app.$mount()