<view class="fullscreen-bg">
  <t-navbar title="{{name}}" left-arrow />
  <scroll-view class="page-scroll__container" scroll-y>
    <block wx:if="{{!loading}}">
      <!-- 调理中卡片 -->
      <view class="info-card card-content">
        <view class="status-tag">
          {{statusText}}
        </view>
        <view class="detail-container">
          <view class="detail-box">
            <view class="row"><text class="label">开具时间：</text>{{careDetail.createTime}}</view>
            <view class="row"><text class="label">开具医生：</text>{{careDetail.createBy}}</view>
            <view class="delivery" wx:if="{{careDetail.isDelivery==='Y'}}">
              <view style="margin-bottom:10px">
                <text class="label">配送：</text>
                <text>是</text>
              </view>
              <view class="address-block" wx:if="{{showAddress}}">
                <view>{{address}}</view>
                <view>
                  <text style="margin-right:10px" wx:if="{{careDetail.patientName || careDetail.liaison}}">
                    {{careDetail.patientName || careDetail.liaison}}</text>
                  <text wx:if="{{careDetail.phone}}">{{careDetail.phone}}</text>
                </view>
              </view>
            </view>
            <view class="row"><text class="label" wx:if="{{careDetail.cost}}">价格：</text>{{careDetail.cost}}元</view>
          </view>
        </view>
      </view>

      <view class="bottom-box">
        <!-- 健康状况卡片 -->
        <view class="info-card status-card">
          <view class="row row-box">
            <image class="icon" src="../../assets/icon/icon_health@2x.png" mode="heightFix" />
            <text class="card-title">健康状况</text>
          </view>
          <view class="content-box">
            <view class="row"><text class="label">程度：</text>{{careDetail.healthAnalysisReport.willillDegreeName}}</view>
            <view class="row"><text class="label">表现：</text>{{careDetail.healthAnalysisReport.willillFunctionName}}</view>
            <view class="row"><text class="label">体质：</text>{{careDetail.healthAnalysisReport.constitutionGroupName}}</view>
            <view class="row"><text class="label">证素：</text>{{careDetail.healthAnalysisReport.factorItemSummary}}</view>
            <view class="row"><text class="label">证型：</text>{{careDetail.healthAnalysisReport.diagnoseSyndromeSummary}}</view>
          </view>
        </view>
      </view>
      <!-- 调养方案 -->
      <view class="bottom-box">
        <view class="info-card status-card care-box">
          <view class="row row-box">
            <image class="icon" src="../../assets/icon/icon_scheme@2x.png" mode="heightFix" />
            <text class="card-title">调养方案</text>
          </view>
          <view wx:for="{{careDetail.items}}" wx:key="id">
            <!-- 线下操作-->
            <view class="scheme-card" wx:if="{{item.conditioningProgramDetail.sellType && item.conditioningProgramDetail.sellType==='2'}}">
              <view class="scheme-title" wx:if="{{item.conditioningProgramDetail && item.conditioningProgramDetail.name && item.conditioningProgramDetail.name!=='null'}}">{{item.conditioningProgramDetail.name}}</view>
              <view class="divider"></view>
              <view class="carousel-box" wx:if="{{item.carouselMediaList && item.carouselMediaList.length > 0}}">
                <view class="carousel-container">
                  <!-- 加载状态 -->
                  <view wx:if="{{carouselLoading[item.id]}}" class="carousel-loading">
                    <t-loading size="40rpx" text="加载中..." />
                  </view>
                  <!-- 轮播图 -->
                  <media-carousel wx:else mediaList="{{item.carouselMediaList}}" showIndicator="{{true}}" autoplay="{{true}}" interval="{{4000}}" circular="{{true}}" bind:imageload="onCarouselLoaded" bind:imageerror="onImageError" bind:videoerror="onVideoError" itemId="{{item.id}}" />
                </view>
              </view>
              <view class="scheme-row light"><text class="text-gray" wx:if="{{item.arrangeDate || item.arrangeDate!==null}}">下次时间：</text>{{item.arrangeDate}}</view>
              <view class="scheme-row between">
                <text>
                  <text class="text-gray">已完成：</text>
                  <text class="success">
                    <text>{{item.finishCount}}次</text>
                    <text style="margin:0 5px;color:black">/</text>
                    <text style="color:black">{{item.totalMeasure}}次</text>
                  </text>
                </text>
                <text class="link" bindtap="onRecord" data-id="{{item.id}}" wx:if="{{item.conditioningProgramDetail.sellType && item.conditioningProgramDetail.sellType==='2'}}">核销记录</text>
              </view>
              <view class="scheme-row">
                <text class="text-gray">频次：</text>
                每{{item.frequencyType}}天{{item.frequencyMeasure}}{{item.conditioningProgramDetail.cpFixedPricingRule.convertUnit || '次'}}
              </view>
              <view class="scheme-row">
                <text class="text-gray">机构：</text>
                {{item.conditioningProgramDetail.conditioningProgramSupplierName}}
              </view>
              <view class="scheme-bottom" wx:if="{{item.actualStartDate!=''}}">
                <text class="next-time" wx:if="{{item.arrangeDate}}">下一次时间：{{item.arrangeDate}}</text>
                <view class="link opt-box" bindtap="onOffline" data-id="{{item.id}}">
                  <t-icon name="app" size="24rpx" color="#1976d2" />
                  <text style="margin-left:10px">线下操作</text>
                </view>
              </view>
            </view>
            <!-- 线上操作 -->
            <view class="scheme-card" wx:if="{{item.conditioningProgramDetail.sellType && item.conditioningProgramDetail.sellType!=='2'}}">
              <view class="scheme-title">{{item.conditioningProgramDetail.name}}</view>
              <view class="divider"></view>
              <view class="carousel-box" wx:if="{{item.carouselMediaList && item.carouselMediaList.length > 0}}">
                <view class="carousel-container">
                  <!-- 加载状态 -->
                  <view wx:if="{{carouselLoading[item.id]}}" class="carousel-loading">
                    <t-loading size="40rpx" text="加载中..." />
                  </view>
                  <!-- 轮播图 -->
                  <media-carousel wx:else mediaList="{{item.carouselMediaList}}" showIndicator="{{true}}" autoplay="{{true}}" interval="{{4000}}" circular="{{true}}" bind:imageload="onCarouselLoaded" bind:imageerror="onImageError" bind:videoerror="onVideoError" itemId="{{item.id}}" />
                </view>
              </view>
              <view class="scheme-row light">
                <text class="text-gray">数量：</text>
                <text>{{item.totalMeasure}}{{item.pricingUnit}}</text>

              </view>
              <view class="scheme-row between">
                <text>
                  <text class="label between">频次：</text>
                  <text>每{{item.frequencyType}}天{{item.frequencyMeasure}}{{item.conditioningProgramDetail.cpFixedPricingRule.convertUnit}}</text>
                </text>
                <view class="link" bindtap="onCardRecord" data-id="{{item.id}}" wx:if="{{item.conditioningProgramDetail.sellType && item.conditioningProgramDetail.sellType!=='2'}}">打卡记录</view>

              </view>
              <view class="desc-row" wx:if="{{item.remark}}">
                <text class="label between">说明：</text>
                <text class="desc-label">{{item.remark || ''}}</text>
              </view>
            </view>
            <!-- 健康评估-->
            <view class="scheme-card" wx:if="{{item.conditioningProgramDetail.conditioningProgramType && item.conditioningProgramDetail.conditioningProgramType==='健康评估'}}">
              <view class="scheme-title">{{item.conditioningProgramDetail.name}}</view>
              <view class="divider"></view>
              <view class="carousel-box" wx:if="{{item.carouselMediaList && item.carouselMediaList.length > 0}}">
                <view class="carousel-container">
                  <!-- 加载状态 -->
                  <view wx:if="{{carouselLoading[item.id]}}" class="carousel-loading">
                    <t-loading size="40rpx" text="加载中..." />
                  </view>
                  <!-- 轮播图 -->
                  <media-carousel wx:else mediaList="{{item.carouselMediaList}}" showIndicator="{{true}}" autoplay="{{true}}" interval="{{4000}}" circular="{{true}}" bind:change="onCarouselChange" bind:imageload="onCarouselLoaded" bind:imageerror="onImageError" bind:videoplay="onVideoPlay" bind:videopause="onVideoPause" bind:videoended="onVideoEnded" bind:videoerror="onVideoError" itemId="{{item.id}}" />
                </view>
              </view>
              <view class="scheme-row between" style="margin-top:15px">
                <view>
                  <text class="text-gray">已完成：</text>
                  <text class="success">
                    <text> {{item.finishCount}}次</text>
                    <text style="margin:0 5px;color:black">/</text>
                    <text style="color:black">{{item.totalMeasure}}次</text>
                  </text>
                </view>
                <view class="link" bindtap="onReport" data-id="{{item.id}}" wx:if="{{item.conditioningProgramDetail.conditioningProgramType && item.conditioningProgramDetail.conditioningProgramType==='健康评估'}}">
                  健康分析报告</view>
              </view>
              <view class="scheme-row">
                <text class="text-gray">频次：</text>
                <view wx:if="{{item.frequencyType==='不限'}}">{{item.frequencyType}}{{item.conditioningProgramDetail.cpFixedPricingRule.convertUnit}}</view>
                <view wx:else>
                  每{{item.frequencyType}}天{{item.frequencyMeasure}}{{item.conditioningProgramDetail.cpFixedPricingRule.convertUnit}}
                </view>
              </view>
              <view class="desc-row" wx:if="{{item.remark}}">
                <text class="text-gray">操作指南：</text>
                <text class="desc-label">{{item.remark}}</text>
              </view>
            </view>
                  <!-- 健康咨询-->
            <view class="scheme-card" wx:if="{{item.conditioningProgramDetail.conditioningProgramType && item.conditioningProgramDetail.conditioningProgramType==='健康咨询'}}">
              <view class="scheme-title">{{item.conditioningProgramDetail.name}}</view>
              <view class="divider"></view>
              <view class="scheme-row between" style="margin-top:15px">
                <view>
                  <text class="text-gray">数量：</text>
                  <text class="success">
                   <text style="color:black" wx:if="{{item.frequencyType==='不限'}}">不限次</text>
                    <text style="color:black" wx:else>{{item.totalMeasure}}次</text>
                  </text>
                </view>
                <view class="link" bindtap="onChatRecord" data-item="{{item.consults}}" wx:if="{{item.consults && item.consults.length>0}}">
                  咨询记录</view>
              </view>
              <view class="scheme-row">
                <text class="text-gray">频次：</text>
                <view wx:if="{{item.frequencyType==='不限'}}">{{item.frequencyType}}{{item.conditioningProgramDetail.cpFixedPricingRule.convertUnit}}</view>
                <view wx:else>
                  每{{item.frequencyType}}天{{item.frequencyMeasure}}{{item.conditioningProgramDetail.cpFixedPricingRule.convertUnit}}
                </view>
              </view>
              <view class="desc-row" wx:if="{{item.remark}}">
                <text class="text-gray">操作指南：</text>
                <text class="desc-label">{{item.remark}}</text>
              </view>
            </view>


          </view>


        </view>
      </view>
      <!--调养效果  -->
      <view class="bottom-box">
        <view class="info-card status-card result-box">
          <view class="row row-box" style="margin-bottom:27rpx">
            <image class="icon" src="../../assets/icon/icon_effect@3x.png" mode="heightFix" />
            <text class="header-title">调养效果</text>
          </view>
          <!--调养效果  -->
          <record-care></record-care>
          <!--舌象  -->
          <view class="tongue-list-outer">
            <view class="tongue-list-title">舌象</view>
            <view class="tongue-list-table">
              <view class="table-header">
                <view class="header-cell date-cell">日期</view>
                <view class="header-cell">舌面</view>
                <view class="header-cell">舌底</view>
              </view>
              <block wx:for="{{healthReports}}" wx:key="healthAnalysisReportId">
                <view class="table-row">
                  <view class="cell date-cell">
                    <view>{{item.time4}}</view>
                    <view class="report-btn" bindtap="onSeeReport" data-date="{{item.time4}}" data-id="{{item.healthAnalysisReportId}}">
                      <t-icon name="file" size="20rpx" color="#1976d2" />
                      <text>查看报告</text>
                    </view>
                  </view>
                  <view class="cell">
                    <t-image wx:if="{{item.upImg}}" src="{{item.upImg}}" mode="aspectFit" width="80rpx" height="80rpx" shape="round" bind:tap="onPreviewImage" data-url="{{item.upImg}}" />
                    <t-icon wx:else name="image" size="48rpx" color="#ccc" />
                  </view>
                  <view class="cell">
                    <t-image wx:if="{{item.downImg}}" src="{{item.downImg}}" mode="aspectFit" width="80rpx" height="80rpx" shape="round" bind:tap="onPreviewImage" data-url="{{item.downImg}}" />
                    <t-icon wx:else name="image" size="48rpx" color="#ccc" />
                  </view>
                </view>
              </block>
            </view>
          </view>
          <!--面象  -->
          <view class="tongue-list-outer">
            <view class="tongue-list-title">面象</view>
            <view class="tongue-list-table">
              <view class="table-header">
                <view class="header-cell date-cell">日期</view>
                <view class="header-cell">面部</view>
              </view>
              <block wx:for="{{healthReports}}" wx:key="healthAnalysisReportId">
                <view class="table-row">
                  <view class="cell date-cell">
                    <view>{{item.time4}}</view>
                    <view class="report-btn" bindtap="onSeeReport" data-date="{{item.time4}}" data-id="{{item.healthAnalysisReportId}}">
                      <t-icon name="file" size="20rpx" color="#1976d2" />
                      <text>查看报告</text>
                    </view>
                  </view>
                  <view class="cell">
                    <t-image wx:if="{{item.faceImg}}" src="{{item.faceImg}}" mode="aspectFit" width="80rpx" height="80rpx" shape="round" bind:tap="onPreviewImage" data-url="{{item.faceImg}}" />
                    <t-icon wx:else name="image" size="48rpx" color="#ccc" />
                  </view>
                </view>
              </block>
            </view>
          </view>
          <!--症状  -->
          <view class="symptom-list-outer">
            <view class="symptom-list-title">症状</view>
            <view class="container">
              <!-- 表头 -->
              <view class="table-headers">
                <view class="date-header">日期</view>
                <view class="symptoms-header-scroll">
                  <view class="symptoms-header">症状</view>
                </view>
              </view>
              <!-- 表格内容 -->
              <view class="table-body">
                <!-- 固定日期列 -->
                <view class="date-column">
                  <view wx:for="{{healthReports}}" wx:key="healthAnalysisReportId" class="date-cells">
                    {{item.time4}}
                  </view>
                </view>
                <!-- 可滚动症状列 -->
                <scroll-view class="symptoms-column" scroll-x>
                  <view class="symptoms-grid">
                    <view wx:for="{{healthReports}}" wx:key="healthAnalysisReportId" class="symptoms-row">
                      <view wx:for="{{item.symptoms}}" wx:key="index" class="symptom-cells" wx:for-item="symptom" style="min-width: {{symptomCellWidth}}; max-width: {{symptomCellWidth}};">
                        <block wx:if="{{symptom.name}}">
                          <text>{{symptom.name}}{{symptom.label}}</text>
                          <text wx:if="{{symptom.trend==='up'}}" style="margin-left:8rpx;color:#f44336">↑</text>
                          <text wx:if="{{symptom.trend==='down'}}" style="margin-left:8rpx;color:#4caf50">↓</text>
                        </block>
                        <block wx:else></block>
                      </view>
                    </view>
                  </view>
                </scroll-view>
              </view>
            </view>
          </view>
          <!--指标  -->
          <view class="index-container">
            <view class="index-title">指标</view>
            <record-index></record-index>
          </view>
        </view>

      </view>
    </block>
  </scroll-view>
</view>