import Vue from 'vue' import store from './store' import App from './App' import * as Api from '@/common/config/caimeiApi.js' import * as Regs from '@/common/config/common.js' import Json from './json' //本地数据 /** * 示例使用了uni.scss下的变量, 除变量外已尽量移除特有语法,可直接替换为其他预处理器使用 */ const msg = (title, duration=1500, mask=true, icon='none')=>{ //统一提示方便全局修改 if(Boolean(title) === false){return;} uni.showToast({ title, duration, mask, icon }); } const modal = (title,content,confirmText,cancelText,showCancel=false,callBack) =>{ uni.showModal({ title, content, confirmText, cancelText, confirmColor:'#E15616', showCancel, success: function (res) { if (res.confirm) { callBack() } } }); } const json = type=>{ //模拟异步请求数据 return new Promise(resolve=>{ setTimeout(()=>{ // console.log(resolve+'======='+type); resolve(Json[type]); }, 500) }) } const prePage = ()=>{ let pages = getCurrentPages(); let prePage = pages[pages.length - 2]; // #ifdef H5 return prePage; // #endif return prePage.$vm; } Vue.config.productionTip = false Vue.prototype.$fire = new Vue(); Vue.prototype.$store = store; Vue.prototype.$util = {msg, json, prePage,modal}; Vue.prototype.$api = Api; Vue.prototype.$reg = Regs; App.mpType = 'app' const app = new Vue({ ...App }) app.$mount()