Files
ys-app/src/pages/userinfo/version.vue

139 lines
4.0 KiB
Vue
Raw Normal View History

2025-08-01 18:12:36 +08:00
<template>
<view class="con-body">
<view class="con-bg">
<!-- 头部 -->
<customHeader ref="customHeaderRef" :title="'版本更新'" :leftFlag="true" :rightFlag="false"></customHeader>
<!-- 高度来避免头部遮挡 -->
2025-08-13 09:22:58 +08:00
<view class="top-height"></view>
2025-08-01 18:12:36 +08:00
<view class="white-bg">
<view class="version-con">
<view class="v-title">当前版本 Version {{appVersion}}</view>
2025-08-13 09:22:58 +08:00
<block v-if="isCurrent==2">
2025-08-01 18:12:36 +08:00
<view class="v-sub-title">最新版本 Version {{ newVersion }}</view>
<view class="v-remark">
<view class="v-r-title">本期更新</view>
{{ remark }}
</view>
<view class="v-btn" @click="handleDown"> </view>
</block>
<block v-else>
<view class="v-new-title">已经是最新版本</view>
</block>
</view>
</view>
</view>
</view>
</template>
<script setup>
2025-08-20 11:36:31 +08:00
import { ref, onMounted,getCurrentInstance } from 'vue'
2025-08-12 16:19:19 +08:00
import { onLoad } from '@dcloudio/uni-app';
2025-08-01 18:12:36 +08:00
import customHeader from '@/components/customHeader.vue'
import { versionCheck } from '@/api/auth.js';
import { getNavBarPaddingTop } from '@/utils/system.js'
2025-08-12 16:19:19 +08:00
import { formatIOS } from '@/utils/status.js'
2025-08-20 11:36:31 +08:00
const { proxy } = getCurrentInstance();
2025-08-12 16:19:19 +08:00
// 初始load页面
onLoad(async(opt) => {
getOSVesion();
});
2025-08-01 18:12:36 +08:00
// 1.头部导航栏
let navBarPaddingTop = ref(0);
let appVersion = ref("1.0.0");//当前版本号
let newVersion = ref('1.0.0');//最新版本号
2025-08-13 09:22:58 +08:00
let isCurrent = ref(undefined);
let downloadURL = ref(''); //下载地址
2025-08-01 18:12:36 +08:00
let remark = ref('');//更新内容
onMounted(() => {
navBarPaddingTop.value = getNavBarPaddingTop() * 2;
})
let getOSVesion = async()=>{
2025-08-20 11:36:31 +08:00
let networkEnv = proxy.$NETWORK_ENV;//1-内网 2-外网
2025-08-01 18:12:36 +08:00
let systemInfo = uni.getSystemInfoSync();
let param = {
// #ifdef APP-PLUS
2025-08-12 16:19:19 +08:00
verNumber:systemInfo.appWgtVersion,//当前版本号
2025-08-01 18:12:36 +08:00
// #endif
// #ifdef H5
2025-08-12 16:19:19 +08:00
verNumber : systemInfo.appVersion,
2025-08-01 18:12:36 +08:00
// #endif
2025-08-12 16:19:19 +08:00
os: formatIOS(systemInfo.osName),//操作系统 Android IOS
2025-08-20 11:36:31 +08:00
runEnv:networkEnv
2025-08-01 18:12:36 +08:00
}
// 当前手机版本
appVersion.value = param.appVersion;
2025-08-20 11:36:31 +08:00
console.log("appVersion=>",appVersion.value)
2025-08-01 18:12:36 +08:00
let data = await versionCheck(param);
2025-08-12 16:19:19 +08:00
newVersion.value = data.verNumber;
2025-08-13 09:22:58 +08:00
downloadURL.value = data.downloadUrl || '';
isCurrent.value = data.isCurrent;
2025-08-20 11:36:31 +08:00
remark.value = data.remark; //|| '全新的UI界面 优化了签到/打卡功能,整体流程更加简洁清晰 搜索功能全面升级 修复了已知BUG'
2025-08-01 18:12:36 +08:00
}
// 下载最新版本
const handleDown = ()=>{
// #ifdef APP-PLUS
// 跳转到应用商店或下载最新版本的页面
plus.runtime.openURL(downloadURL.value);
2025-08-12 16:19:19 +08:00
if (versionData.value.os == 'ios'){
plus.ios.import("UIApplication").sharedApplication().performSelector("exit")
} else if (versionData.value.os == 'android'){
2025-08-01 18:12:36 +08:00
plus.runtime.quit();
2025-08-12 16:19:19 +08:00
}
2025-08-01 18:12:36 +08:00
// #endif
}
</script>
<style scoped>
.white-bg{
width: 750rpx;
padding: 40rpx 0 ;
margin-bottom:0;
border-radius: 8px 8px 0 0;
2025-08-13 09:22:58 +08:00
height:calc(100vh - 105px);
2025-08-01 18:12:36 +08:00
}
.version-con{
padding:10rpx 53rpx;
}
.version-con .v-title{
font-size:38rpx;
font-weight: bold;
}
.version-con .v-sub-title{
color:#3384DF;
font-size: 28rpx;
margin-top: 35rpx;
font-weight: bold;
border-bottom:1px solid #E7E7E7;
padding-bottom: 25rpx;
}
.version-con .v-remark{
padding-top:25rpx;
font-size:28rpx;
line-height: 50rpx;
}
.version-con .v-remark .v-r-title{
font-size: 32rpx;
font-weight: bold;
margin-bottom:10rpx;
}
.version-con .v-btn{
width:496rpx;
height:80rpx;
line-height:80rpx;
text-align: center;
color:#F0F0F0;
background-color: #05A3F4;
margin:100rpx auto;
border-radius: 44rpx;
}
.version-con .v-new-title{
color:#919191;
font-size:28rpx;
font-weight: bold;
margin-top:40rpx;
}
</style>