main.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. // localStorage.setItem('Wx-Token','eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjE3ODIzNDkxMTYyMzI4OTI0MTcsIm5iZiI6MTcxMzg0MzIzMjY2Niwicm9sZSI6Im1rdF91c2VyIiwicHJ2IjoiMGU1ZWM0NzM3NDk3NmFmY2NlZGJiY2Y1ZGVlNzVmMDE0Y2E1YjliNSIsImV4cCI6LTEsImlhdCI6MTcxMzg0MzIzMjY2NiwianRpIjoieGJ5N3ljbWxqNGduYXcybyJ9.Iv04__mjBDEV75QU8kbrJX2umQIKDZE87-kTD5LG4vg')
  47. // localStorage.setItem('wx_user_info',JSON.stringify({"id":"1782349116232892417","name":"雷阳","mobile":"15270803986","statistics":{"teamAmount":0,"saleAmount":0},"imgUrl":"","marketable":1,"utoken":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjE3ODIzNDkxMTYyMzI4OTI0MTcsIm5iZiI6MTcxMzg0MzIzMjY2Niwicm9sZSI6Im1rdF91c2VyIiwicHJ2IjoiMGU1ZWM0NzM3NDk3NmFmY2NlZGJiY2Y1ZGVlNzVmMDE0Y2E1YjliNSIsImV4cCI6LTEsImlhdCI6MTcxMzg0MzIzMjY2NiwianRpIjoieGJ5N3ljbWxqNGduYXcybyJ9.Iv04__mjBDEV75QU8kbrJX2umQIKDZE87-kTD5LG4vg"}))
  48. // true为APP打包,false为M端打包
  49. Vue.prototype.$isApp = true
  50. Vue.use(VueScroller)
  51. Vue.component('icon', icon)
  52. Vue.component('noData', noData)
  53. Vue.component('userImage', userImage)
  54. 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)
  55. Vue.prototype.$route_back = function (setp) {
  56. if (typeof (setp) == 'undefined') {
  57. setp = -1
  58. }
  59. if (window.history.length <= 1 && window.plus) {
  60. //先关掉键盘再
  61. document.activeElement.blur()
  62. setTimeout(() => {
  63. plus.webview.currentWebview().close()
  64. }, 100)
  65. } else {
  66. router.go(-1)
  67. }
  68. }
  69. Vue.directive('isKeyboard', function (el) {
  70. let isAndroid = true;
  71. if (navigator.userAgent.indexOf('Android') > 0) {
  72. isAndroid = true;
  73. } else {
  74. isAndroid = false;
  75. }
  76. if (isAndroid) {
  77. //获取原窗口的高度
  78. var originalHeight = document.documentElement.clientHeight || document.body.clientHeight;
  79. window.onresize = function () {
  80. //键盘弹起与隐藏都会引起窗口的高度发生变化
  81. var resizeHeight = document.documentElement.clientHeight || document.body.clientHeight;
  82. if (resizeHeight - 0 < originalHeight - 0) {
  83. // console.log("键盘收起")
  84. el.style['display'] = 'none'
  85. } else {
  86. // console.log("键盘放下")
  87. el.style['display'] = 'block'
  88. }
  89. };
  90. } else { // ios:focusin和focusout支持冒泡,对应focus和blur, 使用focusin和focusout的原因是focusin和focusout可以冒泡,focus和blur不会冒泡,这样就可以使用事件代理,处理多个输入框存在的情况。
  91. document.body.addEventListener("focusin", () => {
  92. //软键盘弹出的事件处理
  93. el.style['display'] = 'none'
  94. });
  95. document.body.addEventListener("focusout", () => {
  96. //软键盘收起的事件处理
  97. el.style['display'] = 'block'
  98. });
  99. }
  100. })
  101. Vue.config.productionTip = false
  102. window.VueObj = new Vue({
  103. el: '#app',
  104. router,
  105. store,
  106. components: {
  107. App
  108. },
  109. template: '<App/>'
  110. })