<!--pages/voucher/voucher.wxml-->
<myPay id="myPay" bindsuccess="successPay"></myPay>
<view class="voucher {{all?'all':''}}" >
  <!-- 购买优惠券 -->
  <view class="buyVoucher shadow">
    <view class="head">购买优惠券</view>
    <view class="buyVoucher_content">
      <scroll-view  scroll-x="true">
        <view class="voucher_type">
          <view class="voucher_item" wx:for="{{voucherList}}" wx:key="index">
            <view class="voucher_item_content">
              <view class="voucher_name">
                {{item.name}}
              </view>
              <view class="voucher_amount">
                {{item.amount}}<span style="font-size: 24rpx;">元</span> 
              </view>
              <view class="voucher_threshold">
                {{item.threshold?'满'+item.threshold+'可用':'无门槛'}}
              </view>
              <view class="foot">
                {{item.expirationTime?item.expirationTime+'到期':'永久'}} | 使用范围 <van-icon name="question-o" data-useScopes="{{item.useScopes}}" bind:tap="showUseScopes"/>
              </view>
            </view>
            <view class="voucher_price">
              <van-checkbox-group value="{{ buyVoucher }}" bind:change="changeBuyVoucher">
                <van-checkbox label-class="voucher_price1" name="{{item.id}}">￥{{item.sellingPrice}}</van-checkbox>
              </van-checkbox-group>
              <van-stepper value="{{ item.buyNumber }}" data-index="{{index}}" bind:change="changeNumber" />
            </view>
          </view>
        </view>
      </scroll-view>
    </view>
    <view class="pay">
      <view class="payBtn" bind:tap="pay">支付 <span wx:if="{{payMoney}}">￥{{payMoney}}</span> </view>
    </view>
  </view>
  <!-- 已拥有优惠券 -->
  <view class="myVoucher shadow">
    <view class="head">{{all?'我的优惠券':"可使用券"}} <span style="font-size: 20rpx;color: darkgray;">{{myVoucherTotal}} 张</span></view>
    <view class="myVoucher_content">
      <block wx:if="{{myVoucherList.length>0}}">
        <view class="myVoucher_item" wx:for="{{myVoucherList}}" wx:key="index">
          <view class="myVoucher_item_top">
            <view class="myVoucher_item_top_left">
              <view class="myVoucher_name">{{item.name}}</view>
              <view class="myVoucher_expirationTime">{{item.expirationTime?item.expirationTime+'到期':'永久'}}</view>
            </view>
            <view class="myVoucher_item_top_right">
              <view style="margin-right: 10px;">
                <view class="myVoucher_amount"> <span style="font-size: 28rpx;">￥</span>{{item.amount}}</view>
                <view class="myVoucher_threshold">{{item.threshold?'满'+item.threshold+'可用':'无门槛'}}</view>
              </view>
              <view wx:if="{{!all}}">
                <van-checkbox-group value="{{ chooseVoucher }}" bind:change="changeChooseVoucher">
                  <van-checkbox label-class="voucher_price1" name="{{item.id}}"></van-checkbox>
                </van-checkbox-group>
              </view>
            </view>
          </view>
          <view class="myVoucher_item_bottom">
            使用范围：{{item.useScopesText}}
          </view>
        </view>
      </block>
      <view wx:else class="empty">
        暂无可用优惠券
      </view>
    </view>
  </view>
  <!-- 不可使用 -->
  <view class="myVoucher shadow" wx:if="{{disabledTotal>0}}">
    <view class="head">不可使用券 <span style="font-size: 20rpx;color: darkgray;">{{disabledTotal}} 张</span></view>
    <view class="myVoucher_content">
      <block wx:if="{{disabled.length>0}}">
        <view class="myVoucher_item disabled" wx:for="{{disabled}}" wx:key="index">
          <view class="myVoucher_item_top">
            <view class="myVoucher_item_top_left">
              <view class="myVoucher_name">{{item.name}}</view>
              <view class="myVoucher_expirationTime">{{item.ifExpiration?'已过期': (item.expirationTime?item.expirationTime+'到期':'永久')}}</view>
            </view>
            <view class="myVoucher_item_top_right">
              <view style="margin-right: 10px;">
                <view class="myVoucher_amount"> <span style="font-size: 28rpx;">￥</span>{{item.amount}}</view>
                <view class="myVoucher_threshold">{{item.threshold?'满'+item.threshold+'可用':'无门槛'}}</view>
              </view>
              <view wx:if="{{!all}}">
                <van-checkbox-group value="{{ chooseVoucher }}" bind:change="changeChooseVoucher">
                  <van-checkbox label-class="voucher_price1" name="{{item.id}}"></van-checkbox>
                </van-checkbox-group>
              </view>
            </view>
          </view>
          <view class="myVoucher_item_bottom">
            <view wx:if="{{item.disabledReson}}">
              <view style="color: white;">本单不可用原因：{{item.disabledReson}}</view>
            </view>
            <view wx:else>
              使用范围：{{item.useScopesText}}
            </view>
            
          </view>
        </view>
      </block>
      <view wx:else class="empty">
        暂无数据
      </view>
    </view>
  </view>
</view>
 <!-- 确认 -->
 <view class="submit" wx:if="{{!all}}">
    <view>红包优惠￥{{discount}}</view>
    <view class="submit_btn" bind:tap="submit">
      <view>确 认</view>
    </view>
  </view>