main.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. import Vue from 'vue'
  2. import App from './App'
  3. import router from './router'
  4. import store from './store'
  5. import echarts from 'echarts'
  6. import moment from 'moment' // 时间库
  7. import '@/permission'
  8. import '@/utils/validator'
  9. import '@/assets/css/reset.css'
  10. import '@/attendanceSet' // 考勤相关
  11. import '@/performanceSet' // 绩效系统相关配置
  12. import icon from 'vue2-svg-icon/Icon'
  13. import VueScroller from '@/components/scroller/src'
  14. import noData from '@/components/noData'
  15. import userImage from '@/components/user_image'
  16. import * as socketApi from '@/api/websocket'
  17. import * as socketApiTow from '@/api/websocketTow'
  18. import axios from '@/utils/axios'
  19. import axiosKq from '@/utils/axiosKq'
  20. import axiosUser from '@/utils/axiosUser'
  21. import axiosKc from '@/utils/axiosKc'
  22. import 'shepherd.js/dist/css/shepherd.css';
  23. import { Tabbar, Empty, TabbarItem, ShareSheet, Loading, Divider, Overlay,Grid, GridItem, Form, Field, NavBar, Row, Col, List, Picker, Cell, CellGroup, Toast, Popup, Dialog, RadioGroup, Radio, Notify, Button, Icon, Tab, Tabs } from 'vant'
  24. import { getWxToken, setWxToken, getIsIdentity, supremeAuthority, getIsWx, getTypes, getTypesName, getUserData, getEmployeeMap, getCache, setCache, removeCache, returnDeptName, getEmployeeMapItem, returnFh } from '@/utils/auth'
  25. Vue.prototype.$echarts = echarts
  26. Vue.prototype.$moment = moment
  27. Vue.prototype.$getTypesName = getTypesName
  28. Vue.prototype.$getTypes = getTypes()
  29. Vue.prototype.$userInfo = getUserData;
  30. Vue.prototype.$getEmployeeMap = getEmployeeMap
  31. Vue.prototype.$getEmployeeMapItem = getEmployeeMapItem
  32. Vue.prototype.$getCache = getCache
  33. Vue.prototype.$setCache = setCache
  34. Vue.prototype.$getIsIdentity = getIsIdentity
  35. Vue.prototype.$supremeAuthority = supremeAuthority
  36. Vue.prototype.$axios = axios
  37. Vue.prototype.$axiosUser = axiosUser
  38. Vue.prototype.$axiosKq = axiosKq
  39. Vue.prototype.$axiosKc = axiosKc
  40. Vue.prototype.$removeCache = removeCache
  41. Vue.prototype.$returnDeptName = returnDeptName
  42. Vue.prototype.$socketApi = socketApi //长连接
  43. Vue.prototype.$socketApiTow = socketApiTow //长连接
  44. Vue.prototype.$returnFh = returnFh
  45. Vue.prototype.$isWx = getIsWx()
  46. // true为APP打包,false为M端打包
  47. Vue.prototype.$isApp = true
  48. Vue.use(VueScroller)
  49. Vue.component('icon', icon)
  50. Vue.component('noData', noData)
  51. Vue.component('userImage', userImage)
  52. Vue.use(Button).use(Tabbar).use(TabbarItem).use(ShareSheet).use(Grid).use(Overlay).use(Loading).use(Divider).use(GridItem).use(Picker).use(Form).use(Field).use(List).use(Tabs).use(Tab).use(NavBar).use(Row).use(Col).use(Cell).use(CellGroup).use(Toast).use(Popup).use(Dialog).use(RadioGroup).use(Radio).use(Icon).use(Notify).use(Empty)
  53. Vue.prototype.$route_back = function (setp) {
  54. if (typeof (setp) == 'undefined') {
  55. setp = -1
  56. }
  57. if (window.history.length <= 1 && window.plus) {
  58. //先关掉键盘再
  59. document.activeElement.blur()
  60. setTimeout(() => {
  61. plus.webview.currentWebview().close()
  62. }, 100)
  63. } else {
  64. router.go(-1)
  65. }
  66. }
  67. Vue.directive('isKeyboard', function (el) {
  68. let isAndroid = true;
  69. if (navigator.userAgent.indexOf('Android') > 0) {
  70. isAndroid = true;
  71. } else {
  72. isAndroid = false;
  73. }
  74. if (isAndroid) {
  75. //获取原窗口的高度
  76. var originalHeight = document.documentElement.clientHeight || document.body.clientHeight;
  77. window.onresize = function () {
  78. //键盘弹起与隐藏都会引起窗口的高度发生变化
  79. var resizeHeight = document.documentElement.clientHeight || document.body.clientHeight;
  80. if (resizeHeight - 0 < originalHeight - 0) {
  81. // console.log("键盘收起")
  82. el.style['display'] = 'none'
  83. } else {
  84. // console.log("键盘放下")
  85. el.style['display'] = 'block'
  86. }
  87. };
  88. } else { // ios:focusin和focusout支持冒泡,对应focus和blur, 使用focusin和focusout的原因是focusin和focusout可以冒泡,focus和blur不会冒泡,这样就可以使用事件代理,处理多个输入框存在的情况。
  89. document.body.addEventListener("focusin", () => {
  90. //软键盘弹出的事件处理
  91. el.style['display'] = 'none'
  92. });
  93. document.body.addEventListener("focusout", () => {
  94. //软键盘收起的事件处理
  95. el.style['display'] = 'block'
  96. });
  97. }
  98. })
  99. Vue.config.productionTip = false
  100. window.VueObj = new Vue({
  101. el: '#app',
  102. router,
  103. store,
  104. components: {
  105. App
  106. },
  107. template: '<App/>'
  108. })