|
|
|
@ -86,6 +86,7 @@ import { BasePage } from '@/components/base/page';
|
|
|
|
|
import { VForm } from 'vue/types/form';
|
|
|
|
|
import { Lang } from '@/i18n';
|
|
|
|
|
import { url } from '@/utils/url';
|
|
|
|
|
import { path } from 'lodash/fp';
|
|
|
|
|
// import { any } from 'lodash/fp';
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
@ -143,10 +144,8 @@ export default class LoginPage extends BasePage {
|
|
|
|
|
async update() {
|
|
|
|
|
await session.QueryVersion();
|
|
|
|
|
if (this.Version != session.Version) {
|
|
|
|
|
//alert('版本更新啦!');
|
|
|
|
|
// 版本更新提示
|
|
|
|
|
uni.showModal({
|
|
|
|
|
//title: this.$t('message.updatePrompt') as string,
|
|
|
|
|
content: this.$t('message.Tip1') as string,
|
|
|
|
|
confirmText: this.$t('message.workArea_Confirm') as string,
|
|
|
|
|
cancelText: this.$t('message.Cancel') as string,
|
|
|
|
@ -154,38 +153,104 @@ export default class LoginPage extends BasePage {
|
|
|
|
|
if (res.confirm) {
|
|
|
|
|
//确定执行下载
|
|
|
|
|
let downloadApkUrl = session.url;
|
|
|
|
|
// uni.downloadFile({
|
|
|
|
|
// url: downloadApkUrl,
|
|
|
|
|
// });
|
|
|
|
|
var dtask = plus.downloader.createDownload(downloadApkUrl, {}, function (d, status) {
|
|
|
|
|
if (status == 200) {
|
|
|
|
|
console.log('Download success: ' + d.filename);
|
|
|
|
|
uni.showToast({
|
|
|
|
|
icon: 'none',
|
|
|
|
|
title: d.filename,
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
console.log('Download failed: ' + status);
|
|
|
|
|
}
|
|
|
|
|
////////////////uni下载方法,
|
|
|
|
|
uni.downloadFile({
|
|
|
|
|
url: downloadApkUrl,
|
|
|
|
|
success: (downloadResult) => {
|
|
|
|
|
//uni.hideLoading();
|
|
|
|
|
if (downloadResult.statusCode == 200) {
|
|
|
|
|
//安装更新
|
|
|
|
|
plus.runtime.install(downloadResult.tempFilePath, { force: true }, function (res) {
|
|
|
|
|
//uni.showToast('更新成功,重启');
|
|
|
|
|
plus.runtime.restart();
|
|
|
|
|
});
|
|
|
|
|
// uni.showModal({
|
|
|
|
|
// //content: '更新更新',
|
|
|
|
|
// content: this.$t('message.Tip2') as string,
|
|
|
|
|
// confirmText: this.$t('message.restart') as string,
|
|
|
|
|
// cancelText: this.$t('message.Cancel') as string,
|
|
|
|
|
// success: function (res) {
|
|
|
|
|
// if (res.confirm == true) {
|
|
|
|
|
// plus.runtime.install(downloadResult.tempFilePath, { force: true }, function (res) {
|
|
|
|
|
// //uni.showToast('更新成功,重启');
|
|
|
|
|
// plus.runtime.restart();
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
// },
|
|
|
|
|
// });
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
dtask.start();
|
|
|
|
|
///////////////////// plus方法
|
|
|
|
|
// plus.downloader
|
|
|
|
|
// .createDownload(downloadApkUrl, {}, function (d, status) {
|
|
|
|
|
// uni.showModal({
|
|
|
|
|
// content: status,
|
|
|
|
|
// });
|
|
|
|
|
// if (status == 200) {
|
|
|
|
|
// uni.showModal({
|
|
|
|
|
// title: '',
|
|
|
|
|
// content: this.$t('message.Tip2') as string,
|
|
|
|
|
// confirmText: this.$t('message.restart') as string,
|
|
|
|
|
// cancelText: this.$t('message.Cancel') as string,
|
|
|
|
|
// success: function (res) {
|
|
|
|
|
// if (res.confirm == true) {
|
|
|
|
|
// plus.runtime.install(plus.io.convertLocalFileSystemURL(d.filename), { force: true }, function (res) {
|
|
|
|
|
// //uni.showToast('更新成功,重启');
|
|
|
|
|
// plus.runtime.restart();
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
// },
|
|
|
|
|
// });
|
|
|
|
|
// } else {
|
|
|
|
|
// console.log('Download failed: ' + status);
|
|
|
|
|
// }
|
|
|
|
|
// })
|
|
|
|
|
// .start();
|
|
|
|
|
// dtask.start();
|
|
|
|
|
/////////////////plus 方法
|
|
|
|
|
} else if (res.cancel) {
|
|
|
|
|
//console.log('用户点击取消');
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//dtask.addEventListener("statechanged", onStateChanged, false);
|
|
|
|
|
// await uni.downloadFile({
|
|
|
|
|
// url: session.url,
|
|
|
|
|
// success: (res) => {
|
|
|
|
|
// console.log('res.statusCode', res.statusCode);
|
|
|
|
|
// console.log('res.tempFilePath', res.tempFilePath);
|
|
|
|
|
// console.log("url,url,url",session.url);
|
|
|
|
|
// },
|
|
|
|
|
// });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/////////////////无用代码无用代码
|
|
|
|
|
// 更新应用资源
|
|
|
|
|
async installApk(path) {
|
|
|
|
|
plus.runtime.install(
|
|
|
|
|
path,
|
|
|
|
|
{},
|
|
|
|
|
function () {
|
|
|
|
|
console.log('安装文件成功!');
|
|
|
|
|
|
|
|
|
|
plus.runtime.restart();
|
|
|
|
|
},
|
|
|
|
|
function (e) {
|
|
|
|
|
uni.hideLoading();
|
|
|
|
|
console.log(JSON.stringify(e)); //这里!e一直为null,path路径为_downloads/apk/10.apk
|
|
|
|
|
uni.showToast({
|
|
|
|
|
title: '安装失败',
|
|
|
|
|
mask: false,
|
|
|
|
|
duration: 1500,
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
/* 安装失败 */
|
|
|
|
|
failed() {
|
|
|
|
|
uni.showToast({
|
|
|
|
|
icon: 'none',
|
|
|
|
|
mask: true,
|
|
|
|
|
title: '更新失败!请退出重试或向工作人员反映',
|
|
|
|
|
duration: 1500,
|
|
|
|
|
});
|
|
|
|
|
setTimeout(function () {
|
|
|
|
|
plus.runtime.quit();
|
|
|
|
|
}, 1500);
|
|
|
|
|
}
|
|
|
|
|
////////////////////////////
|
|
|
|
|
login(): void {
|
|
|
|
|
this.$form.validate(async (valid: boolean) => {
|
|
|
|
|
if (valid) {
|
|
|
|
|