修改升级版本、缴费记录分页显示金额问题

This commit is contained in:
zhouyanli
2026-09-23 16:51:45 +08:00
parent cf8e8263b7
commit 6022b19160
5 changed files with 78 additions and 25 deletions

View File

@@ -2,8 +2,8 @@ import { navigateToLogin } from '@/common/checkLogin.js'
let baseUrl = '';
if (process.env.NODE_ENV === 'development') {
baseUrl = 'http://192.168.0.222:8080'; // 开发环境
// baseUrl = 'https://wuyeapi.ckdzkj.com';
// baseUrl = 'http://192.168.0.222:8080'; // 开发环境
baseUrl = 'https://wuyeapi.ckdzkj.com';
} else {
baseUrl = 'https://wuyeapi.ckdzkj.com'; // 生产环境
// baseUrl = 'https://during-immovable-eats.ngrok-free.dev';

View File

@@ -124,23 +124,42 @@
return 0
}
// iOS App Store 数字 ID(App Store Connect → App 信息 → Apple ID)
const IOS_APPLE_ID = '6785337718'
// 获取 Android 包名。plus.runtime.appid 是 DCloud 的 __UNI__ 标识,不是包名
const getAndroidPackageName = () => {
// #ifdef APP-PLUS
if (plus.os.name === 'Android') {
try {
return String(plus.android.runtimeMainActivity().getPackageName())
} catch (e) {
console.log('获取包名失败', e)
}
}
// #endif
return 'com.chengkong.property.owner' // 兜底:与 App Store 上的 bundleId 一致
}
// 跳转到应用商店更新
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)
const shopUrl = (downloadUrl || '').trim()
if (platform === 'ios') {
// iOS 用 itms-apps 原生协议直接唤起 App Store,不带中文名避免二次编码
//'itms-apps://itunes.apple.com/app/id' + IOS_APPLE_ID
plus.runtime.openURL(downloadUrl, () => {
// itms-apps 协议不可用时回退到 https 链接
plus.runtime.openURL('https://apps.apple.com/cn/app/id' + IOS_APPLE_ID)
})
} else if (shopUrl) {
// 服务端返回的是渠道地址前缀(如应用宝的 ...?pkgname=),拼上真实包名
plus.runtime.openURL(shopUrl + getAndroidPackageName(), () => {
uni.showToast({ title: '请前往应用商店更新', icon: 'none' })
})
} else {
// Android: 通过 market 协议唤起手机自带应用商店
const packageName = plus.runtime.appid || ''
plus.runtime.openURL('market://details?id=' + packageName, () => {
plus.runtime.openURL('market://details?id=' + getAndroidPackageName(), () => {
// market 协议失败时的回调,提示用户手动前往应用商店
uni.showToast({ title: '请前往应用商店更新', icon: 'none' })
})
@@ -233,8 +252,9 @@
uni.showToast({ title: '检查更新失败2', icon: 'none' })
}
} catch (err) {
console.log('err',err)
uni.hideLoading()
uni.showToast({ title: err.msg || '检查更新失败', icon: 'none' })
uni.showToast({ title: err.msg || '无最新版本', icon: 'none' })
}
}

View File

@@ -58,6 +58,8 @@
</view>
</view>
</view>
<view v-if="loading" class="list-tip">加载中...</view>
<view v-else-if="noMore && monthGroups.length > 0" class="list-tip">没有更多了</view>
</view>
</scroll-view>
</view>
@@ -93,6 +95,12 @@
const barMaxHeight = ref(300)
const billList = ref([])
// 各月缴费合计,来自接口 monthlyStats,key 形如 "2026-09"
const monthStatsMap = ref({})
// 加载中,防止 scrolltolower 连续触发导致 pageNum 连跳
const loading = ref(false)
// 没有更多数据了
const noMore = ref(false)
// 费用名称映射
// topup(水电表充值):type 1=电费, 2=水费
@@ -119,11 +127,15 @@
// 获取缴费记录(loadMore=true 时分页追加)
const getRecords = async (loadMore = false) => {
if (loading.value) return
if (loadMore && noMore.value) return
loading.value = true
// 成功后才推进页码,避免请求失败时丢掉一页
const nextPage = loadMore ? pageNum.value + 1 : 1
try {
if (!loadMore) pageNum.value = 1
const res = await getTopupRecordWithStat({
residentUserId: uni.getStorageSync('userId'),
pageNum: pageNum.value,
pageNum: nextPage,
pageSize: pageSize.value
})
if (res.code === 200) {
@@ -139,11 +151,14 @@
month: parts[1] ? parseInt(parts[1], 10) : 1,
name,
account: item.deviceCode || '',
amount: Number(item.amount) || 0,
amount: Number(item.paidAmount) || 0,
recordType: item.recordType || '',
icon: iconMap[name] || iconMap['账单']
}
})
pageNum.value = nextPage
// 返回条数不足一页,说明没有更多了
noMore.value = mappedList.length < pageSize.value
billList.value = loadMore ? [...billList.value, ...mappedList] : mappedList
// 累计缴费金额
totalAmount.value = res.data.totalAmount || '0.00'
@@ -152,12 +167,13 @@
}
} catch (err) {
console.error('获取缴费记录失败', err)
} finally {
loading.value = false
}
}
// 加载更多(触底分页)
const loadMore = () => {
pageNum.value++
getRecords(true)
}
@@ -169,13 +185,15 @@
const priceMatch = value.match(/([\d.]+)元/)
if (priceMatch && key.includes('-')) {
const [y, m] = key.split('-')
statsMap[key] = {
// 统一成补零格式(2026-09),方便和分组 key 对齐
statsMap[`${parseInt(y, 10)}-${String(parseInt(m, 10)).padStart(2, '0')}`] = {
year: parseInt(y, 10),
month: parseInt(m, 10),
price: parseFloat(priceMatch[1]) || 0
}
}
})
monthStatsMap.value = statsMap
// 取最近6个月(当前月往前)
const now = new Date()
@@ -215,6 +233,7 @@
const key = `${bill.year}-${String(bill.month).padStart(2, '0')}`
if (!map[key]) {
map[key] = {
key,
month: bill.month,
year: bill.year,
total: 0,
@@ -224,8 +243,15 @@
map[key].list.push(bill)
map[key].total += bill.amount
})
// 分组合计优先用接口返回的月度统计:列表是分页加载的,
// 只累加已加载的记录会少算,滚动翻页时数字还会一直往上跳
const groups = Object.values(map)
groups.forEach(group => {
const stat = monthStatsMap.value[group.key]
if (stat) group.total = stat.price
})
// 按年月降序排列
return Object.values(map).sort((a, b) => {
return groups.sort((a, b) => {
if (a.year !== b.year) return b.year - a.year
return b.month - a.month
})
@@ -298,6 +324,13 @@
margin-bottom: 10rpx;
}
.list-tip {
text-align: center;
font-size: 26rpx;
color: #999;
padding: 20rpx 0 40rpx;
}
.top-box {
display: flex;
justify-content: space-between;