main.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. import Vue from 'vue'
  2. import App from './App'
  3. import store from './store'
  4. import WpTabbar from '@/pages/tabbar/wpTabbar'
  5. // 引入全局uView
  6. import uView from '@/uni_modules/uview-ui'
  7. import mixin from './common/mixin'
  8. import postSelect from 'pageApp/components/postSelect.vue'
  9. import deptSelect from 'pageApp/components/deptSelect.vue'
  10. import dictSelect from 'pageApp/components/dictSelect.vue'
  11. import input from 'pageApp/components/input.vue'
  12. import show from 'pageApp/components/show.vue'
  13. import flowSubmit from 'pageApp/components/flowSubmit.vue'
  14. import photo from 'pageApp/components/photo.vue'
  15. import wsRequest from 'util/webSocket/wsRequest.js'
  16. import {
  17. httpRequest,
  18. BASE_URL,
  19. BASE_SOCKET_URL,
  20. goto,
  21. goTab,
  22. goBack,
  23. dateResult,
  24. showModal,
  25. getDicts,
  26. dictTranslation,
  27. getUrlType,
  28. getConfigData,
  29. getAllConfigData,
  30. getAllDicts
  31. } from './util/request/api.js'
  32. Vue.component('wp-tabbar', WpTabbar);
  33. Vue.prototype.$httpRequest = httpRequest
  34. Vue.prototype.$BASE_URL = BASE_URL
  35. Vue.prototype.$BASE_SOCKET_URL = BASE_SOCKET_URL
  36. Vue.prototype.$goto = goto
  37. Vue.prototype.$goTab = goTab
  38. Vue.prototype.$goBack = goBack
  39. Vue.prototype.$dateResult = dateResult
  40. Vue.prototype.$showModal = showModal
  41. Vue.prototype.$getDicts = getDicts
  42. Vue.prototype.$getUrlType = getUrlType
  43. Vue.prototype.$dictTranslation = dictTranslation
  44. Vue.prototype.$getConfigData = getConfigData
  45. Vue.prototype.$getAllConfigData = getAllConfigData
  46. Vue.prototype.$getAllDicts = getAllDicts
  47. Vue.prototype.$wsConnection = new wsRequest(8000)
  48. // 入口文件 main.js
  49. Vue.prototype.$getRect = function(selector, all) {
  50. return new Promise(resolve => {
  51. uni.createSelectorQuery().
  52. in(this)[all ? 'selectAll' : 'select'](selector)
  53. .boundingClientRect(rect => {
  54. if (all && Array.isArray(rect) && rect.length) {
  55. resolve(rect)
  56. }
  57. if (!all && rect) {
  58. resolve(rect)
  59. }
  60. })
  61. .exec()
  62. })
  63. }
  64. Vue.prototype.$store = store
  65. Vue.component('hs-post-select', postSelect)
  66. Vue.component('hs-dept-select', deptSelect)
  67. Vue.component('hs-dict-select', dictSelect)
  68. Vue.component('hs-input', input)
  69. Vue.component('hs-show', show)
  70. Vue.component('hs-flow-submit', flowSubmit)
  71. Vue.component('hs-photo', photo)
  72. Vue.config.productionTip = false
  73. App.mpType = 'app'
  74. Vue.use(uView)
  75. // #ifdef MP
  76. // 引入uView对小程序分享的mixin封装
  77. const mpShare = require('@/uni_modules/uview-ui/libs/mixin/mpShare.js')
  78. Vue.mixin(mpShare)
  79. // #endif
  80. Vue.mixin(mixin)
  81. const app = new Vue({
  82. store,
  83. ...App
  84. })
  85. // 引入请求封装
  86. require('./util/request/index')(app)
  87. app.$mount()