Files
ebiz-h5/src/main.js
勾通 958c8f8b01 【FEAT】新增问卷测评部分逻辑
(cherry picked from commit eb15794b9a)
2025-11-18 13:51:37 +08:00

161 lines
3.7 KiB
JavaScript

import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import Filters from '@/filters'
import FastClick from 'fastclick'
import '@/assets/js/utils/validator' //表单校验
import Jump from '@/assets/js/utils/jump'
import utils from '@/assets/js/business-common'
import config from '@/config'
import noMoreClick from '@/directive/noMoreClick'
import vueHashCalendar from 'vue-hash-calendar'
import 'vue-hash-calendar/lib/vue-hash-calendar.css'
import md5 from 'js-md5'
import cryptoJs from 'crypto-js'
import cacheUtils from '@/assets/js/utils/cacheUtils'
import animated from 'animate.css'
import {
Cell,
CellGroup,
DatetimePicker,
Popup,
Picker,
Col,
Row,
Tab,
Tabs,
NavBar,
Toast,
Button,
Dialog,
Icon,
Lazyload,
Field,
Area,
Uploader,
PullRefresh,
List,
Image as VanImage,
Sticky,
Radio,
RadioGroup,
Checkbox,
CheckboxGroup
} from 'vant'
Vue.use(Cell)
Vue.use(CellGroup)
Vue.use(DatetimePicker)
Vue.use(Popup)
Vue.use(Picker)
Vue.use(Col)
Vue.use(Row)
Vue.use(Tab)
Vue.use(Tabs)
Vue.use(Icon)
Vue.use(vueHashCalendar)
Vue.use(NavBar)
Vue.use(Toast)
Vue.use(Button)
Vue.use(Dialog)
Vue.use(Lazyload, {
lazyComponent: true
})
Vue.use(Field)
Vue.use(Area)
Vue.use(Uploader)
Vue.use(PullRefresh)
Vue.use(List)
Vue.use(VanImage)
Vue.use(Sticky)
Vue.use(animated)
Vue.use(Radio)
Vue.use(RadioGroup)
Vue.use(Checkbox)
Vue.use(CheckboxGroup)
Vue.prototype.$assetsUrl = config.assetsUrl
Vue.prototype.$assetsUpUrl = config.assetsUpUrl
Vue.prototype.$mainUrl = config.mainUrl
Vue.prototype.$zssqUrl = config.zssqUrl
Vue.prototype.$MD5 = md5
Vue.prototype.$CryptoJs = cryptoJs
Vue.prototype.$CacheUtils = cacheUtils
// 全局 防重复点击
Vue.directive('no-more-click', noMoreClick)
//解决ios移动端input调软键盘问题
let isIphone = navigator.userAgent.indexOf('iPhone') != -1
if (isIphone) {
FastClick.prototype.focus = function(targetElement) {
let length
if (
isIphone &&
targetElement.setSelectionRange &&
targetElement.type.indexOf('date') !== 0 &&
targetElement.type !== 'time' &&
targetElement.type !== 'month' &&
targetElement.type !== 'email'
) {
length = targetElement.value.length
targetElement.setSelectionRange(length, length)
/*修复bug ios 11.3不弹出键盘,这里加上聚焦代码,让其强制聚焦弹出键盘*/
targetElement.focus()
} else {
targetElement.focus()
}
}
}
//router or bridge jump
Vue.prototype.$jump = Jump
Vue.prototype.$utils = utils
//混合开发调试工具
// if (process.env.NODE_ENV == 'development') {
// // let Eruda = require('eruda')
// // Eruda.init()
// Vue.prototype.$rootUrl = location.origin
// } else if (process.env.NODE_ENV == 'production') {
// Vue.prototype.$rootUrl = location.origin + '/ebiz-h5'
// }
if (process.env.VUE_APP_FLAG != 'prd') {
let Eruda = require('eruda')
Eruda.init()
} else {
// Vue.prototype.$rootUrl = location.origin + '/ebiz-h5'
Vue.config.devtools = true
}
// let Eruda = require('eruda')
// Eruda.init()
// 注册过滤器
Object.keys(Filters).forEach(function(k) {
Vue.filter(k, Filters[k])
})
//权限控制
import { permission } from '@/assets/js/utils/permission'
permission()
//ios点击300毫秒时延
FastClick.attach(document.body)
// 监听input弹窗滚动到可视区域
window.addEventListener('resize', function () {
if (document.activeElement.tagName === 'INPUT' || document.activeElement.tagName === 'TEXTAREA') {
window.setTimeout(function () {
document.activeElement.scrollIntoViewIfNeeded()
}, 0)
}
})
Vue.config.productionTip = false
new Vue({
router,
store,
render: h => h(App)
}).$mount('#app')