<view class='page'>
  <include src='/components/common/common'></include>
  <include src='/components/header/header'></include>
  <view class='body after-navber'>
    <view class='top-bar flex-row'>
      <navigator class='flex-grow-1 {{(status == 0?"active":"")}}' openType='redirect'
        url='/pages/coupon/coupon?status=0'><text>未使用</text></navigator>
      <navigator class='flex-grow-1 {{(status == 1?"active":"")}}' openType='redirect'
        url='/pages/coupon/coupon?status=1'><text>已使用</text></navigator>
      <navigator class='flex-grow-1 {{(status == 2?"active":"")}}' openType='redirect'
        url='/pages/coupon/coupon?status=2'><text>已过期</text></navigator>
    </view>
    <block wx:if='{{ (list && list.length > 0) }}'>
      <view class='coupon-list'>
        <block wx:for='{{list}}' wx:for-item='coupon' wx:for-index='index' wx:key='{{item.id}}'>
          <view class='coupon-item coupon-status-{{coupon.status}}' style='margin-top:20rpx;'>
            <image class='coupon-bg' src='/images/img-coupon-bg-{{(coupon.status == 0?0:1)}}.png'></image>
            <block wx:if='{{coupon.status != 0}}'>
              <image class='coupon-status-icon' src='/images/img-coupon-status-icon-{{coupon.status}}.png'></image>
            </block>
            <view class='flex-row' style='height: 100%;overflow: hidden;position:relative'>
              <view class='flex-grow-0 flex-col flex-y-center flex-x-center coupon-left'>
                <view class='flex-row flex-y-bottom'>
                  <view class='fs-sm'>￥</view>
                  <view style='font-size: {{(coupon.sub_price.length > 4?13:19)}}pt;line-height: .9'>
                    {{coupon.sub_price}} </view>
                </view>
                <view class='fs-sm' style='margin-top: 10rpx'>{{coupon.min_price_desc}}</view>
              </view>
              <view class='flex-grow-1 flex-y-center coupon-right'>
                <view style='width:100%;'>
                  <navigator openType='navigateTo'
                    url='/pages/coupon-detail/coupon-detail?user_coupon_id={{coupon.user_coupon_id}}'>
                    <view class='flex-row flex-y-center mb-10' style='margin-bottom:5rpx;'>
                      <view class='flex-grow-1'>{{coupon.event_desc}}</view>
                    </view>
                    <view class='fs-sm' style='color: #666666; font-size: 8pt;'>{{coupon.begin_time}} ~
                      {{coupon.end_time}}</view>
                    <block wx:if='{{ (coupon.appoint_type == 1 && coupon.cat.length == 0) }}'><text
                        class='user_coupon_font'>全场通用</text></block>
                    <block wx:if='{{ (coupon.appoint_type == 2 && coupon.goods.length == 0) }}'><text
                        class='user_coupon_font'>全场通用</text></block>
                    <block wx:if='{{coupon.appoint_type == NULL}}'><text class='user_coupon_font'>全场通用</text></block>
                  </navigator>
                  <block wx:if='{{ (coupon.appoint_type == 1 && coupon.cat.length > 0) }}'>
                    <view class='user_coupon_font'
                      style='overflow: hidden; white-space: nowrap; text-overflow: ellipsis;width:87%;'> 仅限<block
                        wx:for='{{coupon.cat}}' wx:for-item='cat' wx:for-index='index' wx:key='id'>
                        <text>{{cat.name}}、</text></block>产品使用 </view>
                    <block wx:if='{{coupon.cat.length > 2}}'>
                      <block wx:if='{{index != check}}'>
                        <image bindtap='xia' class='xia' data-index='{{index}}'
                          src='{{__wxapp_img.user.coupon_xia.url}}'></image>
                      </block>
                      <block wx:if='{{index == check}}'>
                        <image bindtap='shou' class='xia' data-index='{{index}}' src='{{__wxapp_img.store.shou.url}}'>
                        </image>
                      </block>
                    </block>
                  </block>
                  <block wx:if='{{ (coupon.appoint_type == 2 && coupon.goods.length > 0) }}'>
                    <view bindtap='goodsList' class='user_coupon_font' data-goods_id='{{coupon.goods}}'
                      data-id='{{coupon.user_coupon_id}}' style='height:50rpx;'>指定商品使用 点进去查看指定商品</view>
                  </block>
                </view>
              </view>
            </view>
          </view>
          <block wx:if='{{coupon.cat.length > 2}}'>
            <block wx:if='{{check == index}}'>
              <view class='user_coupon' style='padding:10rpx 24rpx;background:#fff;'> 仅限<block wx:for='{{coupon.cat}}'
                  wx:for-item='cat' wx:for-index='index' wx:key='id'><text>{{cat.name}}、</text></block>产品使用 </view>
            </block>
          </block>
        </block>
      </view>
    </block>
    <block wx:else>
      <view style='padding-top: 200rpx;color: #888;text-align: center'>暂无相关优惠券</view>
    </block>
  </view>
  <include src='/components/footer/footer'></include>
</view>