<template>
    <view class="container" style="paddingBottom:1rpx;">
      <u-navbar
			leftIconSize="40rpx"
			leftIconColor="#333333"
			title="心路历程详情"
		>
		</u-navbar>
      <view class="detail-card">
        <view class="card-header">
          <view class="card-title">
            <uni-icons type="heart" size="20" color="#fff"></uni-icons>
            <text class="card-name">{{ detailInfo.name }}</text>
          </view>
        </view>

        <view class="section">
          <view class="section-title">
            <view class="title-icon"></view>
            <text>基本信息</text>
          </view>
          <view class="info-grid">
            <view class="info-item">
              <text class="info-label">类型</text>
              <text class="info-value">{{ detailInfo.type || '-' }}</text>
            </view>
            <view class="info-item">
              <text class="info-label">记录时间</text>
              <text class="info-value">{{ detailInfo.createTime || '-' }}</text>
            </view>
          </view>
        </view>

        <view class="section" v-if="detailInfo.remark">
          <view class="section-title">
            <view class="title-icon"></view>
            <text>内容</text>
          </view>
          <view class="remark-content">
            <text>{{ detailInfo.remark }}</text>
          </view>
        </view>
      </view>
      <u-toast ref="uToast"></u-toast>
    </view>
  </template>
  
<script setup>
import { getHeartJourney} from '@/api/invest/heartJourney'
import { getDicts } from '@/api/system/dict/data.js'
import {onLoad} from "@dcloudio/uni-app";
import {reactive ,toRefs,ref,computed }from "vue";
const id = ref('')
const data = reactive({
  detailInfo: {} 
})
const {detailInfo} = toRefs(data)
onLoad((option) => {
    id.value = option.id
    getInfo()
  })
  function getInfo() {
    getHeartJourney(id.value).then(res => {
          detailInfo.value = res.data
                     // 类型
            getDicts('journey_type').then(result => {
         detailInfo.value.type=dictStr(detailInfo.value.type, result.data)
      })
        })
  }
  function dictStr(val, arr) {
      let str = ''
      arr.map(item => {
        if (item.dictValue === val) {
          str = item.dictLabel
        }
      })
      return str
    }
  </script>
  
  <style lang="scss" scoped>
  .detail-card {
    margin: 24rpx;
    background-color: #fff;
    border-radius: 12rpx;
    overflow: hidden;
    box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.08);

    .card-header {
      background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
      padding: 12rpx 20rpx;
      display: flex;
      justify-content: space-between;
      align-items: center;

      .card-title {
        display: flex;
        align-items: center;
        gap: 8rpx;

        .card-name {
          color: #fff;
          font-size: 28rpx;
          font-weight: bold;
          line-height: 1;
        }
      }
    }

    .section {
      padding: 32rpx;
      border-bottom: 1rpx solid #f0f0f0;

      &:last-child {
        border-bottom: none;
      }

      .section-title {
        display: flex;
        align-items: center;
        gap: 12rpx;
        margin-bottom: 24rpx;
        font-size: 32rpx;
        font-weight: bold;
        color: #333;

        .title-icon {
          width: 6rpx;
          height: 32rpx;
          background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
          border-radius: 3rpx;
        }
      }

      .info-grid {
        display: flex;
        flex-direction: column;
        gap: 24rpx;

        .info-item {
          display: flex;
          justify-content: space-between;
          align-items: center;

          .info-label {
            font-size: 28rpx;
            color: #999;
          }

          .info-value {
            font-size: 28rpx;
            color: #333;
            font-weight: 500;
          }
        }
      }

      .remark-content {
        font-size: 28rpx;
        color: #666;
        line-height: 1.6;
        text-align: justify;
      }
    }
  }
  </style>