<!-- 申请退款 -->
<!--pages/applyRefund/applyRefund.wxml-->

<view class="page">
  <!-- 头部商品信息 -->
  <view class="top-box">
    <text class="order-number">订单编号：{{orderNumber}}</text>
  </view>

  <!-- 整单退款 -->
  <view class="goods-msg-box">
    <block wx:for="{{orderItemDtos}}" wx:key='prodId' wx:if="{{refundItem.status >=2 && refundItem.orderItemDtos}}">
      <view class='item-cont' bindtap='toProdPage' data-prodid="{{item.prodId}}">
        <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'>
            <text class='skuname'>{{item.skuName||''}}</text> 
            <text class='number' decode="{{true}}">&nbsp;×{{item.prodCount}}</text>
          </view>
          <view class='price-nums clearfix'>
            <text class='prodprice'>
              <text class='symbol'>￥</text>
              <text class='big-num'>{{wxs.parsePrice(item.actualTotal)[0]}}</text>
              <text class='small-num'>.{{wxs.parsePrice(item.actualTotal)[1]}}</text>
            </text>
          </view>
        </view>
      </view>
    </block>
  </view>

  <!-- 单个退款 -->
  <view class="goods-msg-box" wx:if="{{!refundItem.orderItemDtos}}">
    <view class="img-box">
      <image src="{{refundItem.pic}}"></image>
    </view>
    <view class="goods-msg">
      <view class="goods-title">{{refundItem.prodName}}</view>
      <view class="goods-quantity">数量：{{refundItem.prodCount}}件</view>
    </view>
  </view>


  <!-- 退款方式 -->
  <view class="picker-box">
    <view class="select-show clearfix">
      <text class="select-text">退款方式</text>
      <!-- 仅退款/退货退款 -->
      <text class="select-results">{{['', '仅退款', '退货退款'][applyType]}}</text>
    </view>
  </view>
  <!-- 货物状态【已发货状态下且用户选择仅退款】 -->
  <!-- 订单状态 1:待付款 2:待发货 3:待收货 4:待评价 5:成功 6:失败 -->
  <picker class="picker-box" mode="selector" wx:for-idx="idx" bindchange="goodsStateArray" value="{{isReceiver}}" range="{{goodsStateArray}}" wx:if="{{refundItem.status >= 3 && refundItem.status!=6 && applyType==1}}">
    <view class="select-show select-box clearfix">
      <text class="select-text">货物状态</text>
      <text class="select-results select-reason">{{goodsStateArray[isReceiver]}}</text>
      <view class="right-arrow">
        <image src="../../images/icon/more.png"></image>
      </view>
    </view>
  </picker>

  <!-- 退款原因isReceiver: 0, //货物状态(1:已收到货 0:未收到货) -->
  <!-- 退款原因（已发货 || 已完成）&& 已收到货 -->
  <picker class="picker-box picker-reason" wx:if="{{refundItem.status != 2 && isReceiver == 1}}" mode="selector" bindchange="refundReasonChange" value="{{refundProdReasonArray[buyerReason]}}" range="{{refundProdReasonArray}}">
    <view class="select-show select-box clearfix">
      <text class="select-text">退款原因</text>
      <text class="select-results select-reason">{{refundProdReasonArray[buyerReason]}}</text>
      <view class="right-arrow">
        <image src="../../images/icon/more.png"></image>
      </view>
    </view>
  </picker>
  <!-- 退款原因（未发货 && 未收到货）|| (已发货 && 未收货) -->
  <picker class="picker-box picker-reason" wx:if="{{(refundItem.status == 2  || refundItem.status != 2) && isReceiver == 0}}" mode="selector" bindchange="refundReasonChange" value="{{refundPriReasonArray[buyerReason]}}" range="{{refundPriReasonArray}}">
    <view class="select-show select-box clearfix">
      <text class="select-text">退款原因</text>
      <text class="select-results select-reason">{{refundPriReasonArray[buyerReason]}}</text>
      <view class="right-arrow">
        <image src="../../images/icon/more.png"></image>
      </view>
    </view>
  </picker>


  <!-- 退货数量 -->
  <view class="refund-quantity clearfix" wx:if="{{applyType == 2 && refundType == 2}}">
    <text class="qua-text">退货数量</text>
    <view class="quantity-choose">
      <text class="reduce" data-st="0" bindtap="changePordNum">-</text>
      <input class="show-num" value="{{goodsNum}}" disabled="{{true}}" />
      <text class="add" data-st="1" bindtap="changePordNum">+</text>
    </view>
  </view>

  <!-- 退款金额 -->
  <view class="refund-sum-box">
    <view class="refund-sum">
      <label class="refund-sum-tit">退款金额</label>
      <!-- 如果是待发货状态且使用了平台分摊的优惠金额，则不允许修改退款金额（输入框不可输入） -->
      <text class="refund-sum-num" wx:if="{{refundItem.status==2 && refundItem.platformShareReduce >0}}">{{showPriAndScore}}</text>
      <text class="refund-sum-num" wx:else>{{showPriAndScore}}</text>
      <!-- <input wx:else class="refund-sum-num" type="digit " placeholder="请输入退款金额" value="{{showPriAndScore}}" bindinput="onRefInput" /> -->
    </view>

    <!-- 最多可退 -->
    <view class="refund-sum-tips">
      最多可退：<text>{{showNumAndCont}}</text>
    </view>

  </view>


  <!-- 退货信息 -->
  <view class="refund-message">
    <!-- 手机 -->
    <view class="item-num">
      <label class="item-num-tit">手机号码</label>
      <input class="item-num-num" type="number" placeholder="请输入退货人手机号码" maxlength="11" value="{{buyerMobile}}" bindinput="onMobileInput" />
    </view>
    <!-- 说明 -->
    <view class="item-num">
      <label class="item-num-tit">退款说明</label>
      <input class="item-num-num refund-explain" placeholder="必填，最多50字" maxlength="50" value="{{buyerDesc}}" bindinput="onDescInput" />
    </view>

    <!-- 上传照片 -->
    <view class="item-num">
      <label class="item-num-tit upload-tit">上传凭证</label>
      <view class="upload-img">
        <view class="upload-tips">可上传5张图片</view>
        <!-- 预览缩略图 -->
        <block wx:for="{{photoFiles}}" wx:key="*this" wx:for-index="idx" wx:for-item="imgItem">
          <view class="q-image-wrap">
            <!-- 图片缩略图  -->
            <image class="q-image" src="{{imgItem.url}}" mode="aspectFill" data-idx="{{idx}}" bindtap="refundPicPreView"></image>
            <!-- 移除图片的按钮  -->
            <view class="q-image-remover" data-idx="{{idx}}" data-index="{{index}}" bindtap="removeImage">
              <image src="../../images/icon/close2.png"></image>
            </view>
          </view>
        </block>
        <!-- 添加图片按钮 -->
        <view class="upload-btn" wx:if="{{photoFiles.length < 5}}" data-idx="{{index}}" bindtap="getUploadImg">+</view>
      </view>
    </view>
  </view>
  <!-- 退货信息end -->


  <!-- 提交btn -->
  <view class="submit-btn" bindtap="applyRefund">提交</view>



</view>


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