main.js 1.7 KB
import Vue from 'vue'
import App from './App'

import store from './store/index';
Vue.prototype.$store = store;

//配置
import config from './config.js'
Vue.prototype.$conf = config

Vue.prototype.$msg = (title, duration = 1500, mask = false, icon = 'none') => {
	//统一提示方便全局修改
	if (Boolean(title) === false) {
		return;
	}
	uni.showToast({
		title,
		duration,
		mask,
		icon
	});
}

Vue.prototype.$prePage = (len) => {
	let pages = getCurrentPages();
	let prePage = pages[pages.length - len];
	// #ifdef H5
	return prePage;
	// #endif
	return prePage.$vm;
}

Vue.directive('enterNumber', {
  inserted: function (el) {
    el.addEventListener("keypress",function(e){
      e = e || window.event;
      let charcode = typeof e.charCode == 'number' ? e.charCode : e.keyCode;
      let re = /\d/;
      if(!re.test(String.fromCharCode(charcode)) && charcode > 9 && !e.ctrlKey){
          if(e.preventDefault){
              e.preventDefault();
          }else{
              e.returnValue = false;
          }                            
      }
    });
  }
})

import http from './common/http/index.js'
Vue.prototype.$http = http

import {
  getDicts
} from "./common/http/dict";
Vue.prototype.getDicts = getDicts

import { formatTime, formatDate, selectDictLabel, selectCommonLabel, unique} from './common/util.js'
Vue.prototype.formatTime = formatTime
Vue.prototype.formatDate = formatDate
Vue.prototype.selectDictLabel = selectDictLabel
Vue.prototype.selectCommonLabel = selectCommonLabel
Vue.prototype.unique = unique

import uniIcons from "@/components/uni-icons/uni-icons.vue"
Vue.component('uniIcons', uniIcons)

Vue.config.productionTip = false

App.mpType = 'app'

const app = new Vue({
	...App
})
app.$mount()