更新机制修改,请在登录页修改每次的版本号

master
guoshuang 1 year ago
parent 53d9732785
commit b5696e5e17

@ -87,13 +87,16 @@ import { Component, Ref, Watch } from 'vue-property-decorator';
import Alerts from '@/components/alert/alerts.vue';
import { page } from '@/utils/page';
import { session } from '@/store/modules/session';
import { auth } from '@/store/modules/auth';
import { BasePage } from '@/components/base/page';
import { VForm } from 'vue/types/form';
import model from './model';
// mixin
@Component({
components: { Alerts },
})
export default class LoginPage extends BasePage {
model = model;
/**
* 访客权限
*/
@ -131,7 +134,6 @@ export default class LoginPage extends BasePage {
const languages = ['cn', 'en', 'ru'];
this.$i18n.locale = languages[index];
}
Version = '';
onReady(): void {
this.$form.setRules(this.rules);
//this.customToast('' + plus.runtime.version);
@ -139,6 +141,86 @@ export default class LoginPage extends BasePage {
// console.log('image', this.image);
// console.log('Version////', this.Version);
}
///******************
version = '0.0.56';
compareVersion(version1: any, version2: any) {
//version1 1 &&& version2 -1
const newVersion1 = `${version1}`.split('.').length < 3 ? `${version1}`.concat('.0') : `${version1}`;
const newVersion2 = `${version2}`.split('.').length < 3 ? `${version2}`.concat('.0') : `${version2}`;
//,
function toNum(a) {
const c = a.toString().split('.');
const num_place = ['', '0', '00', '000', '0000'],
r = num_place.reverse();
for (let i = 0; i < c.length; i++) {
const len = c[i].length;
c[i] = r[len] + c[i];
}
return c.join('');
}
//
function checkPlugin(a: any, b: any) {
const numA = toNum(a);
const numB = toNum(b);
return numA > numB ? 1 : numA < numB ? -1 : 0;
}
return checkPlugin(newVersion1, newVersion2);
}
//
async checkupdate() {
try {
await this.model.checkupdate();
const queryversion = this.model.checkversion.version;
//const queryversion = this.checkversion.Version.match(/\d+\.\d+\.\d+/)[0];
let versionNumber = this.compareVersion(this.version, queryversion); //this.version, queryversion
if (versionNumber == -1) {
//
uni.showModal({
content: '新版本为:' + this.model.checkversion.version + ',' + '是否更新?',
success: (res) => {
if (res.confirm) {
//
let downloadApkUrl = this.model.checkversion.fileAddress;
uni.showLoading({
title: '下载中',
});
////////////////uni,
uni.downloadFile({
url: downloadApkUrl,
success: (downloadResult) => {
uni.hideLoading();
if (downloadResult.statusCode == 200) {
//
plus.runtime.install(downloadResult.tempFilePath as any, { force: true }, function () {
//uni.showToast('');
plus.runtime.restart();
});
}
},
});
} else if (res.cancel) {
console.log();
uni.navigateTo({
url: page.shouye,
});
}
},
});
return;
} else {
uni.navigateTo({
url: page.shouye,
});
// uni.showToast({
// title: '',
// icon: 'none',
// });
}
} catch (e) {
console.log('error', e);
}
}
//
onShow(): void {
// console.log('......', server.serverAddress);
@ -262,15 +344,17 @@ export default class LoginPage extends BasePage {
nickName,
roles,
});
auth.setVersion(this.version);
uni.showToast({
//icon: 'success',
duration: 2000,
title: this.$t('message.LoginSuccessful') as string,
image: '/static/icons/icon-51.png',
});
uni.navigateTo({
url: page.shouye,
});
this.checkupdate();
// uni.navigateTo({
// url: page.shouye,
// });
}
}
</script>

@ -0,0 +1,24 @@
import { getModule, Module, MutationAction, VuexModule } from 'vuex-module-decorators';
import store from '@/store';
import http from '@/utils/request';
// import { url } from '@/utils/url';
// import { session } from '@/store/modules/session';
@Module({
namespaced: true,
dynamic: true,
store,
name: 'page.login',
})
export class login extends VuexModule {
checkversion: any = {};
@MutationAction
async checkupdate() {
const result: any = await http.post('/prod-api/system/apkFile/getLastApkVersion', {
factory: 1000,
});
const checkversion: any = result.data;
return { checkversion };
}
}
export default getModule(login);

@ -35,8 +35,8 @@
</view>
</view>
<view class="astyle astyleversion">
<view @click="checkupdate()"> </view>
<view @click="checkupdate()"> Version:{{ version }} </view>
<view> 版本 </view>
<view> Version:{{ version }} </view>
<!-- <u-button
@click.native="
uni.navigateTo({
@ -60,90 +60,92 @@ import { BasePage } from '@/components/base/page';
import dayjs from 'dayjs';
import model from './model';
import { session } from '@/store/modules/session';
import { auth } from '@/store/modules/auth';
@Component
export default class RawHome extends BasePage {
model = model;
src: 'http://pic2.sc.chinaz.com/Files/pic/pic9/202002/hpic2119_s.jpg';
today = dayjs().format('YYYY-MM-DD dddd');
version = '0.0.55';
version = '';
checkversion: any = {};
sessiondata: any = '';
onLoad() {
// this.model.getMenuList();
uni.setStorageSync('version', this.version);
this.sessiondata = session;
this.version = auth.getVersion;
}
compareVersion(version1: any, version2: any) {
//version1 1 &&& version2 -1
const newVersion1 = `${version1}`.split('.').length < 3 ? `${version1}`.concat('.0') : `${version1}`;
const newVersion2 = `${version2}`.split('.').length < 3 ? `${version2}`.concat('.0') : `${version2}`;
//,
function toNum(a) {
const c = a.toString().split('.');
const num_place = ['', '0', '00', '000', '0000'],
r = num_place.reverse();
for (let i = 0; i < c.length; i++) {
const len = c[i].length;
c[i] = r[len] + c[i];
}
return c.join('');
}
//
function checkPlugin(a: any, b: any) {
const numA = toNum(a);
const numB = toNum(b);
return numA > numB ? 1 : numA < numB ? -1 : 0;
}
return checkPlugin(newVersion1, newVersion2);
}
async checkupdate() {
try {
await this.model.checkupdate();
const queryversion = this.model.checkversion.version;
//const queryversion = this.checkversion.Version.match(/\d+\.\d+\.\d+/)[0];
let versionNumber = this.compareVersion(this.version, queryversion); //this.version, queryversion
if (versionNumber == -1) {
//
uni.showModal({
content: '新版本为:' + this.model.checkversion.version + ',' + '是否更新?',
success: (res) => {
if (res.confirm) {
//
let downloadApkUrl = this.model.checkversion.fileAddress;
uni.showLoading({
title: '下载中',
});
////////////////uni,
uni.downloadFile({
url: downloadApkUrl,
success: (downloadResult) => {
uni.hideLoading();
if (downloadResult.statusCode == 200) {
//
plus.runtime.install(downloadResult.tempFilePath as any, { force: true }, function () {
//uni.showToast('');
plus.runtime.restart();
});
}
},
});
} else if (res.cancel) {
console.log();
}
},
});
return;
} else {
uni.showToast({
title: '无更新内容',
icon: 'none',
});
}
} catch (e) {
console.log('error', e);
}
}
// compareVersion(version1: any, version2: any) {
// //version1 1 &&& version2 -1
// const newVersion1 = `${version1}`.split('.').length < 3 ? `${version1}`.concat('.0') : `${version1}`;
// const newVersion2 = `${version2}`.split('.').length < 3 ? `${version2}`.concat('.0') : `${version2}`;
// //,
// function toNum(a) {
// const c = a.toString().split('.');
// const num_place = ['', '0', '00', '000', '0000'],
// r = num_place.reverse();
// for (let i = 0; i < c.length; i++) {
// const len = c[i].length;
// c[i] = r[len] + c[i];
// }
// return c.join('');
// }
// //
// function checkPlugin(a: any, b: any) {
// const numA = toNum(a);
// const numB = toNum(b);
// return numA > numB ? 1 : numA < numB ? -1 : 0;
// }
// return checkPlugin(newVersion1, newVersion2);
// }
// async checkupdate() {
// try {
// await this.model.checkupdate();
// const queryversion = this.model.checkversion.version;
// //const queryversion = this.checkversion.Version.match(/\d+\.\d+\.\d+/)[0];
// let versionNumber = this.compareVersion(this.version, queryversion); //this.version, queryversion
// if (versionNumber == -1) {
// //
// uni.showModal({
// content: '' + this.model.checkversion.version + ',' + '',
// success: (res) => {
// if (res.confirm) {
// //
// let downloadApkUrl = this.model.checkversion.fileAddress;
// uni.showLoading({
// title: '',
// });
// ////////////////uni,
// uni.downloadFile({
// url: downloadApkUrl,
// success: (downloadResult) => {
// uni.hideLoading();
// if (downloadResult.statusCode == 200) {
// //
// plus.runtime.install(downloadResult.tempFilePath as any, { force: true }, function () {
// //uni.showToast('');
// plus.runtime.restart();
// });
// }
// },
// });
// } else if (res.cancel) {
// console.log();
// }
// },
// });
// return;
// } else {
// uni.showToast({
// title: '',
// icon: 'none',
// });
// }
// } catch (e) {
// console.log('error', e);
// }
// }
}
</script>

@ -1,22 +1,12 @@
import { getModule, Module, VuexModule } from 'vuex-module-decorators';
import { getModule, Mutation, Module, VuexModule } from 'vuex-module-decorators';
//import request from '@/utils/request';
import store from '@/store';
//import { User } from '@/store/modules/session';
//import { url } from '@/utils/url';
export interface UserInfo {
factoryCode: string;
factoryName: string;
factoryType?: any;
warehouseCode?: any;
warehouseName?: any;
warehouseType?: any;
loginName: string;
userName: string;
sapFactoryCode?: any;
locationCode?: any;
workareaCode?: any;
}
// export interface UserInfo {
// version:string;
// }
@Module({
dynamic: true,
@ -25,6 +15,14 @@ export interface UserInfo {
name: 'auth',
})
class AuthService extends VuexModule {
version = '';
get getVersion(): string {
return this.version;
}
@Mutation
setVersion(version: string) {
this.version = version;
}
// @Action
// async getUserInfo({ loginName }: { loginName: User['loginName'] }): Promise<UserInfo> {
// const r: any = await request.post(url.auth.userInfo, {

Loading…
Cancel
Save