<!--pages/buy/cart_v2/cart_v2.wxml-->
<wxs module="util">
  var toNumber = function (val) { if (val) { return Number(val) } };
  module.exports.toNumber = toNumber;
</wxs>
<block wx:if="{{firstshow&&!loginshow}}">
  <view class="cart">
    <view class="edit" bindtap="onCartDelete" wx:if="{{isShowList && cartList_none}}">
      <view class="pencil_square">
        <van-icon name="records" size="36rpx" color="#bfcbd9"/>
      </view>
      <view class="edit-right-box">
        <view class="span">{{!cartDelete? language.cart['编辑']:language.cart['完成']}}</view>
        <view class="to-more" wx:if="{{sharin_is_open == 1}}" catchtap="toShowMore">
          <icon class="iconfont icon-zb_all_more"></icon>
          <block wx:if="{{showMore}}">
            <view class="triangle-up"></view>
            <view class="more-list-box">
              <text bindtap="shareCartGood">分享好物</text>
            </view>
          </block>
        </view>
      </view>
    </view>

    <view class="cart_main" wx:if='{{isShowList}}'>
      <!--购物车商品列表-->
      <view class="shop-box" wx:for="{{cartList}}" wx:for-item="item" wx:for-index="c_index" wx:key="c_index">
        <view class="shop-head">
          <van-checkbox checked-color="#f15353" disabled="{{item.disable}}" bind:change="shopChange" data-c_index="{{c_index}}"
                        value="{{eachCheckShop[c_index].check}}"></van-checkbox>
          <view class="shop-left" data-item="{{item}}" catchtap="toShop">
            <icon class="iconfont icon-fontclass-dianpu"></icon>
            <view class=" span shop-title">{{item.name}}</view>
          </view>
          <!--<view class="coupon-tag" catchtap="showCouponList">-->
          <!--<text class="span">优惠券</text>-->
          <!--</view>-->
        </view>
        <view class="coupon-list" wx:for="{{item.discount_activity}}" wx:for-item="discount" wx:key="code">
          <view class="coupon-left">
            <text class="span tag">{{discount.name}}</text>
            <text class="span tag-title">{{discount.desc}}</text>
          </view>
          <view class="coupon-right" data-item="{{item}}" catchtap="toSearch">
            <text>去凑单</text>
            <icon class="iconfont icon-advertise-next"></icon>
          </view>
        </view>
        <van-checkbox-group value="{{eachCheckList[c_index]}}" bind:change="allSelectHandle" data-c_index="{{c_index}}">
          <view class="cart-box" wx:for="{{item.carts}}" wx:for-item="good" wx:for-index="index" wx:key="index">
            <view class="cart_good">
              <van-checkbox checked-color="#f15353" shape="round" disabled="{{item.disable}}"
                            name="{{good.cart_id}}"></van-checkbox>
              <view class="right">
                <view class="img" data-goodsid="{{good.goods_id}}" catchtap="toGoodsInfo" data-option_id="{{good.goods_option_id}}">
                  <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" data-option_id="{{good.goods_option_id}}">
                      {{good.goods_title}}
                    </view>
                    <view class="introduction li" wx:if="{{good.goods_option_title}}" data-good="{{good}}">
                      <!--catchtap="openSpecs"-->
                      <view class="span option_str">{{ good.goods_option_title }}
                        <!-- <icon class="iconfont icon-member-bottom" style="vertical-align: sub;"></icon> -->
                      </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}}
                        <text class="dPriceBox_vipPrice" wx:if="{{vip_show}}">会员价：{{language['money']}}<text class="span">{{ good.vip_price }}</text></text>
                      </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 class="dPriceBox_vipPrice" wx:if="{{vip_show}}">会员价：{{language['money']}}<text class="span">{{ good.vip_price }}</text></view>
                      </view>
                    </block>
                    <view class="num">
                      <view class="leftnav" data-index="{{index}}" data-c_index="{{c_index}}" catchtap="numberLeft">-
                      </view>
                      <input type="number" class="shownum" data-index="{{index}}" data-c_index="{{c_index}}"
                             data-cart_id="{{good.cart_id}}" data-goodtotal="{{good.total}}"
                             bindblur="blurCount" bindinput="goodinpbtn" value="{{good.total}}"/>
                      <view class="rightnav" data-index="{{index}}" data-c_index="{{c_index}}" catchtap="numberRight">
                        +
                      </view>
                    </view>
                  </view>
                </view>
              </view>
            </view>
            <view class="estimated" wx:if="{{util.toNumber(good.estimated_price) > 0 && good.estimated_price != good.price}}">
              预估到手价：{{language['money']}}<span>{{good.estimated_price }}</span>
            </view>
            <view class="activity" wx:if="{{good.discount_activity && good.discount_activity.length > 0}}">
              <view class="span activity-title">单品活动</view>
              <view class="activity-box">
                <view class="span activity-item" wx:for="{{good.discount_activity}}" wx:for-item="activity"
                      wx:for-index="i" wx:key="i">{{activity.desc}}
                </view>
              </view>
            </view>
          </view>
        </van-checkbox-group>
      </view>
      <!--购物车商品列表end-->

      <!--失效商品列表-->
      <view class="disabled-list" wx:if="{{failureCartList.length > 0}}">
        <view class="disabled-head">
          <view class=" spandisabled-title">失效商品{{failureCartList.length}}件</view>
          <view class="span" style="text-align: right;color: #f14e4e;" catchtap="clearFailureCart">清空失效商品</view>
        </view>
        <view class="disabled-item" wx:for="{{failureCartList}}" wx:for-item="good" wx:key="goods_id">
          <view class="span gray">失效</view>
          <view class="img" data-goodsid="{{good.goods_id}}" catchtap="toGoodsInfo">
            <image src="{{good.goods_thumb}}" mode='aspectFill'/>
          </view>
          <view class="detail">
            <view class="title">{{ good.goods_title }}</view>
            <view class="price">该商品已不能购买</view>
          </view>
        </view>
      </view>
      <!--失效商品列表end-->

      <!--购物车为空-->
      <view class="nocard" wx:if='{{isShowList && !cartList_none}}'>
        <view class="card_no">
          <view class="shopping_cart">
            <image src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/images/cart.png" mode='widthFix'/>
            <!-- 	<van-icon name="shopping-cart-o" size="200rpx" /> -->
          </view>
          <view class="view_title">
            <view class="left">{{language.cart['购物车快饿瘪了']}}</view>
            <view class="right">{{language.cart['主人快去给我找点东西吧']}}</view>
          </view>
        </view>
        <view class="card_no_menu">
          <view class="card_no_nav" bindtap="gomember">
            {{language.cart['个人中心']}}
          </view>
          <view class="card_no_nav card_no_navcolor" bindtap="gohome">
            {{language.cart['去逛逛']}}
          </view>
        </view>
      </view>
      <!--购物车为空end-->
      <!-- 推荐商品 页面设计插件 -->
      <block wx:if="{{ recommendInfo && recommendInfo.length > 0 }}">
        <view class="recommend_txt">你可能还喜欢</view>
        <view class="recommend">
          <view wx:for="{{recommendInfo}}" wx:key="index" class="recommendBox" catchtap="goRecommend" data-id="{{item.id}}">
            <view class="recommend_image">
              <image src="{{item.thumb}}" mode="aspectFill"></image>
            </view>
            <view class="recommend_min">
              <view class="recommend_title">{{item.title}}</view>
              <view class="recommend_price">{{language['money']}}{{item.price}}</view>
            </view>
          </view>
        </view>
      </block>
      <!-- 推荐商品 页面设计插件 end -->
      <!--结算部分-->
      <view class="cart_pay {{showcarrfootBol?'cart_paybottom':''}} {{showcarrfoot_ipxBol?'cart_paybottom_ipx':''}}"
            wx:if='{{!cartDelete && cartList_none}}'>
        <view class="all">
          <view class="checkall">
            <van-checkbox value="{{checkAll}}" shape="round" checked-color="#f15353" bind:change="allSelect">
              {{language['全选']}}
            </van-checkbox>
            <text class="t span"></text>
          </view>
        </view>
        <view class="ul text">
          <view class="li freight">
            <!-- #86152 隐藏 不含运费 -->
            <text class="span" style="color:#999; font-size:10px;" wx:if="{{false}}">({{language.cart['不含运费']}})</text>
            <text class="span" style="display: flex;">
              <text>{{language.cart['合计']}}：</text>
              <text class="span fontbe" style="font-size:12px;color:#f15353;">{{language['money']}}</text>
              <text class="span totalprice" style="font-size: 14px;">{{total_amount}}</text>
            </text>
          </view>
          <view class="li coupon" wx:if="{{util.toNumber(total_discount_amount) > 0}}" catchtap="openCoupon">
            优惠明细：{{language['money']}}{{total_discount_amount}}
          </view>
        </view>

        <view class="paysub" catchtap="checkGoods">{{language.cart['结算']}}
          <text class="small total">({{cart_ids.length}})</text>
        </view>
      </view>
      <!--结算部分end-->
    </view>

    <!--删除编辑-->
    <view class="cart_del {{showcarrfootBol?'cart_paybottom':''}} {{showcarrfoot_ipxBol?'cart_paybottom_ipx':''}}"
          wx:if='{{cartDelete}}'>
      <view class="checkall">
        <van-checkbox value="{{checkAll}}" shape="round" checked-color="#f15353" bind:change="allSelect">
          {{language['全选']}}
        </van-checkbox>
      </view>
      <view class="delete" catchtap='deleteGoods'>{{language.cart['删除']}}</view>
    </view>
    <!--删除编辑end-->

  </view>
</block>

<!--商品规格-->
<block wx:if="{{popupSpecs}}">
  <yzSpecs goodsInfo="{{goodsInfo}}" popupSpecs="{{popupSpecs}}" bind:closeSpecsPopup="close_yz_specs_popup"></yzSpecs>
</block>
<!--商品规格end-->

<!--配送方式冲突-->
<van-popup show="{{showChoose}}" round close-on-click-overlay="true" custom-style="width: 600rpx;border-radius: 30rpx;">
  <view class="wrapper">
    <view class="block">
      <view class="choose-title">
        您的购物车配送方式有冲突，请选择其中一种配送方式~
      </view>

      <view class="choose-content">
        <van-radio-group value="{{radioChoose}}" bind:change="typeChange">
          <view wx:for="{{dispatch_types}}" wx:for-item="item" wx:for-index="idx" wx:key="idx"
                style="padding: 20rpx 0;">
            <van-radio name="{{idx}}" checked-color="#ff4949">
              <view class="radio-title">{{item.name}}({{item.member_carts.length}}件)</view>
            </van-radio>
            <view class="radio-list ul">
              <view class="radio-item li" wx:for="{{item.member_carts}}" wx:for-item="goods" wx:for-index="i"
                    wx:key="{{i}}">
                <view class="p">{{goods.title}}</view>
                <view class="p" wx:if="{{goods.option_title}}" style="font-size: 12px;color: #666666;">
                  规格：{{goods.option_title}}
                </view>
              </view>
            </view>
          </view>
        </van-radio-group>
      </view>

      <view class="buttons">
        <view class="button-item">
          <view class="button-content" catchtap="closeChoose">返回购物车</view>
        </view>
        <view class="button-item">
          <view class="button-content red" catchtap="toBuy">去结算</view>
        </view>
      </view>
    </view>
  </view>
</van-popup>
<!--配送方式冲突end-->

<!--优惠明细-->
<van-popup show="{{showCouponDetail}}" round closeable close-on-click-overlay="true" bind:close="closeCoupon"
           position="bottom">
  <view class="coupon-detail">
    <view class="p coupon-detail-title">优惠明细</view>
    <view class="ul coupon-detail-box">
      <view class="li">
        <view class="p left">商品总价</view>
        <view class="p right">{{language['money']}}{{total_goods_price}}</view>
      </view>
      <view class="li" wx:for="{{discount_amount_items}}" wx:key="index">
        <view class="p left">{{item.name}}</view>
        <view class="p right">-{{language['money']}}{{item.amount}}</view>
      </view>
      <view class="li">
        <view class="p left">共优惠</view>
        <view class="p right">-{{language['money']}}{{total_discount_amount}}</view>
      </view>
    </view>
    <view class="total-box">
      <view class="p left">
        <text class="span" style="font-weight: bold">合计</text>
        <text class="span" style="color:#999; font-size:10px;">（不含运费）</text>
      </view>
      <view class="p right">{{language['money']}}{{total_amount}}</view>
    </view>
    <view class="p tips">优惠抵扣金额请在下单页查看</view>
  </view>
</van-popup>
<!--优惠明细end-->

<!--<van-popup show="{{showCouponList}}" round closeable close-on-click-overlay="true" bind:close="closeCouponList"-->
<!--position="bottom">-->
<!--<view class="coupon-pop">-->
<!--<view class="p coupon-pop-title">优惠券</view>-->
<!--<view class="ul coupon-pop-box">-->
<!--<view class="li" wx:for="{{4}}">-->
<!--<view class="left">-->
<!--<view class="p" style="border-bottom: 1px dashed #ffffff">{{language['money']}}11.00</view>-->
<!--<view class="p">满100立减</view>-->
<!--</view>-->
<!--<div class="right">-->
<!--<view class="p">-->
<!--<text class="span good-tag">平台商品</text>-->
<!--<text style="font-weight: bold">测试999</text>-->
<!--</view>-->
<!--<view class="p good-text">已领人数5人</view>-->
<!--<view class="p good-text">可领张数：11张</view>-->
<!--<view class="p good-button"><span>立即领取</span></view>-->
<!--</div>-->
<!--</view>-->
<!--</view>-->
<!--</view>-->
<!--</van-popup>-->

<view class="zangbudenglu" wx:if="{{loginshow}}">
  <view class="p">
    你还没登录,请登录后查看购物车
  </view>
  <view class="buttonContent">
    <view class="button" catchtap="gotologin">
      登录
    </view>
  </view>
</view>

<U_foot bindshowcarrfoot="showcarrfoot" bindshowcarrfoot_ipx="showcarrfoot_ipx"></U_foot>
