3f535f30
杨鑫
'初始'
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import store from './store'
// import '@/config/rem' // 配置flex
import 'normalize.css' // 重置样式表
// import '@/styles/element-ui-style.css' // 重置样式表
import ElementUI from 'element-ui'
import './../theme/index.css'
import qs from 'qs'
import SvgIcon from '@/components/Icon/SvgIcon.vue' // svg组件
// 注册到全局
Vue.component('icon-svg', SvgIcon)
const requireAll = requireContext => requireContext.keys().map(requireContext)
const req = require.context('./assets/svg', false, /\.svg$/)
requireAll(req)
const activityIcon = require.context('./assets/svg/activity', false, /\.svg$/)
requireAll(activityIcon)
const orderDetailIcon = require.context('./assets/svg/order-detail', false, /\.svg$/)
requireAll(orderDetailIcon)
Vue.use(ElementUI)
Vue.prototype.$message = ElementUI.Message
Vue.prototype.$qs = qs
// 阻止启动生产消息
Vue.config.productionTip = false
Vue.filter('money', function (value) {
if (!value) return '0.00'
var val = value.toFixed(2)
var intPart = Number(val).toFixed(0)
var intPartFormat = intPart.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,')
var floatPart = '.00'
val = value.toString()
var value2Array = value.split('.')
if (value2Array.length === 2) {
floatPart = value2Array[1].toString()
if (floatPart.length === 1) {
return intPartFormat + '.' + floatPart + '0'
} else {
return intPartFormat + '.' + floatPart
}
} else {
return intPartFormat + floatPart
}
})
// 防止连点
Vue.directive('throttle', {
inserted (el, binding) {
el.addEventListener('click', () => {
el.style.pointerEvents = 'none'
if (!el.disabled) {
setTimeout(() => {
el.style.pointerEvents = 'auto'
}, binding.value || 2000)
}
})
}
})
Vue.prototype.openLoading = function () {
const loading = this.$loading({ // 声明一个loading对象
lock: true, // 是否锁屏
target: '.sub-main', // 需要遮罩的区域
body: true,
background: '#ffffff',
customClass: 'mask' // 遮罩层新增类名
})
setTimeout(function () { // 设定定时器,超时5S后自动关闭遮罩层,避免请求失败时,遮罩层一直存在的问题
loading.close() // 关闭遮罩层
}, 5000)
return loading
}
router.afterEach((to, from, next) => {
window.scrollTo(0, 0)
})
/* eslint-disable no-new */
new Vue({
el: '#app',
router,
store,
components: { App },
template: '<App/>'
})
|