main.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. import Vue from 'vue'
  2. import App from './App'
  3. //商城 begin
  4. import Server from './utils/server'
  5. import Storage from './utils/storage'
  6. import ApiEx from './utils/api'
  7. import Mixin from './utils/mixin'
  8. import Global from './utils/global'
  9. import Auth from './utils/auth'
  10. import Cache from './utils/cache'
  11. import Util from './utils/util2'
  12. import Dialog from './utils/dialog'
  13. import Filter from './utils/filter'
  14. import Mpi from './utils/mpi'
  15. //商城 end
  16. //uview
  17. import uView from 'uview-ui';
  18. Vue.use(uView);
  19. Vue.config.productionTip = false
  20. App.mpType = 'app'
  21. //封装判空函数
  22. Vue.prototype.$isEmpty=function(value){
  23. switch (typeof value) {
  24. case 'undefined':
  25. return true;
  26. case 'string':
  27. if(value=='undefined') return true
  28. if (value.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/g, '').length == 0) return true;
  29. break;
  30. case 'boolean':
  31. if (!value) return true;
  32. break;
  33. case 'number':
  34. if (0 === value || isNaN(value)) return true;
  35. break;
  36. case 'object':
  37. if (null === value || value.length === 0) return true;
  38. for (var i in value) {
  39. return false;
  40. }
  41. return true;
  42. }
  43. return false;
  44. }
  45. // 商城 begin
  46. // 设置服务器
  47. Global.server = Server
  48. // 版本
  49. Cache.preKey = Server.version
  50. // 全局注入
  51. Vue.mixin(Mixin)
  52. // 全局筛选器
  53. Object.keys(Filter).forEach(key => {
  54. Vue.filter(key, Filter[key])
  55. })
  56. // 全局属性 接口
  57. Vue.prototype.$api = Object.assign({}, ApiEx)
  58. // 全局属性 全局变量
  59. Vue.prototype.$global = Global
  60. // 全局缓存
  61. Vue.prototype.$storage = Storage
  62. // 同意授权
  63. Vue.prototype.$auth = Auth
  64. // 全局属性 工具函数
  65. Vue.prototype.$util = Util
  66. // 微信函数封装
  67. Vue.prototype.$mpi = Mpi
  68. // 全局属性 对话框函数
  69. Dialog.config = Object.assign(Dialog.config,{
  70. cancelColor:'#333',
  71. confirmColor:'#333',
  72. title:'温馨提示'
  73. })
  74. Vue.prototype.$dialog = Dialog
  75. // 商城 end
  76. const app = new Vue({
  77. ...App
  78. })
  79. app.$mount()