<!--module/health/pages/scheme/scheme.wxml-->
<view class="scheme-container">
  <t-navbar title="{{i18n.scheme.title}}" left-arrow />

  <scroll-view class="page-scroll__container" type="list" scroll-y style="{{containerStyle}}">
    <view class="card-wrapper">
      <view class="card-header no-body" bordered="{{false}}" style="background:transparent;padding-right: 6px;padding-left: 6px;">
        <view slot="title" class="header-row">
          <view class="date-text"><text style="color:#8C8C8C">{{i18n.scheme.date}}</text><text style="color:black">{{dataset.reportTime}}</text></view>
          <view class="recuperate-btn" bind:tap="toReportPage">{{i18n.report.title}}</view>
        </view>
      </view>
    </view>


    <view class="card-wrapper" wx:for="{{dataset.children}}" wx:key="title">
      <t-cell t-class="card-header cell-border-gradient" title="{{item.title}}" />
      <view class="card-body">
        <view class="scheme__item" wx:for="{{item.children}}" wx:key="title">
          <view class="buy-container" wx:if="{{item.title || item.buyUrl}}">
            <view class="scheme__item-title scheme__title" wx:if="{{item.title}}">{{item.title}}</view>
            <view class="scheme__item-title scheme__title" wx:else></view>
            <view class="buy-box" bindtap="goBuy" data-item="{{item}}" wx:if="{{item.buyType}}">去购买</view>
          </view>
          <horizontal-scrollable dataset="{{item.children}}"></horizontal-scrollable>
          <view class="scheme__description" wx:if="{{item.description}}">{{item.description}}</view>
          <span class="scheme__description" wx:for="{{item.descriptions}}" wx:key="id">
            <text class="scheme__title">【{{item.name}}】</text>
            <text>{{item.description}}</text>
          </span>
        </view>
        <view class="scheme-wrapper">
          <view class="media-container">
            <view class="media" wx:for="{{item.media}}" wx:key="*this">
              <view class="name">{{item.name}}</view>
              <image wx:if="{{item.type==='picture'}}" src="{{item.mediaUrl}}" mode="aspectFit"></image>
              <video wx:elif="{{item.type==='video'}}" src="{{item.mediaUrl}}" poster="{{item.imgUrl}}"></video>
              <view class="description">{{item.description}}</view>
            </view>
          </view>
          <view class="description" wx:for="{{item.descriptions}}" wx:key="*this">{{item}}</view>
        </view>
      </view>
    </view>
    <!-- 底部占位，避免内容被按钮遮盖 -->
    <view class="scheme-bottom-placeholder"></view>
  </scroll-view>
  
  <!-- 底部固定去购买按钮 -->
  <view class="scheme-bottom-buy-btn" style="padding-bottom: {{container.safeBottomOffset-10}}px;" bindtap="goToProductPage" wx:if="{{true}}">
    <view class="buy-btn-text">{{i18n.orderText.goPay}}</view>
  </view>
</view>
<t-message id="{{$messageId}}"></t-message>

<!-- 小程序码弹窗 -->
<t-popup
  visible="{{showQrCodePopup}}"
  bind:visible-change="closeQrCodePopup"
  placement="center"
  close-on-overlay-click="{{true}}"
>
  <view class="qr-code-popup"   wx:if="{{qrCodeImageUrl}}">
    <view class="qr-code-popup__title">请长按二维码</view>
    <view class="qr-code-popup__content">
      <image
        src="{{qrCodeImageUrl}}"
        mode="aspectFit"
        class="qr-code-image"
        show-menu-by-longpress="{{true}}"
      ></image>
    </view>
    <view class="qr-code-popup__footer">
      <view class="qr-code-popup__btn" bind:tap="closeQrCodePopup">关闭</view>
    </view>
  </view>
</t-popup>