修改切换账号绑定小区

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

@@ -138,7 +138,7 @@ const statusBarHeight = ref(uni.getSystemInfoSync().statusBarHeight || 0)
// 筛选条件status ''全部, '0'未开始, '1'进行中, '2'已结束 // 筛选条件status ''全部, '0'未开始, '1'进行中, '2'已结束
const filters = ref([ const filters = ref([
{ label: '审核中', value: '' }, { label: '全部', value: '' },
{ label: '未开始', value: '0' }, { label: '未开始', value: '0' },
{ label: '进行中', value: '1' }, { label: '进行中', value: '1' },
{ label: '已结束', value: '2' } { label: '已结束', value: '2' }

View File

@@ -269,7 +269,7 @@ const submitStatus = async () => {
}, 1500); }, 1500);
} catch (err) { } catch (err) {
uni.hideLoading(); uni.hideLoading();
uni.showToast({ title: err || '提交失败', icon: 'none' }); uni.showToast({ title: err.msg || '提交失败', icon: 'none' });
} }
}; };
</script> </script>

View File

@@ -47,6 +47,10 @@ export const getVillageSwitch = (data)=>{
export const getActivitylatest = () =>{ export const getActivitylatest = () =>{
return get('/api/resident/activity/latest') return get('/api/resident/activity/latest')
} }
// 重新加载用户信息
export const getReloadUserInfo = () =>{
return get('/api/resident/auth/reloadUserInfo')
}
// ========公告列表====== // ========公告列表======
// 获取公告列表 // 获取公告列表

View File

@@ -1,6 +1,6 @@
let baseUrl = ''; let baseUrl = '';
if (process.env.NODE_ENV === 'development') { if (process.env.NODE_ENV === 'development') {
baseUrl = 'http://192.168.0.239:8080'; // 开发环境 baseUrl = 'http://192.168.1.222:8080'; // 开发环境
} else { } else {
baseUrl = 'http://192.168.0.224:8080'; // 生产环境 baseUrl = 'http://192.168.0.224:8080'; // 生产环境
} }

View File

@@ -1,5 +1,5 @@
// 服务器地址(与 request.js 保持一致) // 服务器地址(与 request.js 保持一致)
const baseUrl = 'http://192.168.0.239:8080'; const baseUrl = 'http://192.168.1.222:8080';
/** /**
* 图片上传 Hook * 图片上传 Hook

View File

@@ -155,6 +155,7 @@ const getVerifyCode = () => {
}); });
} }
}).catch(err => { }).catch(err => {
uni.hideLoading();
uni.showToast({ uni.showToast({
title: '网络异常', title: '网络异常',
icon: 'error' icon: 'error'
@@ -195,6 +196,7 @@ const handleLogin = () => {
} }
getLoginBySms(params).then(res =>{ getLoginBySms(params).then(res =>{
if(res.code === 200){ if(res.code === 200){
uni.hideLoading();
if(res.data){ if(res.data){
uni.setStorageSync('token', res.data.token); uni.setStorageSync('token', res.data.token);
// 存用户ID // 存用户ID
@@ -219,6 +221,7 @@ const handleLogin = () => {
} }
}).catch(err => { }).catch(err => {
uni.hideLoading();
uni.showToast({ uni.showToast({
title: err.msg || '网络异常,请重试', title: err.msg || '网络异常,请重试',
icon: 'error' icon: 'error'

View File

@@ -163,6 +163,7 @@ const handleLogin = () => {
}).catch(err => { }).catch(err => {
// console.log('密码登录异常',err) // console.log('密码登录异常',err)
uni.hideLoading();
uni.showToast({ uni.showToast({
title: err.msg || '网络异常', title: err.msg || '网络异常',
icon: 'error' icon: 'error'

View File

@@ -261,6 +261,7 @@
}); });
} }
}).catch((err) => { }).catch((err) => {
uni.hideLoading();
uni.showToast({ uni.showToast({
title: err.msg || '网络异常', title: err.msg || '网络异常',
icon: 'error' icon: 'error'

View File

@@ -449,7 +449,7 @@
} }
} catch (err) { } catch (err) {
uni.showToast({ uni.showToast({
title: `${err}`, title: err.msg || '网络异常',
icon: 'none' icon: 'none'
}) })
} finally { } finally {
@@ -694,7 +694,7 @@
const params = { const params = {
villageId: uni.getStorageSync('communityId'), villageId: uni.getStorageSync('communityId'),
buildingId: uni.getStorageSync('buildingId'), buildingId: uni.getStorageSync('buildingId'),
unitNo: uni.getStorageSync('unitId'), unitNoId: uni.getStorageSync('unitId'),
floorNo: uni.getStorageSync('floorId'), floorNo: uni.getStorageSync('floorId'),
houseNo: uni.getStorageSync('houseNumberName'), houseNo: uni.getStorageSync('houseNumberName'),
houseId: uni.getStorageSync('houseNumberId'), houseId: uni.getStorageSync('houseNumberId'),
@@ -727,6 +727,8 @@
title: '提交成功', title: '提交成功',
icon: 'success' icon: 'success'
}) })
// 标记需要从绑定房屋返回首页后重新加载用户信息
uni.setStorageSync('needReloadUserInfo', true)
setTimeout(() => { setTimeout(() => {
goBack() goBack()
}, 1500) }, 1500)

View File

@@ -187,8 +187,8 @@
buildingId: selectedBuilding.value buildingId: selectedBuilding.value
}) })
const newList = res.data.map(item => ({ const newList = res.data.map(item => ({
id: item, id: item.id,
name: item name: item.name
})) }))
dataList.value = newList dataList.value = newList

View File

@@ -382,6 +382,7 @@ const submitForm = async () => {
const res = await addQueryRepair(params) const res = await addQueryRepair(params)
if (res.code === 200) { if (res.code === 200) {
uni.hideLoading();
uni.showToast({ title: '提交成功', icon: 'success' }) uni.showToast({ title: '提交成功', icon: 'success' })
form.value = { title: '', desc: '', phone: '', datetime: '', images: [] } form.value = { title: '', desc: '', phone: '', datetime: '', images: [] }
houseName.value = '' houseName.value = ''

View File

@@ -200,6 +200,7 @@ const submitForm = async () => {
const res = await addQueryRepair(params) const res = await addQueryRepair(params)
if (res.code === 200) { if (res.code === 200) {
uni.hideLoading();
uni.showToast({ title: '提交成功', icon: 'success' }) uni.showToast({ title: '提交成功', icon: 'success' })
// const tempProjectId = projectId.value // const tempProjectId = projectId.value
form.value = { title: '', desc: '', phone: '', images: [] } form.value = { title: '', desc: '', phone: '', images: [] }

View File

@@ -33,7 +33,7 @@
<view class="img-scroll-container"> <view class="img-scroll-container">
<view v-for="(img, imgIndex) in item.imgList" :key="imgIndex" class="img-item"> <view v-for="(img, imgIndex) in item.imgList" :key="imgIndex" class="img-item">
<image :src="img" mode="widthFix" class="card-img"></image> <image :src="img" mode="aspectFill" class="card-img"></image>
</view> </view>
</view> </view>

View File

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

View File

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