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 '@/uni_modules/uview-ui' Vue.use(uView); Vue.mixin(mixin) uni.$u.setConfig({ // 修改$u.config对象的属性 config: { // 修改默认单位为rpx,相当于执行 uni.$u.config.unit = 'rpx' unit: 'rpx' }, // 修改$u.props对象的属性 props: { // 修改radio组件的size参数的默认值,相当于执行 uni.$u.props.radio.size = 30 radio: { size: 30, labelSize: 30, iconSize: 25 }, icon: { size: 40, fontSize: 30 }, picker: { fontSize: 30 }, button: { fontSize: 30, iconSize: 30 }, navbar: { leftIconSize: 40, titleStyle: { fontSize: '30rpx' } }, tabbar: { size: 30 }, tabs: { lineWidth: 40 }, search: { searchIconSize: 40 }, codeInput: { size: 60 }, calendar: { rowHeight: 112 }, empty: { textSize: 28 }, checkbox: { fontSize: 30, size: 30, labelSize: 24, iconSize: 30 } // 其他组件属性配置 // ...... } }) // 注册全局组件 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()