This commit is contained in:
2025-04-02 10:35:17 +08:00
commit 89db955ec1
701 changed files with 91082 additions and 0 deletions

166
App.vue Normal file
View File

@@ -0,0 +1,166 @@
<!--
App.vue本身不是页面这里不能编写视图元素也就是没有<template>
-->
<script setup>
import {
ref,
reactive
} from 'vue';
import appConfig from '@/config/appConfig.js';
import {
onLaunch,onHide
} from '@dcloudio/uni-app';
import { getFindBySource } from '@/http/yskApi/version.js'
onHide(()=>{
})
onLaunch(() => {
uni.hideTabBar()
//#ifdef APP-PLUS
//获取当前系统版本信息
plus.runtime.getProperty(plus.runtime.appid, widgetInfo => {
//请求后台接口 解析数据 对比版本
console.log("widgetInfo==",widgetInfo)
getFindBySource({source:'点餐宝'}).then(res => {
console.log('res');
if (res.url && widgetInfo.version < res.version) {
let downloadLink = res.url;
console.log(downloadLink)
let ready = false;
// 校验是否强制升级
if (res.isUp == 1) {
uni.showModal({
showCancel: false,
title: '发现新版本',
confirmText: '立即更新',
content: res.message,
success: res => {
if (res.confirm) {
uni.showLoading({title:'下载中...'});
if (uni.getSystemInfoSync().platform ==
'android') {
uni.hideLoading()
uni.downloadFile({
url: downloadLink,
success: downloadResult => {
uni.hideLoading()
if (downloadResult.statusCode === 200) {
plus.io.resolveLocalFileSystemURL(downloadResult.tempFilePath, entry => {
entry.getParent(_oldFile=>{
entry.moveTo(_oldFile,'.apk',newFilePath=>{
console.log('newFilePath',newFilePath.fullPath)
plus.runtime
.install(newFilePath.fullPath, { force: false },
d => {
console
.log(
'install success...'
);
plus.runtime
.restart();
},
e => {
console.log(e)
console
.error(
'install fail...'
);
}
);
})
})
})
}
}
});
}
if (uni.getSystemInfoSync().platform ==
'ios') {
plus.runtime.openURL(downloadLink, function(
res) {});
}
} else if (res.cancel) {
console.log('取消');
}
}
});
} else {
uni.showModal({
title: '发现新版本',
confirmText: '立即更新',
cancelText: '下次更新',
content: res.message,
success: res => {
if (res.confirm) {
uni.showLoading({title:'下载中...'});
if (uni.getSystemInfoSync().platform ==
'android') {
uni.downloadFile({
url: downloadLink,
success: downloadResult => {
if (downloadResult
.statusCode ===
200) {
plus.io.resolveLocalFileSystemURL(downloadResult.tempFilePath, entry => {
entry.getParent(_oldFile=>{
entry.moveTo(_oldFile,'.apk',newFilePath=>{
console.log('newFilePath',newFilePath.fullPath)
plus.runtime
.install(newFilePath.fullPath, { force: false },
d => {
console
.log(
'install success...'
);
plus.runtime
.restart();
},
e => {
console.log(e)
console
.error(
'install fail...'
);
}
);
})
})
})
}
}
});
}
if (uni.getSystemInfoSync().platform ==
'ios') {
plus.runtime.openURL(downloadLink, function(
res) {});
}
} else if (res.cancel) {
uni.hideLoading()
console.log('取消');
}
}
});
}
}
}).catch((res)=>{
console.log(res)
})
});
// #endif
});
</script>
<style lang="scss">
/** 每个页面公共css */
@import '@/commons/style/common.scss';
@import '@/commons/style/ipad.scss';
/** uni 组件样式覆盖 */
@import '@/commons/style/uni-overwrite.scss';
@import "uview-plus/index.scss";
</style>