main.js 2.3 KB

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