<template>
  <view class="plan-container">
    
    <!-- 加载动画 -->
    <view class="loading-container" v-if="loading">
      <uv-loading-icon text="加载中..." size="28"></uv-loading-icon>
    </view>
    
    <!-- 主体内容 -->
    <view class="main-content" v-if="!loading">
      
      <!-- 内容卡片 -->
      <view class="content-card">
        <!-- 富文本内容 -->
        <view class="rich-text-container">
          <!-- <rich-text :nodes="richTextContent"></rich-text> -->
          <uv-parse :content="richTextContent" :tagStyle="style" :lazyLoad="true" ></uv-parse>
        </view>
      </view>
    </view>
    
    <!-- 底部固定报名栏 -->
    <view class="bottom-bar" v-if="!loading && (type === 1 || type === '1')">
      <uv-button 
        type="primary" 
        text="报名" 
        :custom-style="{
          width: '100%',
          height: '82rpx',
          borderRadius: '44rpx',
          backgroundColor: '#06DADC',
          fontSize: '36rpx',
          fontWeight: '500',
          border: '1px solid  #06DADC'
        }"
        @click="handleSignUp"
      ></uv-button>
      <uv-safe-bottom></uv-safe-bottom>
    </view>
    
    <!-- 底部安全区域 -->
  </view>
</template>

<script>
export default {
  data() {
    return {
      loading: true, // 初始加载状态
      richTextContent: '',
      // richTextContent: `
      //   <div style="padding: 0;">
      //     <div style="margin-bottom: 40rpx; padding: 40rpx; background: #f8f9fa; ">
      //       <h3 style="font-size: 36rpx; font-weight: bold; color: #333; margin: 0 0 20rpx 0;">灵活设置</h3>
      //       <p style="font-size: 28rpx; color: #666; line-height: 1.6; margin: 0 0 30rpx 0;">语音合成支持中文、英文、粤语、四川话，也可以合成中英混读语音；</p>
      //       <div style="width: 100%; height: 300rpx;  overflow: hidden; background: #eee;">
      //         <img src="/static/default-image.png" style="width: 100%; height: 100%; object-fit: cover; " />
      //       </div>
      //     </div>
      //     <div style="padding: 40rpx; background: #f8f9fa; ">
      //       <h3 style="font-size: 36rpx; font-weight: bold; color: #333; margin: 0 0 20rpx 0;">高拟真度</h3>
      //       <p style="font-size: 28rpx; color: #666; line-height: 1.6; margin: 0 0 30rpx 0;">基于业界领先技术构建的语音合成系统，具备合成速度快、合成语音自然流畅等特点，合成语音拟真度高，能够符合多样化的应用场景，让设备和应用轻松发声，人机语音交互效果更加逼真。</p>
      //       <div style="width: 100%; height: 300rpx;  overflow: hidden; background: #eee;">
      //         <img src="/static/default-image.png" style="width: 100%; height: 100%; object-fit: cover; " />
      //       </div>
      //     </div>
      //   </div>
      // `,
      style: {
        img: 'borderRadius: 24rpx'
      },
      id: '',
      type: ''
    }
  },
  methods: {
    handleSignUp() {
      // console.log('点击报名')
      // 这里添加报名逻辑
      uni.navigateTo({
        url: '/subPages/home/submit?id=' + this.id 
      })
    },
  },
 
  async onShow() {
    this.loading = true;
    try{
      const askRes = await this.$api.home.getLinkDetails({
        id: this.id
      })
      if (askRes.code === 200){
        this.richTextContent = askRes.result.content
        this.type = askRes.result.type
      }
    } catch (error) {
      console.error('获取链接详情失败:', error)
    } finally {
      this.loading = false;
    }
  },

  onLoad(options) {
    this.id = options.id
    this.type = options.type
  },
}
</script>

<style scoped lang="scss">
.plan-container {
  background: #fff;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.loading-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
}

.main-content {
  flex: 1;
  padding: 40rpx 32rpx 120rpx;
}

.title-section {
  margin-bottom: 40rpx;
  
  .main-title {
    font-size: 48rpx;
    font-weight: 700;
    color: $primary-text-color;
    line-height: 1.3;
  }
}

.content-card {
  background: #F8F8F8;
  border-radius: 32rpx;
  // padding: 48rpx 32rpx;
  
  // .feature-section {
  //   margin-bottom: 60rpx;
    
  //   &:last-child {
  //     margin-bottom: 0;
  //   }
    
  //   .feature-title {
  //     display: block;
  //     font-size: 36rpx;
  //     font-weight: 700;
  //     color: $primary-text-color;
  //     margin-bottom: 24rpx;
  //   }
    
  //   .feature-desc {
  //     display: block;
  //     font-size: 28rpx;
  //     color: $secondary-text-color;
  //     line-height: 1.6;
  //     margin-bottom: 32rpx;
  //   }
    
  //   .feature-image {
  //     width: 100%;
  //     height: 320rpx;
  //     border-radius: 24rpx;
  //     overflow: hidden;
      
  //     image {
  //       width: 100%;
  //       height: 100%;
  //     }
  //   }
  // }
}

.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  padding: 24rpx 50rpx;
  // border-top: 1rpx solid #f0f0f0;
  z-index: 999;
}

// 富文本容器样式
.rich-text-container {
  width: 100%;
  border-radius: 36rpx;
  // img {
  //   border-radius: 24rpx;
  // }
}
</style>
