修改活动报名显示问题,升级版本bug,支付正在开发

This commit is contained in:
zhouyanli
2026-07-11 11:11:43 +08:00
parent be4bae64d1
commit 3124f95cb3
8 changed files with 172 additions and 72 deletions

View File

@@ -42,7 +42,7 @@
authLogout, getUserProfile, getUserNotify, changeUserNotify, getAppVersion, checkAppUpdate, postUpdateLog
} from '/pageSubPack/api/apiSub.js'
//
//
const statusBarHeight = ref(20)
const cacheSize = ref(0)
const currentVersion = ref('1.0.0')
@@ -134,16 +134,52 @@
return 0
}
// 跳转到应用商店更新
const openAppStore = (downloadUrl, platform) => {
// #ifdef APP-PLUS
if (downloadUrl) {
// 优先使用服务端返回的应用商店地址
const pkgName = plus.runtime.appid || ''
console.log('包名---------',pkgName)
// 无论返回哪种 downloadUrl都在后面拼接包名
const finalUrl = downloadUrl + pkgName
plus.runtime.openURL(finalUrl)
} else if (platform === 'ios') {
// iOS: 打开 App Store需在 Apple Developer 后台获取 Apple ID
plus.runtime.openURL('itms-apps://itunes.apple.com/app/id' + plus.runtime.appid)
} else {
// Android: 通过 market 协议唤起手机自带应用商店
const packageName = plus.runtime.appid || ''
plus.runtime.openURL('market://details?id=' + packageName, () => {
// market 协议失败时的回调,提示用户手动前往应用商店
uni.showToast({ title: '请前往应用商店更新', icon: 'none' })
})
}
// #endif
// #ifndef APP-PLUS
uni.showToast({ title: '请在应用商店更新', icon: 'none' })
// #endif
}
// 检查版本更新
const checkVersionUpdate = async () => {
uni.showLoading({ title: '检查中...', mask: true })
// #ifdef APP-PLUS
// const channel = plus.runtime.channel; // 云打包自动写入,自定义包为空
// const channel = 'xioami'
// console.log('channel',channel)
// #endif
try {
const systemInfo = uni.getSystemInfoSync()
const platform = systemInfo.platform === 'ios' ? 'ios' : 'android'
const channel = 'resident'
const platform = systemInfo.platform === 'android' ? 'android':'ios'
const appChannel = 'resident'
const channel = 'xiaomi'
// const channel = plus.runtime.channel;
// 1. 查询最新版本
const versionRes = await getAppVersion(platform, channel)
const versionRes = await getAppVersion(platform, channel, appChannel)
console.log('查询最新版本',versionRes.data)
if (versionRes.code === 200 && versionRes.data) {
const latestVersion = versionRes.data.versionName || ''
const latestVersionCode = versionRes.data.versionCode || 0
@@ -152,23 +188,31 @@
const checkRes = await checkAppUpdate({
platform: platform,
channel: channel,
appChannel: appChannel,
currentVersionCode: currentVersionCode.value
})
uni.hideLoading()
if (checkRes.code === 200 && checkRes.data) {
console.log('是否需要更新',checkRes.data)
const needUpdate = checkRes.data.needUpdate !== false
if (needUpdate) {
// 如果版本号一致,直接提示已是最新版本
if (compareVersion(currentVersion.value, latestVersion) >= 0) {
uni.showToast({ title: '已是最新版本', icon: 'success' })
return
}
const updateType = checkRes.data.updateType || versionRes.data.updateType || 'optional'
const isForce = updateType === 'force'
const downloadUrl = versionRes.data.downloadUrl || ''
uni.showModal({
title: isForce ? '强制更新' : '发现新版本',
content: `当前版本:${currentVersion.value}\n最新版本${latestVersion}${versionRes.data.releaseNotes || versionRes.data.updateDesc ? '\n\n更新内容' + (versionRes.data.releaseNotes || versionRes.data.updateDesc) : ''}`,
content: `当前版本:${currentVersion.value}\n最新版本${latestVersion}${versionRes.data.releaseNotes ? '\n\n更新内容' + (versionRes.data.releaseNotes) : ''}`,
showCancel: !isForce,
confirmText: '立即更新',
cancelText: '稍后',
success: (modalRes) => {
if (modalRes.confirm && versionRes.data.downloadUrl) {
if (modalRes.confirm) {
// 记录更新日志
const userId = uni.getStorageSync('userId')
if (userId) {
@@ -179,12 +223,8 @@
toVersion: latestVersionCode
})
}
// #ifdef APP-PLUS
plus.runtime.openURL(versionRes.data.downloadUrl)
// #endif
// #ifndef APP-PLUS
uni.showToast({ title: '请在应用商店更新', icon: 'none' })
// #endif
// 跳转到应用商店更新
openAppStore(downloadUrl, platform)
} else if (isForce && !modalRes.confirm) {
// 强制更新时用户点取消,退出应用
// #ifdef APP-PLUS
@@ -197,19 +237,19 @@
uni.showToast({ title: '已是最新版本', icon: 'success' })
}
} else {
uni.showToast({ title: '检查失败', icon: 'none' })
uni.showToast({ title: '检查更新失败1', icon: 'none' })
}
} else {
uni.hideLoading()
uni.showToast({ title: '检查失败', icon: 'none' })
uni.showToast({ title: '检查更新失败2', icon: 'none' })
}
} catch (err) {
uni.hideLoading()
uni.showToast({ title: '检查失败', icon: 'none' })
uni.showToast({ title: err.msg || '检查更新失败', icon: 'none' })
}
}
//
//
const onItemClick = (item) => {
if (item.title == '更改手机号码') {
uni.redirectTo({
@@ -280,7 +320,7 @@
}).catch(err => {
console.log(err);
uni.showToast({
title: `${err}`,
title: err.msg,
icon: 'error'
});
})
@@ -438,4 +478,4 @@
.no-cross-switch>>>.uni-switch-input-checked {
background-color: #007aff !important;
}
</style>
</style>