import Vue from 'vue'; import App from './App'; import uView from 'uview-ui'; Vue.use(uView); import { myRequest } from './util/api.js'; Vue.prototype.$myRequest = myRequest; Vue.config.productionTip = false; App.mpType = 'app'; import config from './util/neutral.js'; Vue.prototype.$imageHost = config.imageHost;// 线上图片服务器路径常量 58003 Vue.prototype.$imageURL = config.imageURL; console.log(Vue.prototype) import { QueryPermission } from './util/QueryPermission.js'; // Vue.use(QueryPermission) Vue.prototype.$QueryPermission = QueryPermission; import customCard from './components/customCard/customCard.vue'; Vue.component('customCard', customCard); Vue.filter('timeFormat', function (time,fmt = 'yyyy-MM-dd hh:mm:ss') { if(!time)return ''; function fun(a) { return String(a).length == 1 ? '0' + a : a; } let $this = new Date(time*1000); let 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(), }; 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.prototype.formatTime = function (thistime, fmt = 'yyyy-MM-dd hh:mm:ss') { let $this = new Date(thistime); let 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(), }; 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.mixin({ data() { return { $imageURL: Vue.prototype.$imageURL, $imageHost: Vue.prototype.$imageHost, // 其他需要混入的全局变量 shareTitle: '', sharePath: '', shareImage: '', timelineTitle: '', timelineQuery: '', timelineImage: '' }; }, onLoad() { // 开启分享功能 uni.showShareMenu({ withShareTicket: true, menus: ['shareAppMessage', 'shareTimeline'] }) }, onShareAppMessage() { return { title: this.shareTitle || '云飞智控', path: this.sharePath || '/pages/index/index', imageUrl: this.shareImage || '/static/logo.png' } }, onShareTimeline() { return { title: this.timelineTitle || '云飞智控', query: this.timelineQuery || '', imageUrl: this.timelineImage || '/static/logo.png' } }, // 如果需要,也可以在created中赋值,但上面这样直接赋值也可以,因为mixin的data会在每个组件创建时合并 // 但是注意,如果这些值在运行时改变,那么这种方式可能不会更新,因为data只初始化一次。如果需要在运行时响应变化,可以使用计算属性。 // 另一种方式是用计算属性: // computed: { // $imageURL() { // return Vue.prototype.$imageURL; // }, // $imageHost() { // return Vue.prototype.$imageHost; // } // } }); const app = new Vue({ ...App, }); app.$mount();