<!-- 关联人员页面 -->
<template>
  <s-layout title="关联人员">
    <view class="member-page">
      <scroll-view scroll-y class="member-list">
        <view 
          v-for="(item, index) in state.memberList" 
          :key="index" 
          class="member-item"
        >
          <!-- 左侧图标 -->
          <image class="member-icon" src="/static/img/yz-icon1.png" mode="aspectFit" />
          
          <!-- 中间信息 -->
          <text class="member-info">{{ item.role }}：{{ item.name }}</text>
          
          <!-- 右侧解除绑定（非业主显示） -->
          <text v-if="item.showUnbind" class="unbind-btn" @tap.stop="handleUnbind(item)">解除绑定</text>
        </view>

        <!-- 空状态 -->
        <view v-if="state.memberList.length === 0" class="empty-state">
          <text class="empty-text">暂无关联人员</text>
        </view>
      </scroll-view>

      <!-- 底部返回按钮 -->
      <view class="bottom-btn-wrapper">
        <button class="back-btn" @tap="goBack">返回</button>
      </view>
    </view>
  </s-layout>
</template>

<script setup>
import { reactive } from 'vue';

// 关联人员列表数据
const state = reactive({
  memberList: [
    { role: '业主', name: '王德福', showUnbind: false },
    { role: '业主家属', name: '王德福', showUnbind: true },
    { role: '租户', name: '王玉华', showUnbind: true },
  ]
});

// 解除绑定
const handleUnbind = (item) => {
  uni.showModal({
    title: '提示',
    content: `确定要解除与 ${item.name} 的关联吗？`,
    success: (res) => {
      if (res.confirm) {
        console.log('解除绑定:', item);
      }
    }
  });
};

// 返回上一页
const goBack = () => {
  uni.navigateBack();
};
</script>

<style lang="scss" scoped>
/* 页面容器 */
.member-page {
  background-color: #F5F5F5;
}

/* 列表区域 */
.member-list {
  height: calc(100vh - 176rpx - 150rpx);
  padding-top: 20rpx;
}

/* 单个成员项 */
.member-item {
  background-color: #FFFFFF;
  margin: 0 38rpx 24rpx;
  border-radius: 31rpx;
  padding: 28rpx 32rpx;
  display: flex;
  align-items: center;

  /* 左侧图标 */
  .member-icon {
    width: 40rpx;
    height: 40rpx;
    flex-shrink: 0;
    margin-right: 16rpx;
  }

  /* 角色和姓名 */
  .member-info {
    flex: 1;
    font-size: 28rpx;
    color: #333333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* 解除绑定按钮 */
  .unbind-btn {
    font-size: 26rpx;
    color: #FF6B35;
    flex-shrink: 0;
    margin-left: 16rpx;

    &:active {
      opacity: 0.7;
    }
  }
}

/* 空状态 */
.empty-state {
  display: flex;
  justify-content: center;
  padding: 120rpx 0;

  .empty-text {
    font-size: 28rpx;
    color: #999999;
  }
}

/* 底部按钮 */
.bottom-btn-wrapper {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 24rpx 38rpx;
  padding-bottom: calc(24rpx + env(safe-area-inset-bottom));
  background-color: #F5F5F5;

  .back-btn {
    width: 100%;
    height: 96rpx;
    background: linear-gradient(135deg, #FF8A65 0%, #FF6B35 100%);
    border-radius: 48rpx;
    border: none;
    font-size: 32rpx;
    font-weight: 500;
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8rpx 24rpx rgba(255, 107, 53, 0.3);

    &::after {
      border: none;
    }

    &:active {
      opacity: 0.9;
      transform: scale(0.98);
    }
  }
}
</style>
