main.js 3.1 KB

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