From c72c0e9baf776bcd884e9bbf11f82b2ae5d6dc16 Mon Sep 17 00:00:00 2001 From: GaoHao <1210693421@qq.com> Date: Mon, 20 Jan 2025 11:13:45 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=89=88=E6=9C=AC=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .hbuilderx/launch.json | 2 +- pages/index/index.vue | 21 +++++++++------------ store/common.js | 13 ++++++++++--- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/.hbuilderx/launch.json b/.hbuilderx/launch.json index a814c8a..576f2b0 100644 --- a/.hbuilderx/launch.json +++ b/.hbuilderx/launch.json @@ -2,7 +2,7 @@ "version" : "1.0", "configurations" : [ { - "playground" : "standard", + "playground" : "custom", "type" : "uni-app:app-android" }, { diff --git a/pages/index/index.vue b/pages/index/index.vue index ef67373..be3162e 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -94,7 +94,7 @@ } from '@/store/common.js' const $common = useCommonStore() onShow(() => { - console.log('cash:' + uni.getStorageSync('userInfo').userId + "" + new Date().getTime(), 'debug') + // console.log('cash:' + uni.getStorageSync('userInfo').userId + "" + new Date().getTime(), 'debug') // 判断ios是否审核 $common.init() let sysInfo = uni.getSystemInfoSync() @@ -123,6 +123,7 @@ content: "", confirmText: "", cancelText: "", + downloadLink: "" }, setindexdata :"false" }) @@ -157,7 +158,7 @@ //获取当前系统版本信息 plus.runtime.getProperty(plus.runtime.appid, widgetInfo => { //请求后台接口 解析数据 对比版本 - selectNewApp().then(res => { + selectNewApp().then( async res => { res = res[0]; let version; if (uni.getSystemInfoSync().platform == 'android') { @@ -165,14 +166,10 @@ } if (uni.getSystemInfoSync().platform == 'ios') { version = res.iosVersion - $common.setversion(widgetInfo.version, version) - } - version = res.version - // && uni.getSystemInfoSync().platform == 'android' - if (widgetInfo.version < version) { - let downloadLink = ''; - let androidLink = res.androidWgtUrl; - let iosLink = res.iosWgtUrl; + } + let isVersion = await $common.setversion(widgetInfo.version, version) + if ( isVersion == 1 ) { + datas.version.downloadLink = res.androidWgtUrl; datas.version.show = true; datas.version.title = "发现新版本"; datas.version.content = res.des; @@ -199,7 +196,7 @@ }); if (uni.getSystemInfoSync().platform == 'android') { uni.downloadFile({ - url: androidLink, + url: datas.version.downloadLink, success: downloadResult => { console.log(downloadResult) if (downloadResult.statusCode === 200) { @@ -222,7 +219,7 @@ }); } if (uni.getSystemInfoSync().platform == 'ios') { - plus.runtime.openURL(iosLink, function(res) {}); + plus.runtime.openURL(datas.version.downloadLink, function(res) {}); } } diff --git a/store/common.js b/store/common.js index 92279dc..cd70bab 100644 --- a/store/common.js +++ b/store/common.js @@ -68,10 +68,17 @@ export const useCommonStore = defineStore("common", { }, setversion(a, b) { // a是當前應用的版本號 b是接口拿的 - console.log('當前版本-' + appversion, '接口版本-' + resversion, '返回-' + this.isIosExamine, '判斷值-' + this - .isExamines) + // console.log('當前版本-' + appversion, '接口版本-' + resversion, '返回-' + this.isIosExamine, '判斷值-' + this + // .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) { From f67ff84af37c6d7468602b6fdf094b77898402fd Mon Sep 17 00:00:00 2001 From: GaoHao <1210693421@qq.com> Date: Mon, 20 Jan 2025 11:15:28 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E7=89=88=E6=9C=AC=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- store/common.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/store/common.js b/store/common.js index cd70bab..79e492d 100644 --- a/store/common.js +++ b/store/common.js @@ -67,15 +67,8 @@ export const useCommonStore = defineStore("common", { } }, setversion(a, b) { - // a是當前應用的版本號 b是接口拿的 - // console.log('當前版本-' + appversion, '接口版本-' + resversion, '返回-' + this.isIosExamine, '判斷值-' + this - // .isExamines) - // 再審核 return new Promise(async (resolve, reject) => { - // a是當前應用的版本號 b是接口拿的 - // console.log('當前版本-' + appversion, '接口版本-' + resversion, '返回-' + this.isIosExamine, '判斷值-' + this - // .isExamines) - // 再審核 + // console.log('當前版本-' + a, '接口版本-' + b, '判斷值-' + this.isExamines) this.isExamines = await this.compare(a, b) resolve(this.isExamines) })