import App from './App' // #ifndef VUE3 import Vue from 'vue' import uView from '@/uni_modules/uview-ui' Vue.use(uView) import fly from '@/common/bin/fly' Vue.prototype.$fly = fly import apis from '@/common/api/index.js' Vue.prototype.$apis = apis const dayjs = require('@/common/bin/dayjs.min.js'); Vue.prototype.$dayjs = dayjs // 全局简写跳转 Vue.prototype.$navTo = function(path){ uni.navigateTo({ url:path }) } Vue.prototype.$navBack = function(delta){ if(typeof delta != 'number') delta = 1 uni.navigateBack({ delta:delta }) } Vue.prototype.$toast = (val, callback) => { uni.showToast({ icon: 'none', mask: true, title: val, duration: 1200 }) if (callback) setTimeout(callback, 1300) } Vue.prototype.$loading = (val = "") => { uni.showLoading({ title: val, mask: true, }) } // 底部导航栏 Vue.prototype.$TabBar = { list:[{ pagePath:'/pages/index/index/index', text:'饮水', iconPath:"/static/icon/tabBar/icon_tabbar_index.png", selectedIconPath:"/static/icon/tabBar/icon_tabbar_index_active.png", },{ pagePath:'/pages/user/index/index', text:'我的', iconPath:"/static/icon/tabBar/icon_tabbar_user.png", selectedIconPath:"/static/icon/tabBar/icon_tabbar_user_active.png", }], current:0, } // 时间格式化 Date.prototype.Format = function(fmt) { const DAY = ['日', '一', '二', '三', '四', '五', '六'] var o = { "M+": this.getMonth() + 1, //月份 "d+": this.getDate(), //日 "H+": this.getHours(), //小时 "m+": this.getMinutes(), //分 "s+": this.getSeconds(), //秒 "q+": Math.floor((this.getMonth() + 3) / 3), //季度 "S": this.getMilliseconds(), //毫秒 "D": DAY[this.getDay()] }; if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)); for (var k in o) if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); return fmt; } Vue.filter('getTime',val=>{ return new Date(val).Format('yyyy-MM-dd HH:mm:ss') }) Vue.filter('getTimeMin',val=>{ return new Date(val).Format('yyyy-MM-dd') }) Vue.filter('hidePhoneMiddle',(phone)=>{ // 先验证是否为11位数字 if (/^\d{11}$/.test(phone)) { return phone.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2'); } return phone; // 如果不是11位数字,返回原值 }) import store from './store' Vue.prototype.$store = store import './uni.promisify.adaptor' Vue.config.productionTip = false App.mpType = 'app' const app = new Vue({ store, ...App }) app.$mount() // #endif // #ifdef VUE3 import { createSSRApp } from 'vue' export function createApp() { const app = createSSRApp(App) return { app } } // #endif