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