main.js 3.2 KB

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