<template>
  <view class="content">
    <!-- 遮罩层 -->
    <view class="mask" v-if="showMenu" @click="toggleMenu"></view>

    <!-- 下拉菜单 -->
    <view class="dropdown-menu" v-if="showMenu">
      <view
        class="menu-item"
        v-for="(item, index) in menuItems"
        :key="index"
        @click="selectMenuItem(item)"
      >
        <text>{{ item }}</text>
      </view>
    </view>

    <u-navbar
      :is-back="true"
      title="上传图片"
      title-color="black"
      :background="{ backgroundColor: '#F7F8FC' }"
      :border-bottom="false"
    >
      <view slot="right">
        <view class="menu-wrapper">
          <image
            src="/static/iconfont/more.svg"
            mode="scaleToFill"
            style="width: 40rpx; height: 40rpx; margin-right: 32rpx"
            @click="toggleMenu"
          />
        </view>
      </view>
    </u-navbar>

    <view class="content-header">
      <view class="content-header-title"> 区域名称——所属计划 </view>
    </view>

    <view class="planList">
      <view class="plan-header">
        <text>请上传区域图片</text>
      </view>
      <view class="plan-content">
        <view class="plan-content-top">
          <image
            src="/static/images/logo.png"
            mode="scaleToFill"
            style="width: 160rpx; height: 160rpx"
          />
        </view>
        <view class="plan-content-remark">
          <view class="plan-content-remark-title">备注</view>
          <view class="plan-content-remark-text">
            备注备注备注备注备注备注备注备注备注备注备注备注备注
          </view>
        </view>
      </view>
    </view>

    <u-button
      class="bottom-btn"
      shape="circle"
      type="primary"
      style="margin: 0 32rpx"
      @click="submitForm"
      >上传</u-button
    >
  </view>
</template>

<script>
export default {
  data() {
    return {
      activeTab: "completed",
      showMenu: false,
      menuItems: ["教学楼楼道", "南广场跑道", "食堂大厅", "食堂大厅"],
    };
  },
  created() {},
  methods: {
    switchTab(tab) {
      this.activeTab = tab;
    },
    toggleMenu() {
      this.showMenu = !this.showMenu;
    },
    selectMenuItem(item) {
      // 处理菜单项选择
      console.log("选择了:", item);
      // 这里可以添加选择后的逻辑
      this.showMenu = false;
    },
  },
};
</script>

<style lang="scss" scoped>
.content {
  position: relative;
  height: 100vh;
  background: #f7f8fc;

  .mask {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.2);
    z-index: 999;
  }
  
  .content-header {
    height: 160rpx;
    background: #ddd;
    border-radius: 16rpx;
    margin: 32rpx;
    display: flex;
    flex-direction: column-reverse;

    &-title {
      font-size: 32rpx;
      color: #333;
      font-weight: 500;
      height: 60rpx;
      line-height: 60rpx;
      text-align: center;
      background-color: #fff;
      border-radius: 32rpx;
      width: 70%;
      margin: 0 auto 32rpx;
    }
  }
  .planList {
    margin: 0 32rpx;
    border-radius: 16rpx;
    background-color: #fff;

    .plan-header {
      font-size: 32rpx;
      color: #333;
      font-weight: 500;
      padding: 32rpx;
      border-bottom: 1px solid #f2f2f2;
    }
    .plan-content {
      padding: 32rpx;
      &-top {
        display: flex;
        justify-content: space-between;
        align-items: center;
        .place {
          font-size: 32rpx;
          color: #333;
        }
      }
      &-remark {
        margin-top: 32rpx;
        border-radius: 16rpx;
        &-title {
          font-size: 32rpx;
          color: #333;
          font-weight: 500;
        }
        &-text {
          font-size: 28rpx;
          color: #666;
          margin-top: 16rpx;
        }
      }
    }
    &.activeList {
      .plan-item {
        background: linear-gradient(
          to bottom,
          #fef7ec 0%,
          #fffdfa 30%,
          #ffffff 100%
        );
      }
    }
  }

  .bottom-btn {
    position: fixed;
    bottom: 32rpx;
    left: 0;
    right: 0;
  }
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20rpx 32rpx;
  position: relative;
}

.title {
  font-size: 36rpx;
  font-weight: 500;
}

.menu-wrapper {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: 80rpx;
  right: 32rpx;
  background-color: #ffffff;
  border-radius: 12rpx;
  box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.1);
  width: 280rpx;
  overflow: hidden;
  z-index: 1000;

  .menu-item {
    padding: 24rpx 32rpx;
    font-size: 28rpx;
    color: #333333;
    border-bottom: 1px solid #f5f5f5;

    .menu-item:last-child {
      border-bottom: none;
    }

    .menu-item:active {
      background-color: #f8f8f8;
    }
  }
}
</style>
