main.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. //uview 封装提示框
  33. Vue.prototype.$showToast=function(title,type,position){
  34. this.$refs.uToast.show({
  35. title: title,
  36. position:position||'top',
  37. type: type ||'success'
  38. })
  39. }
  40. //封装提示框
  41. Vue.prototype.$showModel = (content,isShowCancel=true,title='提示',)=>{
  42. return new Promise((resolve,reject)=>{
  43. uni.showModal({
  44. title: title,
  45. content: content,
  46. showCancel:isShowCancel,
  47. success: (res)=>{
  48. if (res.confirm) {
  49. resolve(res)
  50. }
  51. }
  52. });
  53. })
  54. }
  55. /**封装判空函数
  56. * @param {Object} value
  57. */
  58. Vue.prototype.$isEmpty=function(value){
  59. switch (typeof value) {
  60. case 'undefined':
  61. return true;
  62. case 'string':
  63. if(value=='undefined') return true
  64. if (value.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/g, '').length == 0) return true;
  65. break;
  66. case 'boolean':
  67. if (!value) return true;
  68. break;
  69. case 'number':
  70. if (0 === value || isNaN(value)) return true;
  71. break;
  72. case 'object':
  73. if (null === value || value.length === 0) return true;
  74. for (var i in value) {
  75. return false;
  76. }
  77. return true;
  78. }
  79. return false;
  80. }
  81. Vue.config.productionTip = false
  82. App.mpType = 'app'
  83. const app = new Vue({
  84. ...App
  85. })
  86. app.$mount()