修改切换账号绑定小区

This commit is contained in:
zhouyanli
2026-06-09 17:11:25 +08:00
parent ebdfa8d95e
commit aaf828c6e3
15 changed files with 54 additions and 29 deletions

View File

@@ -87,7 +87,6 @@
</view>
<!-- 广告卡片 -->
<view class="adCardClass">
<!-- <uni-card :is-shadow="false" > -->
<view class="u-demo-block__content">
<up-row justify="space-between" customStyle="margin-bottom: 10px">
<up-col span="3">
@@ -98,14 +97,12 @@
<up-col span="8">
<view class="demo-layout bg-purple-light titleLeft">
<text style="color: #fff;font-size: 40rpx;font-weight: 700;">便民服务</text>
<view style="color: #fff;font-size: 28rpx;">邻里便民服务 全新上线</view>
<view style="color: #fff;font-size: 28rpx;">邻里便民服务 即将上线</view>
</view>
</up-col>
</up-row>
</view>
<!-- </uni-card> -->
</view>
<!-- 活动列表 -->
<uni-card class="activity-card">
@@ -171,14 +168,14 @@
import { ref } from 'vue'
import {onLoad,onUnload,onShow} from '@dcloudio/uni-app'
import moment from 'moment'
import {getNoticeLatest,getCurrentVillage,getActivitylatest,getBannarList} from "/pageSubPack/api/api.js"
import {getNoticeLatest,getCurrentVillage,getActivitylatest,getBannarList,getReloadUserInfo} from "/pageSubPack/api/api.js"
// 列表数据状态
const isDropdownOpen = ref(false)
const scrollTop = ref(0)
const activityList = ref([]) // 活动列表数据
const currentCommunity = ref('请认证小区')
const currentCommunity = ref('请绑定房屋')
const currentVillageId = ref('')
const statusBarHeight = ref(0)
const bannerList = ref([])
@@ -234,7 +231,7 @@ const getCurrentCommunityData = () => {
currentVillageId.value = res.data.villageId
uni.setStorageSync('currentVillageId',res.data.villageId)
}else{
currentCommunity.value = '请认证小区'
currentCommunity.value = '请绑定房屋'
currentVillageId.value = ''
}
}).catch(err =>{
@@ -269,7 +266,7 @@ const getNoticeData = async() =>{
} catch (err) {
uni.showToast({
title: err.msg || '网络异常',
icon: 'error',
icon: 'none',
duration: 1000
})
noticeText.value = '暂无公告'
@@ -278,12 +275,27 @@ const getNoticeData = async() =>{
}
// 刷新所有数据(提取公共方法)
const refreshAllData = () => {
const refreshAllData = async () => {
const token = uni.getStorageSync('token') || '';
const currentVillageId = uni.getStorageSync('currentVillageId');
if (token && currentVillageId && currentVillageId !== '0' && currentVillageId !== 0) {
getCurrentCommunityData();
const needReload = uni.getStorageSync('needReloadUserInfo');
// 只有从绑定房屋返回首页时才重新加载用户信息获取最新小区ID
if (token && needReload) {
try {
const res = await getReloadUserInfo();
if (res.code === 200 && res.data) {
if (res.data.userId) {
uni.setStorageSync('userId', res.data.userId);
}
const reloadedVillageId = res.data.currentVillageId || 0;
uni.setStorageSync('currentVillageId', reloadedVillageId);
}
} catch (err) {
console.error('重新加载用户信息失败', err);
} finally {
uni.removeStorageSync('needReloadUserInfo');
}
}
getCurrentCommunityData();
getNoticeData()
getNewActivityList()
getbannarData()
@@ -294,7 +306,7 @@ onShow(() => {
// 检测到切换账号:重置数据并重新加载
if (lastUserId.value && lastUserId.value !== currentUserId) {
// 切换账号时重置页面数据
currentCommunity.value = '请认证小区'
currentCommunity.value = '请先绑定房屋'
currentVillageId.value = ''
activityList.value = []
bannerList.value = []
@@ -348,8 +360,8 @@ const navigateToPage = () => {
const cachedVillageId = uni.getStorageSync('currentVillageId');
// 未登录 或 未绑定小区 → 去我的页面认证
if ( !cachedVillageId || cachedVillageId === '0' || cachedVillageId === 0) {
currentCommunity.value = '请去认证小区';
uni.setStorageSync('currentCommunity', '请去认证小区');
currentCommunity.value = '请先绑定房屋';
uni.setStorageSync('currentCommunity', '请先绑定房屋');
uni.showToast({
title: '请先绑定小区',
icon: 'none',

View File

@@ -54,11 +54,11 @@
icon:'https://wuyeadmin.bugtc.com/images/propertyImgs/house.png',
title: "我的房屋"
},
{
icon: "https://wuyeadmin.bugtc.com/images/propertyImgs/user.png",
title: "住户管理",
// desc: "您可以在这里添加家人、朋友、租客~"
},
// {
// icon: "https://wuyeadmin.bugtc.com/images/propertyImgs/user.png",
// title: "住户管理",
// // desc: "您可以在这里添加家人、朋友、租客~"
// },
{
icon: "https://wuyeadmin.bugtc.com/images/propertyImgs/parking.png",
title: "我的车位"