131 lines
3.0 KiB
JavaScript
131 lines
3.0 KiB
JavaScript
import Vue from 'vue'
|
|
import App from './App'
|
|
import global from "./assets/script/global";
|
|
import store from "./store";
|
|
import schema from "async-validator";
|
|
import dialog from "./utils/dialog";
|
|
import mixin from '@/mixins/share-mixins.js'
|
|
import {_router, parseRoute} from "@/utils";
|
|
import {
|
|
SERVICE_API_URL,
|
|
SOCKET_URL,
|
|
STATIC_RESOURCE_URL,
|
|
VUE_APP_API_URL,
|
|
VUE_APP_RESOURCES_URL,
|
|
WX_LIVE_APPID
|
|
} from "@/config";
|
|
import uView from "uview-ui";
|
|
import GooSkeleton from '@/components/GooSkeleton/index.vue'
|
|
|
|
Vue.use(uView)
|
|
Vue.component('GooSkeleton', GooSkeleton)
|
|
Vue.mixin(mixin)
|
|
|
|
// 注册全局组件
|
|
|
|
Vue.config.productionTip = false;
|
|
Vue.config.devtools = process.env.NODE_ENV !== "production";
|
|
|
|
Vue.prototype.$SERVICE_API_URL = SERVICE_API_URL
|
|
Vue.prototype.$SOCKET_URL = SOCKET_URL
|
|
Vue.prototype.$VUE_APP_RESOURCES_URL = VUE_APP_RESOURCES_URL
|
|
Vue.prototype.$STATIC_RESOURCE_URL = STATIC_RESOURCE_URL
|
|
Vue.prototype.$VUE_APP_API_URL = VUE_APP_API_URL
|
|
Vue.prototype.$WX_LIVE_APPID = WX_LIVE_APPID
|
|
Vue.prototype.$global = global;
|
|
|
|
Vue.prototype.$validator = function (rule) {
|
|
return new schema(rule);
|
|
};
|
|
|
|
// const CACHE_KEY = "clear_0.0.1";
|
|
|
|
// if (!cookie.has(CACHE_KEY)) {
|
|
// cookie.clearAll();
|
|
// cookie.set(CACHE_KEY, 1);
|
|
// }
|
|
//强制转为几位小数,不足的补0
|
|
var forceToDecimal = function changeToDecimal(x, len, ignore = false) {
|
|
var f_x = parseFloat(x);
|
|
if (isNaN(f_x)) {
|
|
return 0;
|
|
}
|
|
var f = Math.round(f_x * 100) / 100;
|
|
if (ignore) {
|
|
f = Math.floor(f_x * 100) / 100;
|
|
}
|
|
var s = f.toString();
|
|
var rs = s.indexOf('.');
|
|
if (rs < 0) {
|
|
rs = s.length;
|
|
s += '.';
|
|
}
|
|
while (s.length <= rs + len) {
|
|
s += '0';
|
|
}
|
|
return s;
|
|
}
|
|
|
|
//强制转为2位小数,不足的补0
|
|
var force2Decimal = function change2Decimal(x, ignore = false) {
|
|
return forceToDecimal(x, 2, false);
|
|
}
|
|
|
|
Vue.prototype.$force2Decimal = force2Decimal
|
|
Vue.prototype.$forceToDecimal = forceToDecimal
|
|
|
|
Vue.config.productionTip = false
|
|
App.mpType = 'app'
|
|
Vue.prototype.$store = store
|
|
Vue.prototype.$dialog = dialog;
|
|
|
|
|
|
const app = new Vue(App)
|
|
|
|
Vue.mixin({
|
|
onLoad() {
|
|
const {
|
|
$mp
|
|
} = this.$root
|
|
this._route = parseRoute($mp)
|
|
this._data.$VUE_APP_RESOURCES_URL = VUE_APP_RESOURCES_URL;
|
|
},
|
|
onShow() {
|
|
_router.app = this
|
|
_router.currentRoute = this._route
|
|
}
|
|
})
|
|
|
|
Object.defineProperty(Vue.prototype, '$yrouter', {
|
|
get() {
|
|
return _router
|
|
}
|
|
})
|
|
|
|
Object.defineProperty(Vue.prototype, '$yroute', {
|
|
get() {
|
|
return this._route
|
|
}
|
|
})
|
|
|
|
// #ifdef H5
|
|
// H5编译的代码
|
|
Vue.prototype.$deviceType = 'h5'
|
|
store.commit('updateDevicetype', 'h5')
|
|
// #endif
|
|
|
|
// #ifdef APP-PLUS
|
|
// App平台编译的代码
|
|
Vue.prototype.$deviceType = 'app'
|
|
store.commit('updateDevicetype', 'app')
|
|
Vue.prototype.$platform = uni.getSystemInfoSync().platform
|
|
// #endif
|
|
|
|
// #ifdef MP-WEIXIN
|
|
// 微信小程序编译的代码
|
|
Vue.prototype.$deviceType = 'routine'
|
|
store.commit('updateDevicetype', 'routine')
|
|
// #endif
|
|
|
|
app.$mount()
|