<!--pages/submit-order/submit-order.wxml-->
<view class="container">
  <view class='submit-order'>
    <!-- 收货地址 -->
    <view class='delivery-addr ' bindtap='toAddrListPage'>
      <view class='addr-bg ' wx:if="{{!userAddr}}">
        <view class='add-addr'>
          <view class='plus-sign-img'>
            <image src='../../images/icon/plus-sign.png'></image>
          </view>
          <text>新增收货地址</text>
        </view>
        <view class='arrow empty'></view>
      </view>
      <view class='addr-bg whole' wx:if="{{userAddr}}">
        <view class='addr-icon'>
          <image src='../../images/icon/addr.png'></image>
        </view>
        <view class='user-info'>
          <text class='item'>{{userAddr.receiver}}</text>
          <text class='item'>{{userAddr.mobile}}</text>
        </view>
        <view class='addr'>{{userAddr.address}}{{userAddr.addressName}}{{userAddr.addrDetail}}</view>
        <view class='arrow'></view>
      </view>
    </view>

    <view class="shop-item" wx:for="{{shopCartOrders}}" wx:key="shopId" wx:for-item="shopCart">
      <!-- 店铺信息 -->
      <view class="shop-box">
        <view class="shop-icon">
          <image src="../../images/icon/shop.png"></image>
        </view>
        <view class="shop-name">{{shopCart.shopName}}</view>
      </view>
      <!-- /店铺信息 -->

       <!-- 店铺商品明细 -->
      <view class='prod-item'>
        <block wx:for="{{shopCart.shopCartItemDiscounts}}"  wx:key='index' wx:for-item="shopCartItem">

          <view class="prod-block {{shopCartItem.chooseDiscountItemDto?'discount':''}}">
            <!-- 满减提示 -->
            <view class='discount-tips' hidden='{{!shopCartItem.chooseDiscountItemDto}}'>
              <text class='text-block'>{{wxs.parseDiscount(shopCartItem.chooseDiscountItemDto.discountRule)}}</text>
              <text class='text-list'>{{wxs.parseDiscountMsg(shopCartItem.chooseDiscountItemDto.discountRule,shopCartItem.chooseDiscountItemDto.needAmount,shopCartItem.chooseDiscountItemDto.discount)}}</text>
              <text class='text-list reduce-amount' wx:if="{{shopCartItem.chooseDiscountItemDto.reduceAmount > 0}}">已优惠 ￥{{wxs.parsePrice(shopCartItem.chooseDiscountItemDto.reduceAmount)[0]}}.{{wxs.parsePrice(shopCartItem.chooseDiscountItemDto.reduceAmount)[1]}}</text>
            </view>
          
            <block wx:for="{{shopCartItem.shopCartItems}}" wx:key='prodId'>
              <view class="item-box">
                <!-- 商品信息 -->
                <view class='item-cont'>
                  <view class='prod-pic'>
                    <image src='{{item.pic}}'></image>
                  </view>
                  <view class='prod-info'>
                    <view class='prodname'>
                      {{item.prodName}}
                    </view>
                    <view class='prod-info-cont'>{{item.skuName||''}}</view>
                    <view class='price-nums'>
                      <text class='prodprice'><text class='symbol'>￥</text>
                      <text class='big-num'>{{wxs.parsePrice(item.price)[0]}}</text>
                      <text class='small-num'>.{{wxs.parsePrice(item.price)[1]}}</text></text>
                      <text class="prodcount">×{{item.prodCount}}</text>
                    </view>
                  </view>
                </view>
              </view>
            </block>

          </view>


        </block>

        <!-- <view class='total-num'>
          <text class="prodcount">共{{totalCount}}件商品</text>
          <view class='prodprice'>合计：
            <text class='symbol'>￥</text>
            <text class='big-num'>{{wxs.parsePrice(total)[0]}}</text>
            <text class='small-num'>.{{wxs.parsePrice(total)[1]}}</text>
          </view>
        </view> -->
      </view>
      <!-- /店铺商品明细 -->

      <!-- 店铺优惠券和买家留言 -->
      <!-- <view class='order-msg'>
        <view class='msg-item'>
          <view class='item coupon' bindtap='showCouponPopup' data-index="{{index}}">
            <text class='item-tit'>优惠券：</text>
            <text class='coupon-btn' wx:if="{{!shopCart.shopCoupons.canUseLength}}">暂无可用</text>
            <text class='coupon-btn' wx:else>{{shopCart.shopCoupons.canUseLength}}张可用</text>
            <text class="coupon-amount" wx:if="{{shopCart.shopCoupons.couponAmount>0}}"><text class='symbol'>-￥</text>{{wxs.toPrice(shopCart.shopCoupons.couponAmount)}}</text>
            <text class='arrow'></text>
          </view>
          <view class='item'>
            <text>订单备注：</text>
            <input placeholder='选填，给商家留言' value="{{remarks}}" data-index="{{index}}" bindinput="onRemarkIpt"></input>
          </view>
        </view>

      </view> -->
      <!-- /店铺优惠券和买家留言 -->

    </view>



    <!-- 总金额计算 -->
    <view class='order-msg'>
      <view class='msg-item'>
        <!-- 平台优惠券 -->
        <!-- <view class='item coupon' bindtap='showCouponPopup' data-index="-1">
          <text class='item-tit'>平台优惠券：</text>
          <text class='coupon-btn' wx:if="{{!platformCoupons.canUseLength}}">暂无可用</text>
          <text class='coupon-btn' wx:else>{{platformCoupons.canUseLength}}张可用</text>
          <text class="coupon-amount" wx:if="{{platformCoupons.couponAmount > 0}}"><text class='symbol'>-￥</text>{{wxs.toPrice(platformCoupons.couponAmount)}}</text>
          <text class='arrow'></text>
        </view> -->
        <!-- 会员积分 -->
        <view class='item coupon' wx:if="{{maxUsableScore > 0}}">
          <view class="member-points">
            <view class="integral-wrap">
              <view class="integral-deduction">
                <text class="tit">积分抵扣： </text>
                <view class="integral-tips" wx:if="{{isScorePay==1}}" catchtap="handleScorePop">
                  <text wx:if="{{totalScoreAmount>0}}">{{scorePlaceholder}}</text>
                  <text wx:else> 请输入积分数量 <text wx:if="{{shopUseScore>100}}">(10的倍数)</text></text>
                  <image src='../../images/icon/revise.png' ></image>
                </view>   
                <view class="integral-tips" wx:if="{{isScorePay==0}}"> 不使用积分抵扣</view>
              </view>
            </view>
            <view class="integral-right-select">
                <checkbox color="#fbad4d" value="isScorePay" bindtap='useMemberPoints' class="item-group" checked="{{isChecked}}"></checkbox>
            </view>
          </view>
        </view>
        <!-- 起送价 -->
        <!-- <view class='item'>
          <view class='item-tit'>起送价：</view>
          <view class='item-txt price'>
            <text class='symbol'>￥</text>
            <text class='big-num'>{{wxs.parsePrice(deliveryAmount_num)[0]}}</text>
            <text class='small-num'>.{{wxs.parsePrice(deliveryAmount_num)[1]}}</text>
          </view>
        </view> -->
        <!-- 商品总额 -->
        <view class='item'>
          <view class='item-tit'>商品总额：</view>
          <view class='item-txt price'>
            <text class='symbol'>￥</text>
            <text class='big-num'>{{wxs.parsePrice(total)[0]}}</text>
            <text class='small-num'>.{{wxs.parsePrice(total)[1]}}</text>
          </view>
        </view>
        <!-- 运费 -->
        <view class='item'>
          <view class='item-tit'>{{dvyType}}</view>
          <view class='item-txt price'>
            <text class='symbol'>￥</text>
            <text class='big-num'>{{wxs.parsePrice(transfee)[0]}}</text>
            <text class='small-num'>.{{wxs.parsePrice(transfee)[1]}}</text>
          </view>
        </view>
        <!-- 运费 -->
        <view class='item' wx:if="{{freeTransfee}}">
          <view class='item-tit'>会员运费减免：</view>
          <view class='item-txt price'>
            <text class='symbol'>-￥</text>
            <text class='big-num'>{{wxs.parsePrice(freeTransfee)[0]}}</text>
            <text class='small-num'>.{{wxs.parsePrice(freeTransfee)[1]}}</text>
          </view>
        </view>
        <!-- 等级折扣金额 -->
        <view class='item' wx:if="{{totalLevelAmount}}">
          <view class='item-tit'>会员折扣金额：</view>
          <view class='item-txt price'>
            <text class='symbol'>-￥</text>
            <text class='big-num'>{{wxs.parsePrice(totalLevelAmount)[0]}}</text>
            <text class='small-num'>.{{wxs.parsePrice(totalLevelAmount)[1]}}</text>
          </view>
        </view>
        <!-- 积分 -->
        <view class='item'>
          <view class='item-tit'>积分({{totalAvailableScore||0}})：</view>
          <view class='item-txt price'>
            <text class='symbol'>-￥</text>
            <text class='big-num'>{{wxs.parsePrice(totalUsableScore)[0]}}</text>
            <text class='small-num'>.{{wxs.parsePrice(totalUsableScore)[1]}}</text>
          </view>
        </view>
        <!-- <view class='item'>
          <view class='item-tit'>积分：</view>
          <view class='item-txt price'>
            <text class='symbol'>-￥</text>
            <text class='big-num'>{{wxs.parsePrice(orderReduce)[0]}}</text>
            <text class='small-num'>.{{wxs.parsePrice(orderReduce)[1]}}</text>
          </view>
        </view> -->
        <!-- 优惠金额 -->
        <!-- <view class='item'>
          <view class='item-tit'>总优惠金额：</view>
          <view class='item-txt price'>
            <text class='symbol'>-￥</text>
            <text class='big-num'>{{wxs.parsePrice(orderReduce)[0]}}</text>
            <text class='small-num'>.{{wxs.parsePrice(orderReduce)[1]}}</text>
          </view>
        </view> -->
        <!-- <view class='item payment'>
          <view class='item-txt price'>
            小计：
            <text class='symbol'>￥</text>
            <text class='big-num'>{{wxs.parsePrice(actualTotal)[0]}}</text>
            <text class='small-num'>.{{wxs.parsePrice(actualTotal)[1]}}</text>
          </view>
        </view> -->
      </view>
    </view>
    <!-- /总金额计算 -->

    <view class='order-msg' style="margin-top: 20rpx;">
    <view class="msg-item">
      <view class='item'>
            <text>备注：</text>
            <input placeholder='选填，请先和商家协商一致，付款后商家可见' 	placeholder-style="font-size: 24rpx;color: #AAAAAA;" value="{{remarks}}" data-index="{{index}}" bindinput="onRemarkIpt"></input>
          </view>
    </view>
    </view>


  </view>

  <!-- 底部栏 -->
  <view class='submit-order-footer'>
    <view class='sub-order'>
      <view class='item-txt'>
        合计：
        <view class='price'>
          <text class='symbol'>￥</text>
          <text class='big-num'>{{wxs.parsePrice(actualTotal)[0]}}</text>
          <text class='small-num'>.{{wxs.parsePrice(actualTotal)[1]}}</text>
        </view>
      </view>
    </view>
    <view class='footer-box' bindtap='toPay'>
      提交订单
    </view>
  </view>
</view>

<!-- 选择优惠券弹窗 -->
<view class="popup-hide" hidden="{{!popupShow}}">
  <view class="popup-box">
    <view class="popup-tit">
      <text>优惠券</text>
      <text class="close" bindtap='closePopup'></text>
    </view>
    <view class="coupon-tabs">
      <view class="coupon-tab {{couponSts==1?'on':''}}" bindtap='changeCouponSts' data-sts='1'>可用优惠券({{showCoupons.canUseCoupons.length}})</view>
      <view class="coupon-tab {{couponSts==2?'on':''}}" bindtap='changeCouponSts' data-sts='2'>不可用优惠券({{showCoupons.unCanUseCoupons.length}})</view>
    </view>
    <view class='popup-cnt'>
      <view class="{{couponSts==1?'coupon-con':''}}">
        <block wx:for="{{showCoupons.canUseCoupons}}" wx:if="{{couponSts == 1}}" wx:key="index">
          <coupon item="{{item}}" index="{{index}}" order="{{true}}" bind:checkCoupon="checkCoupon" canUse="{{true}}"></coupon>
        </block>
        <block wx:for="{{showCoupons.unCanUseCoupons}}" wx:if="{{couponSts == 2}}" wx:key="index">
          <coupon item="{{item}}" order="{{true}}" canUse="{{false}}"></coupon>
        </block>
      </view>
      <view class="botm-empty"  wx:if="{{couponSts==1 && !showCoupons.canUseCoupons.length}}">这里还没有优惠券，快去领券吧~</view>
      <view class="botm-empty"  wx:if="{{couponSts==2 && !showCoupons.unCanUseCoupons.length}}">暂无相关优惠券</view>
    </view>
    <view class="coupon-ok" wx:if="{{couponSts==1}}">
      <text bindtap='choosedCoupon'>确定</text>
    </view>
  </view>
</view>

<!-- 积分输入框弹窗 -->
<view class="popup-hide" hidden="{{!showScorePop}}">
  <view class="popup-box score-pop">
    <view class='score-pop-con'>
    <view class="score-pop-tit">
      <text>修改抵扣积分</text>
      <text class="close" bindtap='closePopup'></text>
    </view>
      <view class="score-pop-item">
        <input class="score-int" type="number" placeholder-class="score-placeholder" value="{{userUseScore}}" placeholder="{{scorePopPlaceholder}}" bindinput="handleScoreInput"></input>
      </view>
      <view class="score-pop-item">
        <text class="confirm-btn" bindtap="confirmScore">确定</text>
      </view>
    </view>
  </view>
</view>


<wxs module="wxs" src="../../wxs/number.wxs" />
