|
@ -1,7 +1,7 @@ |
|
|
import { |
|
|
import { |
|
|
appCheckUpdate |
|
|
appCheckUpdate |
|
|
} from '../api/request2.js'; |
|
|
} from '../api/request2.js'; |
|
|
export function appUpdate() { |
|
|
export function appUpdate(isShowHint) { |
|
|
let curversion = 0; |
|
|
let curversion = 0; |
|
|
plus.runtime.getProperty(plus.runtime.appid, function(widgetInfo) { |
|
|
plus.runtime.getProperty(plus.runtime.appid, function(widgetInfo) { |
|
|
const data = { |
|
|
const data = { |
|
@ -11,44 +11,77 @@ export function appUpdate() { |
|
|
wgtVersion: widgetInfo.version, |
|
|
wgtVersion: widgetInfo.version, |
|
|
versionCode: widgetInfo.versionCode |
|
|
versionCode: widgetInfo.versionCode |
|
|
} |
|
|
} |
|
|
curversion=data.versionCode |
|
|
curversion = data.versionCode |
|
|
appCheckUpdate().then(res => { |
|
|
appCheckUpdate().then(res => { |
|
|
console.log("当前版本提示",curversion) |
|
|
console.log("当前版本提示", curversion) |
|
|
if (res.data) { |
|
|
var json = JSON.stringify(res) |
|
|
if (res.data.versionCode > Number(curversion)) { |
|
|
console.log("获取更新数据", json) |
|
|
var downUrl = res.data.downUrl; |
|
|
if (res.data) { |
|
|
var content = res.data.content; |
|
|
if (res.data.installPackageVersion > Number(curversion)) { |
|
|
var version =res.data.version |
|
|
var downUrl = res.data.downUrl; |
|
|
console.log("新版本提示") |
|
|
var content = res.data.updateContent; |
|
|
uni.showModal({ |
|
|
var version = res.data.installPackageVersion; |
|
|
title: "发现新版本:("+version+")", |
|
|
var isForcedUpdate = res.data.isForcedUpdate |
|
|
content: content, |
|
|
var versionName =res.data.installPackageName |
|
|
confirmText: "更新", |
|
|
console.log("新版本提示") |
|
|
cancelText: "取消", |
|
|
showDialog(versionName, content, isForcedUpdate, downUrl) |
|
|
success: (res) => { |
|
|
|
|
|
if (res.confirm) { |
|
|
// uni.showModal({
|
|
|
confirm(downUrl); |
|
|
// title: "发现新版本:(" + version + ")",
|
|
|
console.log('comfirm') //点击确定之后执行的代码
|
|
|
// content: content,
|
|
|
} else { |
|
|
// confirmText: "更新",
|
|
|
console.log('cancel') //点击取消之后执行的代码
|
|
|
// showCancel: isForcedUpdate == "TRUE" ? false : true,
|
|
|
} |
|
|
// cancelText: "取消",
|
|
|
|
|
|
// success: (res) => {
|
|
|
|
|
|
// if (res.confirm) {
|
|
|
|
|
|
// confirm(downUrl);
|
|
|
|
|
|
// console.log('comfirm') //点击确定之后执行的代码
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
// console.log('cancel') //点击取消之后执行的代码
|
|
|
|
|
|
// if (isForcedUpdate == "TRUE") {
|
|
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// })
|
|
|
|
|
|
} else { |
|
|
|
|
|
if(isShowHint){ |
|
|
|
|
|
uni.showToast({ |
|
|
|
|
|
title: "当前是最新版本" |
|
|
|
|
|
}) |
|
|
} |
|
|
} |
|
|
}) |
|
|
|
|
|
} else { |
|
|
|
|
|
uni.showToast({ |
|
|
|
|
|
title:"当前是最新版本" |
|
|
|
|
|
}) |
|
|
|
|
|
console.log("没有新版本") |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}).catch(error => { |
|
|
|
|
|
console.log("版本错误", error) |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
console.log("没有新版本") |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}).catch(error => { |
|
|
|
|
|
console.log("版本错误", error) |
|
|
|
|
|
}) |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export function showDialog(versionName, content, isForcedUpdate, downUrl) { |
|
|
|
|
|
uni.showModal({ |
|
|
|
|
|
title: "发现新版本:(" + versionName + ")", |
|
|
|
|
|
content: content, |
|
|
|
|
|
confirmText: "更新", |
|
|
|
|
|
showCancel: isForcedUpdate == "TRUE" ? false : true, |
|
|
|
|
|
cancelText: "取消", |
|
|
|
|
|
success: (res) => { |
|
|
|
|
|
if (res.confirm) { |
|
|
|
|
|
confirm(downUrl); |
|
|
|
|
|
console.log( |
|
|
|
|
|
'comfirm') //点击确定之后执行的代码
|
|
|
|
|
|
} else { |
|
|
|
|
|
console.log( |
|
|
|
|
|
'cancel') //点击取消之后执行的代码
|
|
|
|
|
|
if (isForcedUpdate == "TRUE") { |
|
|
|
|
|
showDialog(version, content, isForcedUpdate, downUrl) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
export function confirm(downUrl) { |
|
|
export function confirm(downUrl) { |
|
|