88 lines
2.3 KiB
JavaScript
88 lines
2.3 KiB
JavaScript
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 ConfigManager from '@/common/config.js'
|
|
import RequestManager from '@/common/request.js'
|
|
import EnvConfig from '@/common/env.js'
|
|
|
|
// 全局注册uni-popup组件
|
|
import uniPopup from '@/uni_modules/uni-popup/components/uni-popup/uni-popup.vue'
|
|
Vue.component('uni-popup', uniPopup)
|
|
|
|
// 全局变量配置
|
|
Vue.prototype.siteBaseUrl = EnvConfig.apiBaseUrl
|
|
Vue.prototype.$baseUrl = EnvConfig.baseUrl
|
|
Vue.prototype.$z_img2 = EnvConfig.imageUrl + '/zcq/'
|
|
Vue.prototype.$img = url => EnvConfig.imageBaseUrl + url
|
|
Vue.prototype.$img1 = url => EnvConfig.iconBaseUrl + url
|
|
Vue.prototype.$sys = () => uni.getSystemInfoSync()
|
|
Vue.prototype.$loginPage = EnvConfig.loginPage
|
|
Vue.prototype.$wxloginPage = EnvConfig.wxLoginUrl
|
|
|
|
// 公共方法
|
|
Vue.prototype.gotoPage = gotopage
|
|
Vue.prototype.$noMultipleClicks = common.noMultipleClicks
|
|
Vue.prototype.$c = common
|
|
// 全局配置管理器
|
|
Vue.prototype.$config = ConfigManager
|
|
// 全局请求方法
|
|
Vue.prototype.req = RequestManager.request
|
|
Vue.prototype.$request = RequestManager
|
|
|
|
// #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: EnvConfig.apiBaseUrl
|
|
}
|
|
|
|
// 应用启动时加载全局配置
|
|
ConfigManager.init().then(config => {
|
|
console.log('全局配置加载完成')
|
|
}).catch(err => {
|
|
console.error('全局配置加载失败', err)
|
|
})
|
|
|
|
app.$mount() |