main.js 3.1 KB

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