修复bug
This commit is contained in:
@@ -146,8 +146,22 @@ const paymentList = ref([
|
||||
|
||||
])
|
||||
|
||||
// 独立的当前小区ID(按账号隔离,避免切换账号后残留上个账号的小区)
|
||||
const getPaymentVillageIdKey = () => 'paymentVillageId_' + (uni.getStorageSync('userId') || '')
|
||||
const getPaymentVillageNameKey = () => 'paymentVillageName_' + (uni.getStorageSync('userId') || '')
|
||||
|
||||
const getPaymentVillageId = () => {
|
||||
return uni.getStorageSync(getPaymentVillageIdKey()) || uni.getStorageSync('currentVillageId') || ''
|
||||
}
|
||||
|
||||
// 获取当前小区
|
||||
const getCurrentCommunityData = () => {
|
||||
const paymentVillageId = uni.getStorageSync(getPaymentVillageIdKey())
|
||||
const paymentVillageName = uni.getStorageSync(getPaymentVillageNameKey())
|
||||
if (paymentVillageId) {
|
||||
currentCommunity.value = paymentVillageName || '已选小区'
|
||||
return
|
||||
}
|
||||
getCurrentVillage().then(res => {
|
||||
if (res.code === 200 && res.data && res.data.villageId) {
|
||||
currentCommunity.value = res.data.villageName || '未命名小区'
|
||||
@@ -159,9 +173,12 @@ const getCurrentCommunityData = () => {
|
||||
|
||||
// 接收小区切换事件
|
||||
const slelctHomeData = (data) => {
|
||||
if (data.name) currentCommunity.value = data.name
|
||||
if (data.name) {
|
||||
currentCommunity.value = data.name
|
||||
uni.setStorageSync(getPaymentVillageNameKey(), data.name)
|
||||
}
|
||||
if (data.villageId) {
|
||||
uni.setStorageSync('currentVillageId', data.villageId)
|
||||
uni.setStorageSync(getPaymentVillageIdKey(), data.villageId)
|
||||
}
|
||||
getBillDetails()
|
||||
getPayList()
|
||||
@@ -169,11 +186,11 @@ const slelctHomeData = (data) => {
|
||||
|
||||
// 跳转小区选择
|
||||
const navigateToSelectHome = () => {
|
||||
const cachedVillageId = uni.getStorageSync('currentVillageId')
|
||||
const cachedVillageId = getPaymentVillageId()
|
||||
if (!cachedVillageId || cachedVillageId === '0' || cachedVillageId === 0) {
|
||||
uni.navigateTo({ url: '/pageSubPack/my/myHouseIndex' })
|
||||
} else {
|
||||
uni.navigateTo({ url: `/pageSubPack/notice-list/selectHome?villageId=${cachedVillageId}` })
|
||||
uni.navigateTo({ url: `/pageSubPack/notice-list/selectHome?villageId=${cachedVillageId}&source=payment` })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,12 +201,12 @@ onShow(() => {
|
||||
|
||||
onLoad(() => {
|
||||
uni.hideTabBar({ animation: false });
|
||||
uni.$on('confirm', slelctHomeData)
|
||||
uni.$on('confirmPayment', slelctHomeData)
|
||||
getPayList()
|
||||
})
|
||||
|
||||
onUnload(() => {
|
||||
uni.$off('confirm', slelctHomeData)
|
||||
uni.$off('confirmPayment', slelctHomeData)
|
||||
})
|
||||
|
||||
// 页面返回拦截
|
||||
@@ -249,7 +266,7 @@ const getBillDetails = (isLoadMore = false) => {
|
||||
}
|
||||
getTopUpDetails({
|
||||
userId: uni.getStorageSync('userId'),
|
||||
villageId: uni.getStorageSync('currentVillageId'),
|
||||
villageId: getPaymentVillageId(),
|
||||
pageNum: pageNum.value,
|
||||
pageSize: pageSize.value,
|
||||
}).then(res => {
|
||||
@@ -289,7 +306,7 @@ const getPayList = async (isLoadMore = false) => {
|
||||
residentUserId: uni.getStorageSync('userId'),
|
||||
pageNum: payPageNum.value,
|
||||
pageSize: payPageSize.value,
|
||||
villageId:uni.getStorageSync('currentVillageId')
|
||||
villageId:getPaymentVillageId()
|
||||
})
|
||||
const data = res.rows || res.data
|
||||
if (isLoadMore) {
|
||||
|
||||
Reference in New Issue
Block a user