12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- import Vue from 'vue'
- import App from './App'
- //引入 vuex 和 ajax 并将其关联
- import store from './store.js' //引入 vuex
- import ajax from './common/js/ajax.js' //引入 ajax 方法
- import common from './common/js/common.js'
- Vue.prototype.$noMultipleClicks = common.noMultipleClicks;
- Vue.prototype.$store = store //挂载 vuex
- Vue.prototype.$ajax = ajax(store) //挂在 ajax 执行后的 ajax 对象
- //在Vue 原型上挂载的一些方法
- Vue.prototype.$verified = function() { //判断用户是否已经验证的全局方法
- return store.state.userServerInfo.token ? true : false
- }
- Vue.prototype.$scrollViewHeight = function (className) { //设置页面内 scroll view 的高度
- this.$nextTick(() => { //在 mounted 以后获取到 className 的高度,赋给 scroll view
- const query = uni.createSelectorQuery().in(this)
- query.select(className).boundingClientRect()
- query.exec(res => this.scrollViewHeight = res[0].height)
- })
- }
- Vue.prototype.$hideLoading = function() { //异步操作结束,停止 loading
- this.$nextTick(() => {
- uni.hideLoading()
- })
- }
- Vue.prototype.$drawHonour = function(ctx, infoArr) { //绘制荣誉证书
- ctx.setTextAlign('center')
- ctx.setFontSize(infoArr[0][0])
- ctx.fillText(infoArr[0][1], infoArr[0][2], infoArr[0][3])
- ctx.setFontSize(infoArr[1][0])
- ctx.fillText(infoArr[1][1], infoArr[1][2], infoArr[1][3])
- ctx.setFontSize(infoArr[2][0])
- ctx.fillText(infoArr[2][1], infoArr[2][2], infoArr[2][3])
- ctx.draw()
- }
- //自定义的一些全局组件
- import nav from './components/custom-nav.vue' //自定义头部导航栏
- import toast from './components/custom-toast.vue' //自定义消息提示
- import counter from './components/custom-counter.vue' //自定义计数器
- import reachBot from './components/custom-reach-bottom.vue' //自定义滚动到底部提示
- import pageToast from './components/toast.vue'
- Vue.component('custom-nav', nav) //注册自定义头部导航栏
- Vue.component('custom-toast', toast) //注册自定义消息提示
- Vue.component('custom-counter', counter) //注册自定义计数器
- Vue.component('custom-reach-bottom', reachBot) //注册自定义滚动到底部提示
- Vue.component('page-toast', pageToast)
- import ToastConfirm from "@/components/toast-confirm.vue"
- Vue.component('toast-confirm', ToastConfirm)
- //将一些常用的方法定义在过滤器上
- import * as filters from './common/js/filters.js'
- Object.keys(filters).forEach(e => {
- Vue.filter(e, filters[e])
- })
- Vue.config.productionTip = false
- ;( new Vue( { ...App } ) ).$mount()
|