main.js 3.0 KB

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