<template>
  <view class="page">
    <base-background />
    <!-- 使用自定义导航栏组件 -->
    <custom-navbar ref="customNavbar" title="活动报名" />
    <view :style="{ backgroundColor: CommonEnum.BASE_COLOR }" class="header">
      <!-- 页面内容将在这里添加 -->
      <text>选择活动日期</text>
      <scroll-view class="scroll-view" scroll-x="true">
        <view class="scroll-view-item_date">A</view>
        <view class="scroll-view-item_date">B</view>
        <view class="scroll-view-item_date">C</view>
      </scroll-view>
      <text>选择活动时段</text>
      <scroll-view class="scroll-view" scroll-x="true">
        <view class="scroll-view-item_time">A</view>
        <view class="scroll-view-item_time">B</view>
        <view class="scroll-view-item_time">C</view>
      </scroll-view>
      <text>参与活动人数</text>
      <scroll-view class="scroll-view" scroll-x="true">
        <view class="scroll-view-item_number">1人</view>
        <view class="scroll-view-item_number">2人</view>
        <view class="scroll-view-item_number">自定义</view>
      </scroll-view>
    </view>
    <view class="contact">
      <view class="contact-item">
        <view class="info">姓名</view>
        <input placeholder="请输入姓名" type="text" />
      </view>
      <view class="contact-item">
        <view class="info">联系号码</view>
        <input placeholder="填写手机号" type="text" />
      </view>
    </view>
    <view class="submit">
      <view class="submit-message">100</view>
      <view class="submit-button">提交报名</view>
    </view>
  </view>
</template>

<script>
import { CommonEnum } from "@/enum/common.js";
import { MonkEnum } from "@/enum/monk.js";
import { getMonkList } from "@/api/monk/monk.js";

import SearchBox from "../../components/search-box/search-box.vue";

export default {
  components: {
    MonkSearchBox: SearchBox,
  },
  data() {
    return {
      bgc: {
        backgroundColor: "#F5F0E7",
      },
      CommonEnum,
      MonkEnum,
      monkList: [],
      searchName: "",
    };
  },
  onLoad() {
    this.fetchMonkList();
  },
  methods: {
    async fetchMonkList() {
      try {
        const res = await getMonkList({ name: this.searchName });
        if (res.code === 200 && Array.isArray(res.rows)) {
          this.monkList = res.rows;
        } else {
          uni.showToast({
            title: res.msg || "获取失败",
            icon: "none",
          });
        }
      } catch (e) {
        uni.showToast({
          title: "网络错误",
          icon: "none",
        });
      }
    },

    // 去除 HTML 标签，返回纯文本
    stripHtmlTags(html) {
      if (!html) return ""; // 处理空值
      return html.replace(/<[^>]+>/g, ""); // 正则替换所有 HTML 标签
    },
  },
};
</script>

<style lang="scss" scoped>
.page {
  width: 100%;
  display: flex;
  align-items: center;
  flex-direction: column;

  .header {
    width: 650rpx;
    margin-top: 24rpx;
    height: 726rpx;
    display: flex;
    align-items: flex-start;
    flex-direction: column;
    padding: 38rpx 50rpx 50rpx 50rpx;
    background: #fffbf5;
    border-radius: 20rpx 20rpx 20rpx 20rpx;
    border: 2rpx solid #c7a26d;
    margin-bottom: 40rpx;

    .scroll-view {
      display: flex;
      justify-content: space-between;
      white-space: nowrap;
      width: 100%;
      margin-bottom: 62rpx;

      .scroll-view-item_date {
        text-align: center;
        line-height: 120rpx;
        display: inline-block;
        width: 162rpx;
        height: 120rpx;
        background: #fff1dd;
        border-radius: 14rpx 14rpx 14rpx 14rpx;
        margin-right: 32rpx;
        font-weight: 700;
        font-size: 28rpx;
        color: #c7a26d;
      }

      .scroll-view-item_time {
        text-align: center;
        line-height: 120rpx;
        display: inline-block;
        width: 258rpx;
        height: 120rpx;
        background: #fff1dd;
        border-radius: 14rpx 14rpx 14rpx 14rpx;
        margin-right: 34rpx;
        font-weight: 700;
        font-size: 30rpx;
        color: #c7a26d;
      }

      .scroll-view-item_number {
        text-align: center;

        line-height: 64rpx;
        display: inline-block;
        width: 170rpx;
        height: 64rpx;
        background: #fff1dd;
        border-radius: 48rpx 48rpx 48rpx 48rpx;
        border: 2rpx solid #c7a26d;
        margin-right: 18rpx;
        font-weight: 400;
        font-size: 32rpx;
        color: #c7a26d;
      }
    }
  }

  .contact {
    width: 650rpx;
    height: 232rpx;
    background: #fffbf5;
    border-radius: 20rpx 20rpx 20rpx 20rpx;
    border: 2rpx solid #c7a26d;
    padding: 0 50rpx 0 54rpx;
    margin-bottom: 292rpx;

    .contact-item {
      width: 100%;
      height: 116rpx;
      display: flex;
      justify-content: space-between;
      align-items: center;
      border-bottom: 1px solid #d8d8d8;

      .info {
        font-weight: 400;
        font-size: 32rpx;
        color: #695347;
        line-height: 44rpx;
        text-align: center;
      }
    }
  }

  .submit {
    width: 650rpx;
    height: 92rpx;
    background: #fffbf5;
    border-radius: 57rpx 57rpx 57rpx 57rpx;
    border: 2rpx solid #c7a26d;
    display: flex;
    justify-content: space-between;
    align-items: center;

    .submit-message {
      font-weight: 500;
      font-size: 28rpx;
      color: #695347;
      line-height: 38rpx;
      margin-left: 62rpx;
    }

    .submit-button {
      width: 224rpx;
      height: 72rpx;
      background: #a24242;
      border-radius: 57rpx 57rpx 57rpx 57rpx;
      font-weight: 500;
      font-size: 28rpx;
      color: #ffffff;
      line-height: 72rpx;
      text-align: center;
      margin-right: 10rpx;
    }
  }
}

text {
  font-weight: 400;
  font-size: 32rpx;
  color: #695347;
  line-height: 44rpx;
  text-align: center;
  margin-bottom: 26rpx;
}
</style>
