main.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. import Vue from 'vue'
  2. import App from './App'
  3. //uview 组件
  4. import uView from 'uview-ui';
  5. Vue.use(uView);
  6. import addBtn from '@/components/addBtn/addBtn.vue'
  7. Vue.component('addBtn',addBtn)
  8. //mescroll
  9. import MescrollBody from "@/components/mescroll-body/mescroll-body.vue"
  10. Vue.component('mescroll-body', MescrollBody)
  11. //封装api
  12. import { api } from 'assets/http/api.js'
  13. Vue.prototype.$api = api
  14. //全局变量
  15. import Global from './utils/global'
  16. Vue.prototype.$global = Global
  17. //缓存
  18. import simpleCache from "@/utils/cache.js"
  19. Vue.prototype.$cache = simpleCache
  20. //校验文件
  21. import verify from 'utils/verify.js'
  22. Vue.prototype.$verify = verify
  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 util from 'utils/util.js'
  31. Vue.prototype.$util = util
  32. // 微信函数封装
  33. import Mpi from './utils/mpi'
  34. Vue.prototype.$mpi = Mpi
  35. //uview 封装提示框
  36. Vue.prototype.$showToast=function(title,type,position){
  37. this.$refs.uToast.show({
  38. title: title,
  39. position:position||'top',
  40. type: type ||'success'
  41. })
  42. }
  43. //封装提示框
  44. Vue.prototype.$showModel = (content,isShowCancel=true,title='提示',)=>{
  45. return new Promise((resolve,reject)=>{
  46. uni.showModal({
  47. title: title,
  48. content: content,
  49. showCancel:isShowCancel,
  50. success: (res)=>{
  51. if (res.confirm) {
  52. resolve(res)
  53. }
  54. }
  55. });
  56. })
  57. }
  58. Vue.prototype.$navigateBack=(delta=1)=>{
  59. uni.navigateBack({
  60. delta
  61. })
  62. }
  63. /**封装判空函数
  64. * @param {Object} value
  65. */
  66. Vue.prototype.$isEmpty=function(value){
  67. switch (typeof value) {
  68. case 'undefined':
  69. return true;
  70. case 'string':
  71. if(value=='undefined') return true
  72. if (value.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/g, '').length == 0) return true;
  73. break;
  74. case 'boolean':
  75. if (!value) return true;
  76. break;
  77. case 'number':
  78. if (0 === value || isNaN(value)) return true;
  79. break;
  80. case 'object':
  81. if (null === value || value.length === 0) return true;
  82. for (var i in value) {
  83. return false;
  84. }
  85. return true;
  86. }
  87. return false;
  88. }
  89. Vue.config.productionTip = false
  90. App.mpType = 'app'
  91. const app = new Vue({
  92. ...App
  93. })
  94. app.$mount()