main.js 3.4 KB

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