版本更新优化

This commit is contained in:
GaoHao
2025-01-20 11:13:45 +08:00
parent c05ee20821
commit c72c0e9baf
3 changed files with 20 additions and 16 deletions

View File

@@ -2,7 +2,7 @@
"version" : "1.0", "version" : "1.0",
"configurations" : [ "configurations" : [
{ {
"playground" : "standard", "playground" : "custom",
"type" : "uni-app:app-android" "type" : "uni-app:app-android"
}, },
{ {

View File

@@ -94,7 +94,7 @@
} from '@/store/common.js' } from '@/store/common.js'
const $common = useCommonStore() const $common = useCommonStore()
onShow(() => { onShow(() => {
console.log('cash:' + uni.getStorageSync('userInfo').userId + "" + new Date().getTime(), 'debug') // console.log('cash:' + uni.getStorageSync('userInfo').userId + "" + new Date().getTime(), 'debug')
// 判断ios是否审核 // 判断ios是否审核
$common.init() $common.init()
let sysInfo = uni.getSystemInfoSync() let sysInfo = uni.getSystemInfoSync()
@@ -123,6 +123,7 @@
content: "", content: "",
confirmText: "", confirmText: "",
cancelText: "", cancelText: "",
downloadLink: ""
}, },
setindexdata :"false" setindexdata :"false"
}) })
@@ -157,7 +158,7 @@
//获取当前系统版本信息 //获取当前系统版本信息
plus.runtime.getProperty(plus.runtime.appid, widgetInfo => { plus.runtime.getProperty(plus.runtime.appid, widgetInfo => {
//请求后台接口 解析数据 对比版本 //请求后台接口 解析数据 对比版本
selectNewApp().then(res => { selectNewApp().then( async res => {
res = res[0]; res = res[0];
let version; let version;
if (uni.getSystemInfoSync().platform == 'android') { if (uni.getSystemInfoSync().platform == 'android') {
@@ -165,14 +166,10 @@
} }
if (uni.getSystemInfoSync().platform == 'ios') { if (uni.getSystemInfoSync().platform == 'ios') {
version = res.iosVersion version = res.iosVersion
$common.setversion(widgetInfo.version, version) }
} let isVersion = await $common.setversion(widgetInfo.version, version)
version = res.version if ( isVersion == 1 ) {
// && uni.getSystemInfoSync().platform == 'android' datas.version.downloadLink = res.androidWgtUrl;
if (widgetInfo.version < version) {
let downloadLink = '';
let androidLink = res.androidWgtUrl;
let iosLink = res.iosWgtUrl;
datas.version.show = true; datas.version.show = true;
datas.version.title = "发现新版本"; datas.version.title = "发现新版本";
datas.version.content = res.des; datas.version.content = res.des;
@@ -199,7 +196,7 @@
}); });
if (uni.getSystemInfoSync().platform == 'android') { if (uni.getSystemInfoSync().platform == 'android') {
uni.downloadFile({ uni.downloadFile({
url: androidLink, url: datas.version.downloadLink,
success: downloadResult => { success: downloadResult => {
console.log(downloadResult) console.log(downloadResult)
if (downloadResult.statusCode === 200) { if (downloadResult.statusCode === 200) {
@@ -222,7 +219,7 @@
}); });
} }
if (uni.getSystemInfoSync().platform == 'ios') { if (uni.getSystemInfoSync().platform == 'ios') {
plus.runtime.openURL(iosLink, function(res) {}); plus.runtime.openURL(datas.version.downloadLink, function(res) {});
} }
} }

View File

@@ -68,10 +68,17 @@ export const useCommonStore = defineStore("common", {
}, },
setversion(a, b) { setversion(a, b) {
// a是當前應用的版本號 b是接口拿的 // a是當前應用的版本號 b是接口拿的
console.log('當前版本-' + appversion, '接口版本-' + resversion, '返回-' + this.isIosExamine, '判斷值-' + this // console.log('當前版本-' + appversion, '接口版本-' + resversion, '返回-' + this.isIosExamine, '判斷值-' + this
.isExamines) // .isExamines)
// 再審核 // 再審核
this.isExamines = this.compare(a, b) return new Promise(async (resolve, reject) => {
// a是當前應用的版本號 b是接口拿的
// console.log('當前版本-' + appversion, '接口版本-' + resversion, '返回-' + this.isIosExamine, '判斷值-' + this
// .isExamines)
// 再審核
this.isExamines = await this.compare(a, b)
resolve(this.isExamines)
})
}, },
// 判断版本号 // 判断版本号
compare(version1, version2) { compare(version1, version2) {