feat: 实现关联人员列表及解绑功能

main
cr 2026-04-25 01:13:11 +08:00
parent bd1c6a9596
commit cc87e84cbc
2 changed files with 109 additions and 31 deletions

View File

@ -4,22 +4,33 @@
<view class="member-page">
<scroll-view scroll-y class="member-list">
<view
v-for="(item, index) in state.memberList"
:key="index"
v-for="(item, index) in memberList"
:key="item.id || index"
class="member-item"
>
<!-- 左侧图标 -->
<image class="member-icon" src="/static/img/yz-icon1.png" mode="aspectFit" />
<!-- 左侧头像 -->
<image
class="member-avatar"
:src="item.facePhotoUrl || '/static/img/person.png'"
mode="aspectFill"
/>
<!-- 中间信息 -->
<text class="member-info">{{ item.role }}{{ item.name }}</text>
<view class="member-info-wrap">
<text class="member-name">{{ item.name }}</text>
<text class="member-role">{{ item.relationDesc }}</text>
</view>
<!-- 右侧解除绑定非业主显示 -->
<text v-if="item.showUnbind" class="unbind-btn" @tap.stop="handleUnbind(item)"></text>
<text
v-if="!item.isOwner"
class="unbind-btn"
@tap.stop="handleUnbind(item)"
>解除绑定</text>
</view>
<!-- 空状态 -->
<view v-if="state.memberList.length === 0" class="empty-state">
<view v-if="memberList.length === 0" class="empty-state">
<text class="empty-text">暂无关联人员</text>
</view>
</scroll-view>
@ -33,25 +44,45 @@
</template>
<script setup>
import { reactive } from 'vue';
import { ref } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import MemberApi from '@/sheep/api/community/member';
import sheep from '@/sheep';
//
const state = reactive({
memberList: [
{ role: '业主', name: '王德福', showUnbind: false },
{ role: '业主家属', name: '王德福', showUnbind: true },
{ role: '租户', name: '王玉华', showUnbind: true },
]
//
const memberList = ref([]);
// ID
const houseId = ref(null);
//
onLoad((options) => {
// ID
houseId.value = options.houseId || sheep.$store('user').userInfo.currentHouseId;
if (houseId.value) {
loadMemberList();
}
});
//
async function loadMemberList() {
const { code, data } = await MemberApi.getRelationList(houseId.value);
if (code === 0 && Array.isArray(data)) {
memberList.value = data;
}
}
//
const handleUnbind = (item) => {
uni.showModal({
title: '提示',
content: `确定要解除与 ${item.name} 的关联吗?`,
success: (res) => {
success: async (res) => {
if (res.confirm) {
console.log('解除绑定:', item);
const { code, data } = await MemberApi.unbind(item.id);
if (code === 0 && data) {
uni.showToast({ title: '解除成功', icon: 'success' });
loadMemberList();
}
}
}
});
@ -84,22 +115,39 @@ const goBack = () => {
display: flex;
align-items: center;
/* 左侧图标 */
.member-icon {
width: 40rpx;
height: 40rpx;
/* 左侧头像 */
.member-avatar {
width: 72rpx;
height: 72rpx;
border-radius: 50%;
flex-shrink: 0;
margin-right: 16rpx;
margin-right: 20rpx;
background-color: #F5F5F5;
}
/* 角色和姓名 */
.member-info {
/* 信息区域 */
.member-info-wrap {
flex: 1;
font-size: 28rpx;
color: #333333;
display: flex;
flex-direction: column;
justify-content: center;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
/* 姓名 */
.member-name {
font-size: 30rpx;
color: #333333;
font-weight: 500;
line-height: 1.4;
}
/* 角色 */
.member-role {
font-size: 24rpx;
color: #999999;
margin-top: 4rpx;
line-height: 1.4;
}
/* 解除绑定按钮 */

View File

@ -0,0 +1,30 @@
import request from '@/sheep/request';
const MemberApi = {
// 查询关联人员列表
getRelationList: (houseId) => {
return request({
url: '/community/member-house/relation-list',
method: 'GET',
data: { houseId },
custom: {
showLoading: true,
auth: true,
},
});
},
// 解除绑定
unbind: (id) => {
return request({
url: '/community/member-house/unbind',
method: 'DELETE',
data: { id },
custom: {
showLoading: true,
auth: true,
},
});
},
};
export default MemberApi;