main.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. import Vue from 'vue'
  2. import App from './App'
  3. //商城 begin
  4. import store from '@/store';
  5. import Server from './utils/server'
  6. import Storage from './utils/storage'
  7. import ApiEx from './utils/api'
  8. import Mixin from './utils/mixin'
  9. import Global from './utils/global'
  10. import Auth from './utils/auth'
  11. import Cache from './utils/cache'
  12. import Util from './utils/util2'
  13. import Dialog from './utils/dialog'
  14. import Filter from './utils/filter'
  15. import Mpi from './utils/mpi'
  16. //商城 end
  17. let vuexStore = require("@/store/$u.mixin.js");
  18. Vue.mixin(vuexStore);
  19. //uview
  20. import uView from 'uview-ui';
  21. Vue.use(uView);
  22. Vue.config.productionTip = false
  23. App.mpType = 'app'
  24. import MescrollBody from "@/comps/mescroll-body/mescroll-body.vue"
  25. Vue.component('mescroll-body', MescrollBody)
  26. //小程序参数
  27. Vue.prototype.$wxData={
  28. APPID:'wxaeb044e4a6b97df4',
  29. SECRET:'0c575e3f4ae59ea630bbb90abcc4852c',
  30. GRANTTYPE:'client_credential'
  31. }
  32. //解决ios系统时间显示错误问题
  33. Vue.prototype.$commonDate=value=>{
  34. return new Date(value.replace(/\-/g, '/'))
  35. }
  36. //封装小程序审核时的标题设置
  37. Vue.prototype.$setNavigationBarTitle=(auditTitle,title)=>{
  38. let appletType= uni.getStorageSync('appletType')
  39. if (appletType==0) {
  40. uni.setNavigationBarTitle({
  41. title:auditTitle
  42. })
  43. }else{
  44. uni.setNavigationBarTitle({
  45. title:title
  46. })
  47. }
  48. return appletType
  49. }
  50. //封装判空函数
  51. Vue.prototype.$isEmpty=function(value){
  52. switch (typeof value) {
  53. case 'undefined':
  54. return true;
  55. case 'string':
  56. if(value=='undefined') return true
  57. if (value.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/g, '').length == 0) return true;
  58. break;
  59. case 'boolean':
  60. if (!value) return true;
  61. break;
  62. case 'number':
  63. if (0 === value || isNaN(value)) return true;
  64. break;
  65. case 'object':
  66. if (null === value || value.length === 0) return true;
  67. for (var i in value) {
  68. return false;
  69. }
  70. return true;
  71. }
  72. return false;
  73. }
  74. // 商城 begin
  75. // 设置服务器
  76. Global.server = Server
  77. // 版本
  78. Cache.preKey = Server.version
  79. // 全局注入
  80. Vue.mixin(Mixin)
  81. // 全局筛选器
  82. Object.keys(Filter).forEach(key => {
  83. Vue.filter(key, Filter[key])
  84. })
  85. // 全局属性 接口
  86. Vue.prototype.$api = Object.assign({}, ApiEx)
  87. // 全局属性 全局变量
  88. Vue.prototype.$global = Global
  89. // 全局缓存
  90. Vue.prototype.$storage = Storage
  91. // 同意授权
  92. Vue.prototype.$auth = Auth
  93. // 全局属性 工具函数
  94. Vue.prototype.$util = Util
  95. // 微信函数封装
  96. Vue.prototype.$mpi = Mpi
  97. // 全局属性 对话框函数
  98. Dialog.config = Object.assign(Dialog.config,{
  99. cancelColor:'#333',
  100. confirmColor:'#333',
  101. title:'温馨提示'
  102. })
  103. Vue.prototype.$dialog = Dialog
  104. // 商城 end
  105. const app = new Vue({
  106. store,
  107. ...App
  108. })
  109. app.$mount()