alipay-emulator/main.js

96 lines
2.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import App from './App'
import globalMethods from '@/utils/globalMethods.js';
import pageData from "@/static/json/page.json"
// #ifndef VUE3
import Vue from 'vue'
import './uni.promisify.adaptor'
Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({
...App
})
app.$mount()
// #endif
// #ifdef VUE3
import {
createSSRApp
} from 'vue'
export function createApp() {
const app = createSSRApp(App)
// 从缓存读取系统信息已在App.vue中获取
app.config.globalProperties.$pageData = pageData
let systemInfo = uni.getStorageSync('systemInfo') || {}
if (!systemInfo.platform) {
systemInfo = uni.getSystemInfoSync() || {}
}
const windowInfo = uni.getWindowInfo();
app.config.globalProperties.$store = {
state: {
safeBottom: windowInfo.safeAreaInsets?.bottom || 0,
safeBottomAz: 0
}
}
app.config.globalProperties.$system = systemInfo.platform == 'ios' ? 'iOS' : 'Android'
// #ifdef APP-PLUS&&!APP-HARMONY
app.config.globalProperties.$system = plus.os.name;
// #endif
app.config.globalProperties.$systemInfo = systemInfo;
uni.setStorageSync('version', '1.0.7.sp6');
app.config.globalProperties.$version = uni.getStorageSync('version');
// 环境development→测试production→正式跟构建环境走无需手改
const isTest = process.env.NODE_ENV === 'development';
app.config.globalProperties.$isTest = isTest;
// #ifdef APP-PLUS&&!APP-HARMONY
const version = plus.runtime.version;
// #endif
const compareVersion = (v1, v2) => {
const a = String(v1).split('.')
const b = String(v2).split('.')
const len = Math.max(a.length, b.length)
for (let i = 0; i < len; i++) {
const n1 = parseInt(a[i] || '0', 10)
const n2 = parseInt(b[i] || '0', 10)
if (n1 > n2) return 1
if (n1 < n2) return -1
}
return 0
}
//安卓和ios
// #ifdef APP-PLUS && !APP-HARMONY
if (plus.os.name == 'iOS') {
if (compareVersion(version, '1.9') >= 0 && !isTest) {
uni.setStorageSync('isTest', false)
} else {
uni.setStorageSync('isTest', true)
}
} else {
if (compareVersion(version, '2.2.0') >= 0 && !isTest) {
uni.setStorageSync('isTest', false)
} else {
uni.setStorageSync('isTest', true)
}
}
// #endif
//鸿蒙
// #ifdef APP-PLUS && APP-HARMONY
if (compareVersion(version, '2.1.7') >= 0&&!isTest) {
uni.setStorageSync('isTest', false)
} else {
uni.setStorageSync('isTest', true)
}
// #endif
//h5环境
// #ifndef APP-PLUS
uni.setStorageSync('isTest', true)
// #endif
app.use(globalMethods);
return {
app
}
}
// #endif