main.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. //配置文件
  17. import config from "@/assets/http/config.js"
  18. Vue.prototype.$config = config
  19. // util begin
  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 'utils/global.js'
  46. Vue.prototype.$global = global
  47. //util end
  48. //封装api
  49. import {
  50. api
  51. } from 'assets/http/api.js'
  52. Vue.prototype.$api = api
  53. //跳转
  54. Vue.prototype.$jump = function(url, events) {
  55. if(this.$isEmpty(url)){
  56. uni.showToast({
  57. title: '暂未开放',
  58. icon: 'none'
  59. });
  60. }
  61. uni.navigateTo({
  62. url,
  63. events,
  64. fail(err) {
  65. console.log(err);
  66. }
  67. })
  68. }
  69. Vue.prototype.$back = function() {
  70. uni.navigateBack({
  71. delta: 1
  72. })
  73. }
  74. //判空函数
  75. Vue.prototype.$isEmpty = function(value) {
  76. switch (typeof value) {
  77. case 'undefined':
  78. return true;
  79. case 'string':
  80. if (value == 'undefined') return true
  81. if (value.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/g, '').length == 0) return true;
  82. break;
  83. case 'boolean':
  84. if (!value) return true;
  85. break;
  86. case 'number':
  87. if (0 === value || isNaN(value)) return true;
  88. break;
  89. case 'object':
  90. if (null === value || value.length === 0) return true;
  91. for (var i in value) {
  92. return false;
  93. }
  94. return true;
  95. }
  96. return false;
  97. }
  98. Vue.prototype.$isNotEmpty = function(value) {
  99. switch (typeof value) {
  100. case 'undefined':
  101. return false;
  102. case 'string':
  103. if (value == 'undefined') return false
  104. if (value.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/g, '').length == 0) return false;
  105. break;
  106. case 'boolean':
  107. if (!value) return false;
  108. break;
  109. case 'number':
  110. if (0 === value || isNaN(value)) return false;
  111. break;
  112. case 'object':
  113. if (null === value || value.length === 0) return false;
  114. for (var i in value) {
  115. return true;
  116. }
  117. return false;
  118. }
  119. return true;
  120. }
  121. // #ifndef VUE3
  122. import Vue from 'vue'
  123. Vue.config.productionTip = false
  124. App.mpType = 'app'
  125. const app = new Vue({
  126. store,
  127. ...App
  128. })
  129. app.$mount();
  130. // #endif
  131. // #ifdef VUE3
  132. import {
  133. createSSRApp
  134. } from 'vue'
  135. export function createApp() {
  136. const app = createSSRApp(App)
  137. return {
  138. app
  139. }
  140. }
  141. // #endif