银联支付集成和购买插件;修改首页小区更改后获取数据;对接我的信息接口
This commit is contained in:
@@ -184,6 +184,7 @@ const statusBarHeight = ref(0)
|
||||
const bannerList = ref([])
|
||||
const noticeText = ref('暂无公告')
|
||||
const noticeId = ref('')
|
||||
const lastUserId = ref('') // 用于检测是否切换账号
|
||||
|
||||
// =======方法=======
|
||||
// 格式化时间
|
||||
@@ -276,9 +277,37 @@ const getNoticeData = async() =>{
|
||||
}
|
||||
}
|
||||
|
||||
onShow(() =>{
|
||||
})
|
||||
// 刷新所有数据(提取公共方法)
|
||||
const refreshAllData = () => {
|
||||
const token = uni.getStorageSync('token') || '';
|
||||
const currentVillageId = uni.getStorageSync('currentVillageId');
|
||||
if (token && currentVillageId && currentVillageId !== '0' && currentVillageId !== 0) {
|
||||
getCurrentCommunityData();
|
||||
}
|
||||
getNoticeData()
|
||||
getNewActivityList()
|
||||
getbannarData()
|
||||
}
|
||||
|
||||
onShow(() => {
|
||||
const currentUserId = uni.getStorageSync('userId') || ''
|
||||
// 检测到切换账号:重置数据并重新加载
|
||||
if (lastUserId.value && lastUserId.value !== currentUserId) {
|
||||
// 切换账号时重置页面数据
|
||||
currentCommunity.value = '请认证小区'
|
||||
currentVillageId.value = ''
|
||||
activityList.value = []
|
||||
bannerList.value = []
|
||||
noticeText.value = '暂无公告'
|
||||
noticeId.value = ''
|
||||
refreshAllData()
|
||||
}
|
||||
// 首次显示 或 非切换账号的普通返回,也刷新数据
|
||||
else {
|
||||
refreshAllData()
|
||||
}
|
||||
lastUserId.value = currentUserId
|
||||
})
|
||||
|
||||
onLoad(() => {
|
||||
const info = uni.getSystemInfoSync()
|
||||
@@ -287,15 +316,11 @@ onLoad(() => {
|
||||
// 绑定全局事件监听
|
||||
uni.$on('confirm', slelctHomeData)
|
||||
|
||||
// 页面加载时,先判断是否有token,有则获取认证小区
|
||||
const token = uni.getStorageSync('token') || '';
|
||||
const currentVillageId = uni.getStorageSync('currentVillageId');
|
||||
if (token && currentVillageId && currentVillageId !== '0' && currentVillageId !== 0) {
|
||||
getCurrentCommunityData(); // 加载时获取认证小区
|
||||
}
|
||||
getNoticeData()
|
||||
getNewActivityList()
|
||||
getbannarData()
|
||||
// 记录当前用户ID,用于 onShow 中检测是否切换账号
|
||||
lastUserId.value = uni.getStorageSync('userId') || ''
|
||||
|
||||
// 页面加载时刷新数据
|
||||
refreshAllData()
|
||||
})
|
||||
|
||||
// 页面销毁时移除监听(防止内存泄漏)
|
||||
|
||||
Reference in New Issue
Block a user