import Vue from 'vue' import App from './App' import Mixin from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js' import common from '@/common/common.js' import { gotopage } from '@/common/gotopage.js' import RequestManager from '@/common/request.js' import ConfigManager from '@/common/config.js' // 基础配置 const baseUrl = 'https://manghe.zpc-xy.com' const imageUrl = 'https://mh.shhuanmeng.com' const loginPage = "https://xinglanmh.shequtuangou.vip/login.html" // 全局变量配置 Vue.prototype.siteBaseUrl = baseUrl + '/api/' Vue.prototype.$baseUrl = baseUrl Vue.prototype.$z_img2 = imageUrl + '/zcq/' Vue.prototype.$img = url => imageUrl + '/static/web' + url Vue.prototype.$img1 = url => imageUrl + '/static/web/static/' + url Vue.prototype.$sys = () => uni.getSystemInfoSync() Vue.prototype.$loginPage = loginPage Vue.prototype.$wxloginPage = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx0e33d80d35e4a3b1&redirect_uri=${escape(loginPage)}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect` // 公共方法 Vue.prototype.gotoPage = gotopage Vue.prototype.$noMultipleClicks = common.noMultipleClicks Vue.prototype.$c = common // 全局请求方法 Vue.prototype.req = RequestManager.request Vue.prototype.$request = RequestManager // 全局配置管理器 Vue.prototype.$config = ConfigManager // #ifdef H5 function loadScript(url) { var script = document.createElement('script') script.type = 'text/javascript' script.src = url document.head.appendChild(script) } loadScript('https://res.wx.qq.com/open/js/jweixin-1.6.0.js') // #endif // #ifdef MP-WEIXIN const updateManager = wx.getUpdateManager() updateManager.onCheckForUpdate(function(res) { console.log(res.hasUpdate) }) updateManager.onUpdateReady(function() { wx.showModal({ title: '更新提示', content: '新版本已经准备好,是否重启应用?', success(res) { if (res.confirm) { updateManager.applyUpdate() } } }) }) updateManager.onUpdateFailed(function() { // 新版本下载失败 }) // #endif Vue.config.productionTip = false Vue.mixin(Mixin) App.mpType = 'app' const app = new Vue({ ...App }) // 创建全局数据对象 app.globalData = { siteBaseUrl: baseUrl + '/api/' } // 应用启动时加载全局配置 ConfigManager.init().then(config => { console.log('全局配置加载完成') }).catch(err => { console.error('全局配置加载失败', err) }) app.$mount()