<template>
  <view class="page__view">
		<navbar title="详情报告" leftClick @leftClick="$utils.navigateBack" color="#191919" bgColor="#FFFFFF" />

    <view class="main">
      <reportCard>
        <view class="section">
          <cardHeader :BMI="BMI"></cardHeader>
        </view>
        <view class="section" v-for="(step, index) in list" :key="step.key">
          <view class="flex section-header">
            <view class="section-header-index">
              <text>{{ index + 1 }}</text>
              <image class="section-header-index-icon" :src="step.url" mode="widthFix"></image>
            </view>
            <view class="section-header-title">
              <view class="section-header-title-zh">{{ step.name }}</view>
              <view class="section-header-title-en">{{ step.nameEn }}</view>
            </view>
          </view>
          <view class="section-content">
            <template v-if="step.key === 'improvementGoal'">
              <view class="tags">
                <view class="tag" v-for="(item, tIdx) in step.tags" :key="tIdx">{{ item }}</view>
              </view>
            </template>
            <template v-else-if="step.key === 'topPriority'">
              <view class="tags">
                <view class="tag highlight">{{ step.tag }}</view>
              </view>
            </template>
            <template v-else-if="step.key === 'potentialHealthIssues'">
              <view class="flex section-content-tag">
                <image class="section-content-tag-icon" :src="step.tag.icon" mode="widthFix"></image>
                <text class="section-content-tag-text">{{ step.tag.text }}</text>
              </view>
              <view>
                <view class="section-content-item" v-for="(item, idx) in step.content" :key="idx">
                  <view class="flex section-content-item-header">
                    <view class="section-content-item-index">{{ `${idx + 1}.` }}</view>
                    <view class="section-content-item-title">{{ item.title }}</view>
                  </view>
                  <view class="section-content-item-detail">{{ item.detail }}</view>
                </view>
              </view>
            </template>
            <template v-else>
              <view>
                <view class="section-content-item" v-for="(item, idx) in step.content" :key="idx">
                  <view class="flex section-content-item-header">
                    <view class="section-content-item-index">{{ `${idx + 1}.` }}</view>
                    <view class="section-content-item-title">{{ item.title }}</view>
                  </view>
                  <view class="section-content-item-detail">{{ item.detail }}</view>
                </view>
              </view>
            </template>
          </view>
        </view>
        <view class="section tips">
          *以上是根据你的营养目标以及饮食、运动、作息状况给出的针对性健康建议，可以辅助你达成营养目标，同时养成良好的生活习惯。
        </view>
      </reportCard>
    </view>

    <view class="bottom">
      <button class="flex btn" @click="jumpToNutritionProgram">查看营养方案</button>
    </view>
  </view>
</template>

<script>
  import reportCard from '@/pages_order/components/reportCard.vue';
  import cardHeader from './cardHeader.vue';

  export default {
		components: {
      reportCard,
      cardHeader,
    },
    data() {
      return {
        BMI: null,
        list: [],
      }
    },
    onLoad() {
      this.BMI = 16.5
      this.list = [
        { 
          id: '001', 
          key: 'improvementGoal', 
          name: '本次改善目标', 
          nameEn: 'This improvement goal', 
          url: '/pages_order/static/report/report-detail-1.png',
          tags: ['皮肤', '脑力/注意力', '眼睛/视力', '睡眠', '骨骼/关节'] 
        },
        { 
          id: '002', 
          key: 'topPriority', 
          name: '首要目标', 
          nameEn: 'Top priority', 
          url: '/pages_order/static/report/report-detail-2.png',
          tag: '脑力/注意力'
        },
        { 
          id: '003', 
          key: 'targetSuggestion', 
          name: '健康目标建议', 
          nameEn: 'Target Suggestion', 
          url: '/pages_order/static/report/report-detail-3.png',
          content: [
            { title: '吃一小把混合坚果对皮肤好', detail: '增加不饱和脂肪酸的摄入有益皮肤健康，可以每天食用一小把混合类坚果，例如核桃、葵花籽、开心果等。' },
          ]
        },
        { 
          id: '004', 
          key: 'dailyGoals', 
          name: '每日小目标', 
          nameEn: 'Daily Small Goals', 
          url: '/pages_order/static/report/report-detail-4.png',
          content: [
            { title: '每天吃1个水煮鸡蛋', detail: '每天食用1个鸡蛋可以补充丰富的动物蛋白以及多种维生素和矿物质，如维生素A、维生素D、 维生素B12、胆碱、叶酸、磷和碘等。' },
            { title: '今天的饭后甜点是低糖酸奶', detail: '每天食用1个鸡蛋可以补充丰富的动物蛋白以及多种维生素和矿物质，如维生素A、维生素D、 维生素B12、胆碱、叶酸、磷和碘等。' },
          ]
        },
        { 
          id: '005', 
          key: 'potentialHealthIssues', 
          name: '需要注意的潜在健康问题', 
          nameEn: 'Potential health issues to note', 
          url: '/pages_order/static/report/report-detail-5.png',
          tag: {
            text: '心血管问题',
            icon: '/pages_order/static/report/cardiovascular.png',
          },
          content: [
            { title: '影响因素', detail: '较少食用富含Omega3的食物（如：深海鱼，坚果）' },
            { title: '营养建议', detail: '建议每天吃一把坚果。' },
          ]
        },
        { 
          id: '006', 
          key: 'specialReminder', 
          name: '特殊提醒', 
          nameEn: 'Special Reminder', 
          url: '/pages_order/static/report/report-detail-6.png',
          content: [
            { title: '眼睛长时间感觉到干涩可能是干眼症，一般是由于泪腺泪液分泌不足导致的，严重的话请及时就医。' },
            { title: '同时使用不同品牌的膳食补剂容易导致营养素摄入过量， 请注意服用剂量，避免造成补剂摄入过量带来的副作用。' },
          ]
        },
        { 
          id: '007', 
          key: 'exerciseRest', 
          name: '运动 & 作息', 
          nameEn: 'Exercise & Rest', 
          url: '/pages_order/static/report/report-detail-7.png',
          content: [
            { title: '请尽量避免在阳光强烈的时段（通常是中午至下午3点）户外活动。在户外时，涂抹SPF（防晒系数）高的防晒霜在暴露的皮肤上，并穿着长袖衣物、帽子和太阳镜减少皮肤接触到紫外线的机会。' }
          ]
        },
        { 
          id: '008', 
          key: 'dietaryRecommendations', 
          name: '饮食建议', 
          nameEn: 'Dietary recommendations', 
          url: '/pages_order/static/report/report-detail-8.png',
          content: [
            { title: '一天不要超过三杯美式咖啡', detail: '健康成年人每天摄入的咖啡因应控制在400mg以内。1杯 355mL的小杯美式咖啡，所含咖啡因为150mg，所以一天最好不要饮用超过3小杯咖啡。' },
          ]
        },
      ]
    },
    methods: {
      jumpToNutritionProgram() {
        this.$utils.navigateTo(`/pages_order/report/nutritionProgram/index?id=${this.id}`)
      },
    },
  }
</script>

<style scoped lang="scss">
.page__view {
  width: 100vw;
  height: 100vh;
  background-color: $uni-bg-color;
  position: relative;
  
  /deep/ .nav-bar__view {
    position: fixed;
    top: 0;
    left: 0;
  }
}

.main {
  padding: calc(var(--status-bar-height) + 152rpx) 32rpx 272rpx 32rpx;
}

.section {
  & + & {
    margin-top: 48rpx;
    padding-top: 12rpx;
    border-top: 2rpx dashed #989898;
  }

  &-header {
    justify-content: flex-start;

    &-index {
      position: relative;
      font-family: HarmonyOS Sans;
      font-weight: 700;
      font-size: 96rpx;
      line-height: 1.4;
      color: #D9D9D9;

      &-icon {
        position: absolute;
        left: 34rpx;
        top: 70rpx;
        width: 40rpx;
        height: 40rpx;
      }
    }

    &-title {
      margin-left: 32rpx;
      font-family: PingFang SC;
      line-height: 1.4;
      color: #252545;

      &-zh {
        font-weight: 600;
        font-size: 40rpx;
      }

      &-en {
        font-weight: 400;
        font-size: 26rpx;
      }
    }
  }

  &-content {
    padding-top: 18rpx;

    &-item {
      font-family: PingFang SC;
      font-weight: 400;
      line-height: 1.5;
      color: #252545;

      & + & {
        margin-top: 24rpx;
      }

      &-header {
        align-items: flex-start;
        justify-content: flex-start;
      }

      &-index {
        display: inline-block;
        width: 44rpx;
        font-size: 24rpx;
        text-align: right;
        line-height: 44rpx;
        padding-right: 10rpx;
        box-sizing: border-box;
      }
      &-title {
        font-size: 28rpx;
      }
      &-detail {
        margin-top: 8rpx;
        font-size: 24rpx;
        color: #989898;
      }
    }

    &-tag {
      margin-bottom: 24rpx;
      padding: 16rpx 0;
      background: #E5E4EB8C;
      border-radius: 16rpx;
      column-gap: 16rpx;

      &-icon {
        width: 40rpx;
        height: 40rpx;
      }

      &-text {
        font-family: PingFang SC;
        font-weight: 400;
        font-size: 28rpx;
        line-height: 1.5;
        color: #252545;
      }
    }
  }
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 16rpx;

  .tag {
    padding: 8rpx 40rpx;
    font-family: PingFang SC;
    font-weight: 400;
    font-size: 28rpx;
    line-height: 1.5;
    color: #252545;
    background: #E5E4EB;
    border-radius: 30rpx;

    &.highlight {
      font-weight: 600;
      color: #FFFFFF;
      background: #252545;
    }
  }
}

.section.tips {
  padding-top: 48rpx;
  font-family: PingFang SC;
  font-weight: 400;
  font-size: 18rpx;
  line-height: 1.4;
  color: #989898;
}

.bottom {
  width: 100%;
  position: fixed;
  left: 0;
  bottom: 0;
  padding: 24rpx 40rpx 92rpx 40rpx;
  box-sizing: border-box;
  background: #FFFFFF;

  .btn {
    padding: 16rpx 0;
    font-family: PingFang SC;
    font-size: 36rpx;
    font-weight: 500;
    line-height: 1;
    color: #FFFFFF;
    background-image: linear-gradient(to right, #4B348F, #845CFA);
    border-radius: 41rpx;
  }
}
</style>