This commit is contained in:
weipengfei 2023-09-08 18:48:28 +08:00
parent f644180b76
commit c2666d2d56
4 changed files with 21 additions and 15 deletions

View File

@ -9,7 +9,6 @@ import Updater from '@/uni_modules/guyue-updater/index';
function compareVersions(version1, version2) {
const arr1 = version1.split('.').map(Number);
const arr2 = version2.split('.').map(Number);
for (let i = 0; i < Math.max(arr1.length, arr2.length); i++) {
const num1 = i < arr1.length ? arr1[i] : 0;
const num2 = i < arr2.length ? arr2[i] : 0;
@ -20,7 +19,6 @@ function compareVersions(version1, version2) {
return -1;
}
}
return 0;
}
@ -58,8 +56,9 @@ const actions = {
if(data) uni.showLoading({
title: '检查更新中'
})
const wgt_v = uni.getStorageSync('wgt_version')||'1.0.0';
// 版本更新
if(compareVersions(res.data.version, os.appVersion||Cache.get('wgt_version')||'1.0.0')==1&&compareVersions(res.data.version, Cache.get('wgt_version')||'1.0.0')==1){
if(compareVersions(res.data.version, os.appVersion||wgt_v)==1&&compareVersions(res.data.version, wgt_v)==1){
try{
let info = res.data.version_info||{};
let version = {
@ -70,8 +69,7 @@ const actions = {
force: info.force==1?true:false, // 是否强制更新
quiet: info.quiet==1?true:false // 是否静默更新
}
Updater.update(version);
Cache.set('wgt_version', info.version);
Updater.update(version);;
}catch(e){
console.log(e);
}

View File

@ -15,27 +15,27 @@
<view class="item">
<view class="text">
押金()
<view class="price">{{income}}</view>
<view class="price">{{extend.deposit.toFixed(2)}}</view>
</view>
<view class="tips">
<!-- <view class="tips">
押金{{terraceIncome.count}}{{terraceIncome.num}}
</view>
</view> -->
</view>
<view class="item">
<view class="text">
个人收益金额()
<view class="price">{{disbursement}}</view>
<view class="price">{{extend.user_money.toFixed(2)}}</view>
</view>
<view class="tips">
<!-- <view class="tips">
收益{{terraceIncome.count}}{{terraceIncome.num}}
</view>
</view> -->
</view>
<view class="all" style="justify-content: space-between;">
<view></view>
<view style="display: flex;">
<view>收益总金额():</view>
<view class="price">
{{aggregateAmount}}
{{(extend.deposit+extend.user_money).toFixed(2)}}
</view>
</view>
</view>
@ -99,6 +99,10 @@
m: '',
d: ''
},
extend: {
deposit: 0,
user_money: 0
},
loadConfig: {
page: 1,
limit: 15,
@ -197,6 +201,9 @@
} else {
this.loadConfig.page++;
}
if(res.data?.extend?.deposit){
this.extend = res.data.extend;
}
this.billList = [...this.billList, ...res.data.lists];
},
initDate() {
@ -273,7 +280,7 @@
font-weight: 400;
color: #666666;
line-height: 39rpx;
padding-bottom: 40rpx;
// padding-bottom: 40rpx;
.text {
font-size: 28rpx;

View File

@ -9,7 +9,7 @@ export default class Updater {
download({
url: options.downUrl,
onSuccess(filePath) {
install(filePath, false);
install(filePath, false, options.versionName);
},
});
} else if (options.downUrl) {

View File

@ -16,11 +16,12 @@ export const download = ({ url, onProgress, onSuccess, onFail }) => {
});
};
export const install = (filePath, restart = false) => {
export const install = (filePath, restart = false, version) => {
plus.runtime.install(filePath, {
force: true
}, () => {
console.log('install success...');
uni.setStorageSync('wgt_version', version);
if (restart) {
plus.runtime.restart();
}