|
|
|
@ -86,6 +86,8 @@ import { session } from '@/store/modules/session';
|
|
|
|
|
import { BasePage } from '@/components/base/page';
|
|
|
|
|
import { VForm } from 'vue/types/form';
|
|
|
|
|
import { Lang } from '@/i18n';
|
|
|
|
|
import vm from '@/main';
|
|
|
|
|
import checkAppUpdate from '@/plugins/app-update';
|
|
|
|
|
// mixin 引入示例目前用于弹窗自定义
|
|
|
|
|
// import { any } from 'lodash/fp';
|
|
|
|
|
|
|
|
|
@ -147,12 +149,12 @@ export default class LoginPage extends BasePage {
|
|
|
|
|
this.$form.setRules(this.rules);
|
|
|
|
|
//this.update();
|
|
|
|
|
console.log('image', this.image);
|
|
|
|
|
console.log("Version////",this.Version);
|
|
|
|
|
console.log('Version////', this.Version);
|
|
|
|
|
}
|
|
|
|
|
Version = '1.0.0';
|
|
|
|
|
async update() {
|
|
|
|
|
await session.QueryVersion();
|
|
|
|
|
if (this.Version != session.Version) {
|
|
|
|
|
if (this.Version == session.Version) {
|
|
|
|
|
// 版本更新提示
|
|
|
|
|
uni.showModal({
|
|
|
|
|
content: this.$t('message.Tip1') as string,
|
|
|
|
@ -162,69 +164,33 @@ export default class LoginPage extends BasePage {
|
|
|
|
|
if (res.confirm) {
|
|
|
|
|
//确定执行下载
|
|
|
|
|
let downloadApkUrl = session.url;
|
|
|
|
|
uni.showLoading({
|
|
|
|
|
title: vm.$t('message.uploading') as string,
|
|
|
|
|
//title: '正在下载中..........',
|
|
|
|
|
});
|
|
|
|
|
////////////////uni下载方法,
|
|
|
|
|
uni.downloadFile({
|
|
|
|
|
url: downloadApkUrl,
|
|
|
|
|
success: (downloadResult) => {
|
|
|
|
|
//uni.hideLoading();
|
|
|
|
|
uni.hideLoading();
|
|
|
|
|
if (downloadResult.statusCode == 200) {
|
|
|
|
|
//安装更新
|
|
|
|
|
plus.runtime.install(downloadResult.tempFilePath as any, { force: true }, function () {
|
|
|
|
|
//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();
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
// },
|
|
|
|
|
// });
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
///////////////////// 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('用户点击取消');
|
|
|
|
|
} else {
|
|
|
|
|
//return;
|
|
|
|
|
console.log("1111111");
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//return;
|
|
|
|
|
this.go();
|
|
|
|
|
}
|
|
|
|
|
/////////////////无用代码无用代码
|
|
|
|
|
// 更新应用资源
|
|
|
|
@ -260,6 +226,33 @@ export default class LoginPage extends BasePage {
|
|
|
|
|
}, 1500);
|
|
|
|
|
}
|
|
|
|
|
////////////////////////////
|
|
|
|
|
async go() {
|
|
|
|
|
const { username, password } = this.form;
|
|
|
|
|
const loginResult = await session.login({
|
|
|
|
|
username,
|
|
|
|
|
password,
|
|
|
|
|
lang: this.$i18n.locale as Lang,
|
|
|
|
|
});
|
|
|
|
|
const { code, factoryCode, list, loginName, msg, userId, userName } = loginResult;
|
|
|
|
|
session.setUser({
|
|
|
|
|
code,
|
|
|
|
|
factoryCode,
|
|
|
|
|
loginName,
|
|
|
|
|
list,
|
|
|
|
|
msg,
|
|
|
|
|
userId,
|
|
|
|
|
userName,
|
|
|
|
|
lang: this.$i18n.locale as Lang,
|
|
|
|
|
});
|
|
|
|
|
uni.showToast({
|
|
|
|
|
icon: 'success',
|
|
|
|
|
title: this.$t('message.LoginSuccessful') as string,
|
|
|
|
|
});
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url: page.login.area,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
login(): void {
|
|
|
|
|
this.$form.validate(async (valid: boolean) => {
|
|
|
|
|
if (valid) {
|
|
|
|
@ -272,32 +265,34 @@ export default class LoginPage extends BasePage {
|
|
|
|
|
uni.navigateTo({ url: page.login.server });
|
|
|
|
|
}, 2000);
|
|
|
|
|
} else {
|
|
|
|
|
const { username, password } = this.form;
|
|
|
|
|
const loginResult = await session.login({
|
|
|
|
|
username,
|
|
|
|
|
password,
|
|
|
|
|
lang: this.$i18n.locale as Lang,
|
|
|
|
|
});
|
|
|
|
|
const { code, factoryCode, list, loginName, msg, userId, userName } = loginResult;
|
|
|
|
|
session.setUser({
|
|
|
|
|
code,
|
|
|
|
|
factoryCode,
|
|
|
|
|
loginName,
|
|
|
|
|
list,
|
|
|
|
|
msg,
|
|
|
|
|
userId,
|
|
|
|
|
userName,
|
|
|
|
|
lang: this.$i18n.locale as Lang,
|
|
|
|
|
});
|
|
|
|
|
uni.showToast({
|
|
|
|
|
icon: 'success',
|
|
|
|
|
title: this.$t('message.LoginSuccessful') as string,
|
|
|
|
|
});
|
|
|
|
|
//debugger;
|
|
|
|
|
// this.update();
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url: page.login.area,
|
|
|
|
|
});
|
|
|
|
|
//checkAppUpdate();
|
|
|
|
|
this.update();
|
|
|
|
|
//const { username, password } = this.form;
|
|
|
|
|
// const loginResult = await session.login({
|
|
|
|
|
// username,
|
|
|
|
|
// password,
|
|
|
|
|
// lang: this.$i18n.locale as Lang,
|
|
|
|
|
// });
|
|
|
|
|
// const { code, factoryCode, list, loginName, msg, userId, userName } = loginResult;
|
|
|
|
|
// session.setUser({
|
|
|
|
|
// code,
|
|
|
|
|
// factoryCode,
|
|
|
|
|
// loginName,
|
|
|
|
|
// list,
|
|
|
|
|
// msg,
|
|
|
|
|
// userId,
|
|
|
|
|
// userName,
|
|
|
|
|
// lang: this.$i18n.locale as Lang,
|
|
|
|
|
// });
|
|
|
|
|
// uni.showToast({
|
|
|
|
|
// icon: 'success',
|
|
|
|
|
// title: this.$t('message.LoginSuccessful') as string,
|
|
|
|
|
// });
|
|
|
|
|
// //debugger;
|
|
|
|
|
// // this.update();
|
|
|
|
|
// uni.navigateTo({
|
|
|
|
|
// url: page.login.area,
|
|
|
|
|
// });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|