main.js 3.5 KB

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