|
|
@@ -182,68 +182,90 @@
|
|
|
// }
|
|
|
// })
|
|
|
|
|
|
- // #ifdef APP-PLUS
|
|
|
- getLatestVersion().then(res => {
|
|
|
- const {
|
|
|
- appVersion
|
|
|
- } = uni.getAppBaseInfo()
|
|
|
- if (appVersion != res.versionCode) {
|
|
|
- uni.showModal({
|
|
|
- title: '发现新版本',
|
|
|
- content: '更新说明:' + res.releaseNotes,
|
|
|
- confirmText: '立即更新',
|
|
|
- success: (val) => {
|
|
|
- if (val.confirm) {
|
|
|
- uni.showLoading({
|
|
|
- title: "正在下载安装包...",
|
|
|
- mask: true,
|
|
|
- });
|
|
|
- uni.downloadFile({
|
|
|
- url: `${Vue.prototype.webviewUrl}/kd-aiot/${res.fileStorePath}`,
|
|
|
- success: (data) => {
|
|
|
- if (data.statusCode === 200) {
|
|
|
- uni.saveFile({
|
|
|
- tempFilePath: data
|
|
|
- .tempFilePath,
|
|
|
- success: (saveRes) => {
|
|
|
- uni.showToast({
|
|
|
- title: '下载成功',
|
|
|
- icon: 'success'
|
|
|
- });
|
|
|
- uni.hideLoading();
|
|
|
- uni.showLoading({
|
|
|
- title: "正在更新...",
|
|
|
- mask: true,
|
|
|
- });
|
|
|
- // 调用安装逻辑
|
|
|
- plus.runtime.install(
|
|
|
- saveRes
|
|
|
- .savedFilePath, {
|
|
|
- force: true
|
|
|
- },
|
|
|
- function() {
|
|
|
- uni
|
|
|
- .hideLoading();
|
|
|
- },
|
|
|
- function() {
|
|
|
- uni
|
|
|
- .hideLoading();
|
|
|
- uni.showToast({
|
|
|
- title: '更新失败',
|
|
|
- icon: 'error'
|
|
|
- });
|
|
|
+ // #ifdef APP-PLUS
|
|
|
+ getLatestVersion().then(res => {
|
|
|
+ console.log('res:', res)
|
|
|
+ const {
|
|
|
+ appVersion
|
|
|
+ } = uni.getAppBaseInfo()
|
|
|
+ if (appVersion != res.versionCode) {
|
|
|
+ uni.showModal({
|
|
|
+ title: '发现新版本',
|
|
|
+ content: '更新说明:' + res.releaseNotes,
|
|
|
+ confirmText: '立即更新',
|
|
|
+ success: (val) => {
|
|
|
+ if (val.confirm) {
|
|
|
+ // uni.showLoading({
|
|
|
+ // title: "正在下载安装包...",
|
|
|
+ // mask: true,
|
|
|
+ // });
|
|
|
+ const downloadTask = uni.downloadFile({
|
|
|
+ url: `${Vue.prototype.webviewUrl}/kd-aiot/${res.fileStorePath}`,
|
|
|
+ success: (data) => {
|
|
|
+ if (data.statusCode === 200) {
|
|
|
+ uni.saveFile({
|
|
|
+ tempFilePath: data
|
|
|
+ .tempFilePath,
|
|
|
+ success: (saveRes) => {
|
|
|
+ // uni.showToast({
|
|
|
+ // title: '下载成功',
|
|
|
+ // icon: 'success'
|
|
|
+ // });
|
|
|
+ // uni.hideLoading();
|
|
|
+ // uni.showLoading({
|
|
|
+ // title: "正在更新...",
|
|
|
+ // mask: true,
|
|
|
+ // });
|
|
|
+ // 调用安装逻辑
|
|
|
+ plus.runtime.install(
|
|
|
+ saveRes
|
|
|
+ .savedFilePath, {
|
|
|
+ force: true
|
|
|
+ },
|
|
|
+ function() {
|
|
|
+ uni
|
|
|
+ .hideLoading();
|
|
|
+ },
|
|
|
+ function() {
|
|
|
+ uni
|
|
|
+ .hideLoading();
|
|
|
+ uni.showToast({
|
|
|
+ title: '更新失败',
|
|
|
+ icon: 'error'
|
|
|
});
|
|
|
+ });
|
|
|
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
+ }
|
|
|
+ });
|
|
|
+ downloadTask.onProgressUpdate((res) => {
|
|
|
+ console.log('下载进度:', res)
|
|
|
+ // uni.showModal({
|
|
|
+ // content: '下载进度:' + res.progress + '%',
|
|
|
+ // showCancel: false,
|
|
|
+ // success: (val) => {
|
|
|
+ // if (val.confirm) {
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ uni.showLoading({
|
|
|
+ title: "正在下载安装包: " + res.progress + "%",
|
|
|
+ mask: true,
|
|
|
});
|
|
|
- }
|
|
|
+
|
|
|
+ if (res.progress == 100) {
|
|
|
+ uni.hideLoading();
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
- });
|
|
|
- }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
+ }).catch(err => {
|
|
|
+ console.log('err:', err)
|
|
|
})
|
|
|
// #endif
|
|
|
},
|