import Vue from 'vue' import App from './App' import * as Api from './config/api.js' import * as Common from './config/common.js' import * as Db from './config/db.js' import * as Config from './config/config.js' import share from "@/common/share.js" import store from './store'; import util from "@/common/util.js" const logic = { systemInfo: null, /** * 显示消息提示 * * @param {Object} text * @param {Object} icon */ showToast(text, icon) { return uni.showToast({ title: text || '加载中', icon: icon || 'none', mask: true, duration: 2000 }); }, /** * 全局方法 - px2rpx * * @param {Object} px */ px2rpx(px) { if (this.systemInfo === null) { this.systemInfo = uni.getSystemInfoSync() } // 官方规定屏幕宽为750rpx return px / this.systemInfo.windowWidth * 750; }, /** * 全局方法 - rpx2px * * @param {Object} rpx */ rpx2px(rpx) { if (this.systemInfo === null) { this.systemInfo = uni.getSystemInfoSync() } // 官方规定屏幕宽为750rpx return rpx / 750 * this.systemInfo.windowWidth; }, } // import { // createSSRApp // } from 'vue' // export function createApp() { // const app = createSSRApp(App) // app.use(store) // app.config.globalProperties.$logic = logic // return { // app // } // } function isPromise(obj) { return (!!obj && (typeof obj === "object" || typeof obj === "function") && typeof obj.then === "function" ); } // uni方法转then数组 uni.addInterceptor({ returnValue(res) { if (!isPromise(res)) { return res; } const returnValue = [undefined, undefined]; return res .then((res) => { returnValue[1] = res; }) .catch((err) => { returnValue[0] = err; }) .then(() => returnValue); }, }); import { tools } from '@/common/fa.mixin.js' Vue.mixin(tools) //皮肤色处理 let styleMixin = require('@/common/fa.style.mixin.js') Vue.mixin(styleMixin) import uView from '@/uni_modules/uview-ui' Vue.use(uView) Vue.prototype.$api = Api; Vue.prototype.$common = Common; Vue.prototype.$db = Db; Vue.prototype.$config = Config; Vue.prototype.$logic = logic; Vue.prototype.$util = util; Vue.prototype.vuex_token = ''; Vue.prototype.user = {}; Vue.prototype.vuex_theme = { value: { color: "#fff", bgColor: "#c7a772" } } Vue.prototype.vuex_parse_style = { h1: 'padding:20rpx 0;', h2: 'padding:10rpx 0;', h3: 'padding:10rpx 0;', h4: 'padding:10rpx 0;', h5: 'padding:5rpx 0;', h6: 'padding:5rpx 0;', ul: 'margin-bottom:20rpx;padding-left:30rpx;', ol: 'margin-bottom:20rpx;padding-left:30rpx;', code: 'background-color: #f6f6f6;margin: 0 5rpx;padding: 6rpx 8rpx;border-radius: 6rpx;text-align:center;', pre: 'white-space: pre;overflow: auto;background: #f6f6f6;border-radius: 8rpx;border: none;color: #1a1a1a;margin-bottom: 20rpx;padding:20rpx;', 'pre code': 'margin:0;padding:0;', blockquote: 'padding: 15rpx;margin:0 0 20rpx 0;border-radius: 6rpx;', p: 'margin-bottom:20rpx', table: 'width:100%;margin-bottom:20rpx;border-collapse: collapse;', th: 'background-color: whitesmoke;border: 1px solid #e6e6e6;padding:10rpx;', td: 'border: 1px solid #e6e6e6;padding:10rpx;' } Vue.prototype.vuex_config = {} Vue.config.productionTip = false Vue.mixin(share) App.mpType = 'app' const app = new Vue({ ...App, store }) app.$mount()