<template> <!-- 检查更新 --> <div class="codeqrPage"> <div class="main"> <img src="https://www.pgyer.com/app/qrcode/ktbN9A" alt="APP扫码" class="codeImg" /> <h2>{{ versionInfo.buildName }}</h2> <p>当前版本号:{{ versionInfo.buildVersion }}</p> <p>更新时间:{{ versionInfo.buildUpdated }}</p> <p>更新说明:{{ versionInfo.buildUpdateDescription || '--' }}</p> <van-button type="primary" round block @click="goDownload" v-if="ifNew == 'true'">立即更新</van-button> </div> </div> </template> <script setup name="codeqrPage"> import { useStore } from '@/pinia/store.js'; import { appVersion, appVersionCheck } from '@/api/publicApi.js'; const pinias = useStore(); const versionInfo = ref({}); const ifNew = ref('false'); // 获取版本信息 function getVersionInfo() { pinias.showLoading(); appVersion().then((res) => { versionInfo.value = res.data; checkNewVersion(); //检测App是否有更新 pinias.hideLoading(); }); } // 检测App是否有更新; function checkNewVersion() { appVersionCheck().then((res) => { ifNew.value = res.data.buildHaveNewVersion; }); } function goDownload() { window.android.downloadurl('https://www.pgyer.com/bj9MvqhO'); } onMounted(() => { getVersionInfo(); //获取详情 }); </script> <style lang="less" scoped> .codeqrPage { width: 100%; display: flex; justify-content: center; .main { width: 90%; margin: 50px 5%; text-align: center; line-height: 40px; .codeImg { width: 210px; height: 210px; } .van-button { margin-top: 50px; } } } </style>