main.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import Vue from 'vue'
  2. import App from '@/App'
  3. import $store from '@/store'
  4. import config from "./config.js"
  5. Vue.prototype.$config = config
  6. import uView from "uview-ui";
  7. Vue.use(uView);
  8. //全局引入iconpark图标
  9. // import { install } from '@icon-park/vue/es/all';
  10. // install(Vue, '');
  11. // Vue.use(VueRouter)
  12. //配置跳转小程序
  13. // Vue.config.ignoredElements = ['wx-open-launch-weapp'];
  14. //配置防止连点的公共方法
  15. import common from './common/util/clicks.js'
  16. Vue.prototype.$noMultipleClicks = common.noMultipleClicks;
  17. // 防连点方法
  18. Vue.directive('throttle', {
  19. inserted(el, binding) {
  20. el.addEventListener('click', () => {
  21. el.style.pointerEvents = 'none'
  22. if (!el.disabled) {
  23. setTimeout(() => {
  24. el.style.pointerEvents = 'auto'
  25. }, binding.value || 2000)
  26. }
  27. })
  28. }
  29. })
  30. Vue.prototype.$store = $store // vuex
  31. Vue.prototype.$offset = function(selector) { // 获取元素宽高位置信息
  32. return new Promise((resolve, reject) => {
  33. uni.createSelectorQuery().in(this).select(selector).boundingClientRect(data => {
  34. console.log(data,'data')
  35. data ? data.x = data.left + data.width / 2 : ''
  36. data ? data.y = data.top + data.height / 2 : ''
  37. data ? resolve(data) : reject('元素不存在')
  38. }).exec()
  39. })
  40. }
  41. Vue.prototype.$scrollViewHeight = function (className) { //设置页面内 scroll view 的高度
  42. this.$nextTick(() => { //在 mounted 以后获取到 className 的高度,赋给 scroll view
  43. const query = uni.createSelectorQuery().in(this)
  44. query.select(className).boundingClientRect()
  45. query.exec(res => this.scrollViewHeight = res[0].height)
  46. })
  47. }
  48. Vue.prototype.$hideLoading = function() { //异步操作结束,停止 loading
  49. this.$nextTick(() => {
  50. uni.hideLoading()
  51. })
  52. }
  53. Vue.prototype.$drawHonour = function(ctx, infoArr) { //绘制荣誉证书
  54. console.log('infoArr',infoArr)
  55. ctx.setTextAlign('center')
  56. ctx.setFontSize(infoArr[0][0])
  57. ctx.fillText(infoArr[0][1], infoArr[0][2], infoArr[0][3])
  58. ctx.setFontSize(infoArr[1][0])
  59. ctx.fillText(infoArr[1][1], infoArr[1][2], infoArr[1][3])
  60. ctx.setFontSize(infoArr[2][0])
  61. ctx.fillText(infoArr[2][1], infoArr[2][2], infoArr[2][3])
  62. ctx.draw()
  63. }
  64. import CustomNav from './components/public/custom-nav.vue' //自定义头部导航栏交互组件
  65. import pageToast from './components/toast.vue'
  66. import reachBot from './components/custom-reach-bottom.vue' //自定义滚动到底部提示
  67. Vue.component('custom-nav', CustomNav) //注册自定义头部导航栏
  68. Vue.component('page-toast', pageToast)
  69. Vue.component('custom-reach-bottom', reachBot) //注册自定义滚动到底部提示
  70. import * as filters from '@/filters'
  71. Object.keys(filters).forEach(e => {
  72. Vue.filter(e, filters[e])
  73. })
  74. App.mpType = 'app'
  75. Vue.config.productionTip = false;
  76. (new Vue({
  77. ...App
  78. })).$mount()