<!--packageF/cart_share/cart_share.wxml-->
<view id="cart">
  <image class="bg-box" src="{{set.img_url || 'https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com//cart_share_bg.png'}}" mode='widthFix' />

  <view class="main-box">
    <!--会员和优惠券-->
    <view class="member-header">
      <view class="gift-btn" wx:if="{{!share_id && set.is_gift_coupon==1}}" catchtap="openCoupon"><icon class="iconfont icon-fontclass-youhuiq"></icon><text style="margin-left: 3px;">转增</text></view>
      <view class="header-top">
        <image class="actor" src="{{member.avatar_image}}" alt="" />
        <view class="name">{{member.nickname}}{{set.title}}</view>
      </view>
      <view class="coupon-list-box" style="margin-right: 43px;" wx:if="{{share_id && share_coupons.length > 0}}">
        <view class="coupon-item" wx:for="{{share_coupons}}" wx:for-item="coupon" wx:key="coupon">
          <view class="coupon-item-left">
            <text class="money span" wx:if="{{coupon.coupon_method==2}}">{{coupon.discount}}折</text>
            <text class="money span" wx:if="{{coupon.coupon_method==1}}"><text style="font-size: 10px;">{{language['money']}}</text>{{coupon.deduct}}</text>
            <text class="span" style="font-size: 10px;">{{coupon.enough_msg}}</text>
            <view class="top-circle"></view>
            <view class="bottom-circle"></view>
          </view>
          <view class="coupon-item-right">
            <text class="span">{{coupon.name}}</text>
            <view class="get-btn-box" wx:if="{{coupon.sharing_status == 0}}" catchtap="getCoupon" data-coupon="{{coupon}}" data-index="{{index}}"><text class="get-btn span">领取</text></view>
            <view class="get-btn-box" wx:if="{{coupon.sharing_status == 1}}"><text class="get-btn disabled span">已领取</text></view>
            <view class="top-circle" style="left: -5px;"></view>
            <view class="bottom-circle" style="left: -5px;"></view>
          </view>
        </view>
      </view>
      <view class="coupon-list-box" wx:if="{{!share_id && share_coupons.length > 0}}">
        <view class="coupon-item" wx:for="{{share_coupons}}" wx:for-item="coupon" wx:key="coupon">
          <view class="coupon-item-left">
            <text class="money span" wx:if="{{coupon.belongs_to_coupon.coupon_method==2}}">{{coupon.belongs_to_coupon.discount}}折</text>
            <text class="money span" wx:if="{{coupon.belongs_to_coupon.coupon_method==1}}"><text style="font-size: 10px;">{{language['money']}}</text>{{coupon.belongs_to_coupon.deduct}}</text>
            <text class="span" style="font-size: 10px;" wx:if="{{coupon.belongs_to_coupon.coupon_method==2}}">满{{ coupon.belongs_to_coupon.enough }}立享</text>
            <text class="span" style="font-size: 10px;" wx:if="{{coupon.belongs_to_coupon.coupon_method==1}}">满{{ coupon.belongs_to_coupon.enough }}立减</text>
            <view class="top-circle"></view>
            <view class="bottom-circle"></view>
          </view>
          <view class="coupon-item-right">
            <text class="span">{{coupon.belongs_to_coupon.name}}</text>
            <view class="get-btn-box"><text class="get-btn span">{{coupon.num}}张</text></view>
            <view class="top-circle" style="left: -5px;"></view>
            <view class="bottom-circle" style="left: -5px;"></view>
          </view>
        </view>
      </view>
      <view class="asset-line" wx:if="{{share_id && share_coupons.length > 0}}"></view>
      <view class="one-click-box {{all_get_coupon?'disabled':''}}" data-coupon="{{'all'}}" catchtap="getCoupon" wx:if="{{share_id && share_coupons.length > 0}}">
        <text>一键领取</text>
      </view>
    </view>

    <!--带share_id的购物车列表-->
    <view class="cart-list-box" wx:if="{{share_id}}">
      <van-checkbox-group value="{{eachCheckList}}" bind:change="allSelectHandle">
        <view class="cart-box" wx:for="{{cartList}}" wx:for-item="good" wx:for-index="index" wx:key="index">
          <view class="cart_good">
            <van-checkbox checked-color="#f15353" shape="round" disabled="{{good.stock == 0}}"
                          name="{{good.goods_id}}"></van-checkbox>
            <view class="right">
              <view class="img" data-goodsid="{{good.goods_id}}" catchtap="toGoodsInfo">
                <image src="{{good.thumb}}" mode='aspectFill'/>
              </view>
              <view class="info">
                <view class="inner ul">
                  <view class="name h1" data-goodsid="{{good.goods_id}}" catchtap="toGoodsInfo">
                    {{good.title}}
                  </view>
                  <view class="introduction li" wx:if="{{good.option_title}}" data-good="{{good}}">
                    <view class="span option_str">{{ good.option_title }}
                    </view>
                  </view>
                </view>
                <view class="other">
                  <!--<block wx:if="{{good.style_type == 'point-mall'}}">-->
                    <!--<view class="price">-->
                      <!--<text class="span">{{ good.point_goods.point }}</text>{{integral}}-->
                    <!--</view>-->
                  <!--</block>-->
                  <!--<block wx:elif="{{good.style_type == 'lease-toy'}}">-->
                    <!--<view class="price">{{language['money']}}-->
                      <!--<text class="span">{{good.goods_price}}</text>/天(押金：{{good.lease_goods.goods_deposit}})-->
                    <!--</view>-->
                  <!--</block>-->
                  <!--<block wx:else>-->
                    <view class="price">{{language['money']}}
                      <text class="span">{{good.price}}</text>
                    </view>
                  <!--</block>-->
                  <view wx:if="{{good.stock == 0}}">
                    库存不足
                  </view>
                  <view wx:else class="num">
                    <view class="leftnav" data-index="{{index}}" catchtap="numberLeft">-
                    </view>
                    <input type="number" class="shownum" data-index="{{index}}"
                           data-cart_id="{{good.goods_id}}" data-goodtotal="{{good.total}}"
                           bindblur="blurCount" bindinput="goodinpbtn" value="{{good.total}}"/>
                    <view class="rightnav" data-index="{{index}}" catchtap="numberRight">
                      +
                    </view>
                  </view>
                </view>
              </view>
            </view>
          </view>
        </view>
      </van-checkbox-group>
    </view>

    <!--不带share_id的购物车列表-->
    <view class="cart-list-box" wx:if="{{!share_id}}">
      <van-checkbox-group value="{{eachCheckList}}" bind:change="allSelectHandle">
        <view class="cart-box" wx:for="{{cartList}}" wx:for-item="good" wx:for-index="index" wx:key="index">
          <view class="cart_good">
            <van-checkbox checked-color="#f15353" shape="round" name="{{good.goods_id}}"></van-checkbox>
            <view class="right">
              <view class="img" data-goodsid="{{good.goods_id}}" catchtap="toGoodsInfo">
                <image src="{{good.goods.thumb}}" mode='aspectFill'/>
              </view>
              <view class="info">
                <view class="inner ul">
                  <view class="name h1" data-goodsid="{{good.goods_id}}" catchtap="toGoodsInfo">
                    {{good.goods.title}}
                  </view>
                  <view class="introduction li" wx:if="{{good.goods_option}}" data-good="{{good}}">
                    <view class="span option_str">{{ good.goods_option.title}}
                    </view>
                  </view>
                </view>
                <view class="other">
                  <!--<block wx:if="{{good.style_type == 'point-mall'}}">-->
                  <!--<view class="price">-->
                  <!--<text class="span">{{ good.point_goods.point }}</text>{{integral}}-->
                  <!--</view>-->
                  <!--</block>-->
                  <!--<block wx:elif="{{good.style_type == 'lease-toy'}}">-->
                  <!--<view class="price">{{language['money']}}-->
                  <!--<text class="span">{{good.goods_price}}</text>/天(押金：{{good.lease_goods.goods_deposit}})-->
                  <!--</view>-->
                  <!--</block>-->
                  <!--<block wx:else>-->
                  <view class="price">{{language['money']}}
                    <text class="span">{{good.goods.price}}</text>
                  </view>
                  <!--</block>-->
                  <view class="num">
                    <view class="leftnav" data-index="{{index}}" catchtap="numberLeft">-
                    </view>
                    <input type="number" class="shownum" data-index="{{index}}"
                           data-cart_id="{{good.goods_id}}" data-goodtotal="{{good.total}}"
                           bindblur="blurCount" bindinput="goodinpbtn" value="{{good.total}}"/>
                    <view class="rightnav" data-index="{{index}}" catchtap="numberRight">
                      +
                    </view>
                  </view>
                </view>
              </view>
            </view>
          </view>
        </view>
      </van-checkbox-group>
    </view>

    <!--底部-->
    <view class="fixed-cart" catchtap="gotoCart">
      <icon class="iconfont icon-gouwuche2"></icon>
    </view>
    <view style="height: 60px;"></view>
    <view class="cart-bottom-box">
      <view class="checkall">
        <van-checkbox checked-color="#f15353"
                      style="font-size: 12px;"
                      value="{{checkAll}}"
                      bind:change="allSelect">{{language['全选']}}
        </van-checkbox>
      </view>
      <view wx:if="{{!share_id}}" class="paysub {{!share_id && eachCheckList.length==0 && share_coupons.length ==0?'disabled':''}}" catchtap="shareGoods">
        点击生成分享
        <!-- <text class="total" style="font-size: 12px;">({{ eachCheckList.length }})</text> -->
      </view>
      <view wx:if="{{share_id}}" class="paysub"catchtap="addIntoCart">
        加入购物车
      </view>
    </view>

    <!--优惠券-->
    <van-popup bind:click-overlay="cancelCoupon" show="{{showCouponDetail}}" position="bottom" overlay="{{true}}">
      <view class="add-info">
        <view class="tips">注：选择转赠优惠券，将会扣除您对应的优惠券数量</view>
        <view class="coupon-list-info" wx:for="{{coupons}}" wx:key="index" wx:for-item="coupon" wx:for-index="index">
          <view class="checkList">
            <van-checkbox data-item="{{coupon}}" data-index="{{index}}" checked-color="#f6a132" disabled="{{!coupon.valid}}" value="{{coupon.checked}}" bind:change="selectCoupon" shape="square"></van-checkbox>
          </view>
          <view class="{{coupon.valid?'coupon_voucher_main':''}} {{!coupon.valid?'coupon_voucher_gray':''}}">
            <view class="coupon_voucher_left">
              <view wx:if="{{coupon.belongs_to_coupon.coupon_method==1}}">
                <view class="p coupon_voucher_amount type_large">
                  <text style="font-size: 13px;">{{language['money']}}</text>{{coupon.belongs_to_coupon.deduct}}
                </view>
                <view class="p coupon_voucher_limit">满{{coupon.belongs_to_coupon.enough}}立减</view>
              </view>
              <view wx:else>
                <view class="p coupon_voucher_amount type_large">
                  {{coupon.belongs_to_coupon.discount}}折
                </view>
                <view class="p coupon_voucher_limit">满{{coupon.belongs_to_coupon.enough}}立享</view>
              </view>
            </view>
            <view class="coupon_voucher_hr"></view>
            <view class="coupon_voucher_right">
              <view class="p coupon_voucher_range">{{coupon.belongs_to_coupon.name}}</view>
              <view wx:if="{{ coupons_temp[coupon.coupon_id] }}" class="coupon-stepper">
                <view class="coupon-stepper-num">共{{coupon.count}}张</view>
                <block wx:if="{{coupon.checked && coupons_temp[coupon.coupon_id] }}">
                  <van-stepper input-class='input-box' plus-class='plus-box' minus-class='minus-box' data-item="{{coupon}}" data-index="{{index}}" integer value="{{ coupons_temp[coupon.coupon_id].num }}" async-change bind:change="changeCoupon" />
                </block>
              </view>
              <!--<view class="p coupon_voucher_period">{{coupon.time_start}}-{{coupon.time_end}}</view>-->
            </view>
          </view>
        </view>
      </view>
      <view class="coubtngroup">
        <view class="btn sure" bindtap="sureCoupon">确认</view>
        <view class="btn close" bindtap="cancelCoupon">取消</view>
      </view>
    </van-popup>

    <van-popup show="{{ showWechatshar }}" round="{{true}}" bind:close="onClose">
      <view class="pop-share">
        <view class="pop-share-tips">分享购物车生成成功！</view>
        <view class="pop-share-tips">点击下面按钮或者右上角分享</view>
        <button class="pop-share-paysub" open-type="share">点击分享</button>
      </view>
    </van-popup>

  </view>
</view>
