代码如下
getVes() {
// #ifdef APP-PLUS
uni.getSystemInfo({
success: response => {
plus.runtime.getProperty(plus.runtime.appid, wgtinfo => {
//调用后台最新版本接口
appVersion({ appName: 'AI_FUER', brand: response.brand, versionNum: wgtinfo.version }).then(res => {
if (res.updateResult.needUpdate == 'Y') { //判断是否需要强制更新(修改功能等大改动)
let content = 'AI妇儿已发布新版本,当前版本' + wgtinfo.version + ',前往更新';
if (res.updateResult.mandatoryUpdate == 'Y') { //判断是否弹出更新提示框
uni.showModal({
title: '确认更新',
content: content,
showCancel: false,
success: resp => {
if (resp.confirm) {
//跳转更新地址
plus.runtime.openURL(res.updateResult.appUrl);
if (uni.getSystemInfoSync().platform == 'ios') {
//关闭当前APP,下次启动再次检测是否需要更新
plus.ios
.import('UIApplication')
.sharedApplication()
.performSelector('exit');
} else if (uni.getSystemInfoSync().platform == 'android') {
//关闭当前APP,下次启动再次检测是否需要更新
plus.runtime.quit();
}
}
}
});
} else {
//非强制更新(更新的小东西,可以不更新)
uni.showModal({
title: '确认更新',
content: content,
success: resp => {
if (resp.confirm) {
//跳转更新地址
plus.runtime.openURL(res.updateResult.appUrl);
} else if (resp.cancel) {
console.log('用户点击取消');
}
}
});
}
}
});
});
}
});
// #endif
}
getVes() {
// #ifdef APP-PLUS