银联支付集成和购买插件;修改首页小区更改后获取数据;对接我的信息接口

This commit is contained in:
zhouyanli
2026-06-04 17:42:29 +08:00
parent 4d0515e5fe
commit a8e3d1f875
11 changed files with 409 additions and 324 deletions

View File

@@ -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()
})
// 页面销毁时移除监听(防止内存泄漏)

View File

@@ -6,7 +6,7 @@
<scroll-view class="page" scroll-y>
<view class="topBox">
<view class="name">
<image src="http://47.104.199.163:9090/images/propertyImgs/touxiang.jpg" class="img" />
<image :src="avatar" class="img" />
<span style="padding: 5rpx 5rpx;display: flex;flex-direction: column;line-height: 60rpx;">
<span style="font-size: 36rpx;font-weight: 600;">
{{loginName}}
@@ -28,7 +28,7 @@
style="align-self: flex-end;font-size: 24rpx;vertical-align: baseline;">{{ item.desc }}</span></span>
</view>
<view class="item-arrow"></view>
<!-- <image src="http://47.104.199.163:9090/images/propertyImgs/arrow-right.png" class="arrow-icon" /> -->
<!-- <image src="https://wuyeadmin.bugtc.com/images/propertyImgs/arrow-right.png" class="arrow-icon" /> -->
</view>
</view>
@@ -46,32 +46,35 @@
import {
ref
} from 'vue';
import { getUserProfile } from '../../pageSubPack/api/apiSub';
import {onShow} from '@dcloudio/uni-app'
const list = ref([{
icon: "http://47.104.199.163:9090/images/propertyImgs/house.png",
icon:'https://wuyeadmin.bugtc.com/images/propertyImgs/house.png',
title: "我的房屋"
},
{
icon: "http://47.104.199.163:9090/images/propertyImgs/user.png",
icon: "https://wuyeadmin.bugtc.com/images/propertyImgs/user.png",
title: "住户管理",
// desc: "您可以在这里添加家人、朋友、租客~"
},
{
icon: "http://47.104.199.163:9090/images/propertyImgs/parking.png",
icon: "https://wuyeadmin.bugtc.com/images/propertyImgs/parking.png",
title: "我的车位"
},
{
icon: "http://47.104.199.163:9090/images/propertyImgs/car.png",
icon: "https://wuyeadmin.bugtc.com/images/propertyImgs/car.png",
title: "我的车辆"
},
{
icon: "http://47.104.199.163:9090/images/propertyImgs/setting.png",
icon: "https://wuyeadmin.bugtc.com/images/propertyImgs/setting.png",
title: "设置"
}
])
const loginName = ref("wangh")
const phoneNum = ref('156*****1212')
const loginName = ref("")
const phoneNum = ref('')
const avatar = ref('')
// --方法----
const goToDetail = () => {
@@ -79,6 +82,19 @@
url: '/pageSubPack/notice-list/noticeListDetails'
})
}
// 获取用户账号信息
function getUserInfoData(){
getUserProfile().then(res => {
if (res.code === 200 && res.data) {
avatar.value = res.data.avatar
loginName.value = res.data.username
phoneNum.value = res.data.phone || ''
}
})
}
// 返回
const onItemClick = (item) => {
if (item.title == '我的房屋') {
@@ -121,6 +137,9 @@
complete: () => {}
});
}
onShow(() =>{
getUserInfoData()
})
</script>