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