main.js 2.7 KB

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