<template>
  <div class="content">
    <div class="return-detail">
      <div class="crumbs">
        <nuxt-link to="/user-center/uc-return" class="item-a">{{$t('applyReturn.refundList')}}</nuxt-link>
        <span class="arrow">></span>
        <span class="item-span">{{$t('applyReturn.refundDetails')}}</span>
      </div>
      <div class="return-step">
        <div
          :class="['item', ((refundDetail.returnMoneySts <= 4 && refundDetail.returnMoneySts != -1) || refundDetail.returnMoneySts == 5)?'active':'']"
        >
          <div class="number">●</div>
          <div class="text">{{$t('applyReturn.buyerSubmits')}}</div>
          <div class="time">{{refundDetail.applyTime}}</div>
        </div>
        <div
          :class="['item', (refundDetail.returnMoneySts >=2 && refundDetail.returnMoneySts <=5)?'active':'']"
        >
          <div class="number">●</div>
          <div class="text">{{$t('applyReturn.sellerProcessing')}}</div>
          <div
            class="time"
            v-if="refundDetail.returnMoneySts >=2 && refundDetail.returnMoneySts <=5"
          >{{refundDetail.handelTime}}</div>
        </div>
        <div
          :class="['item', (refundDetail.returnMoneySts >=3 && refundDetail.returnMoneySts <=5)?'active':'']"
          v-if="refundDetail.applyType == 2"
        >
          <div class="number">●</div>
          <div class="text">{{$t('applyReturn.buyerReturns')}}</div>
          <div
            class="time"
            v-if="refundDetail.returnMoneySts >=3 && refundDetail.returnMoneySts <=5"
          >{{refundDetail.shipTime}}</div>
        </div>
        <div :class="['item', (refundDetail.returnMoneySts == 5)?'active':'']">
          <div class="number">●</div>
          <div class="text">{{$t('applyReturn.refundCompleted')}}</div>
          <div class="time" v-if="refundDetail.returnMoneySts == 5">{{refundDetail.refundTime}}</div>
        </div>
      </div>
      <div :class="['return-order',this.$store.state.locale == 'en'?'en':'']">
        <table cellspacing="0" cellpadding="0" class="order-box">
          <tbody>
            <tr class="box-tit">
              <th>{{$t('applyReturn.productInformation')}}</th>
              <th width="130">{{$t('applyReturn.transactionTime')}}</th>
              <th width="127">{{$t('applyReturn.numberOfApplications')}}</th>
              <th width="160">{{$t('applyReturn.refundAmount')}}</th>
              <th width="127">{{$t('status')}}</th>
              <th width="127">{{$t('operation')}}</th>
            </tr>
            <tr class="box-space">
              <td colspan="6"></td>
            </tr>
            <!-- 表格头 -->
            <tr class="box-hd">
              <td colspan="6">
                <div class="order-number">
                  {{$t('applyReturn.orderNumber')}}：
                  <span class="num">{{refundDetail.orderNumber}}</span>
                </div>
                <div class="return-number">
                  {{$t('applyReturn.refundNumber')}}：
                  <span class="num">{{refundSn}}</span>
                </div>
                <nuxt-link :to="'/shopIndex?sid='+refundDetail.shopId" class="shop">
                  <span class="shop-icon"></span>
                  {{refundDetail.shopName}}
                </nuxt-link>
              </td>
            </tr>
            <tr class="box-tr" v-for="(refundItem,index) in prodList" :key="index">
              <!-- 商品信息 -->
              <td>
                <div
                  class="goods-info"
                  :class="{'gift-goods-info': refundItem.giveawayOrderItemId}"
                  @click="toProdDetails(refundItem.prodId, refundItem.giveawayOrderItemId)">
                  <div class="img">
                    <img v-if="refundItem.pic" :src="refundItem.pic.indexOf('http') == -1 ? picDomain + refundItem.pic : refundItem.pic"  @error="handlePicError"/>
                    <img v-else src="~/assets/img/def.png" alt />
                  </div>
                  <div class="name-sku">
                    <div class="name">{{refundItem.prodName}}</div>
                    <div class="sku">
                      <span v-if="refundItem.giveawayOrderItemId" class="gift-icon">{{$t('prodDetail.gift')}}</span>
                      <span>{{refundItem.skuName}} x{{refundItem.prodCount}}</span>
                      <!-- <span v-if="refundItem.giveawayOrderItemId">×{{ refundItem.prodCount }}</span> -->
                    </div>
                  </div>
                </div>
                <!-- 赠品：多件商品时展示 -->
                <div
                  v-if="refundDetail.orderItems.length > 1 && refundItem.giveawayList && refundItem.giveawayList.length"
                  class="gift-info">
                  <div
                    v-for="(gitfItem, gitfIndex) in refundItem.giveawayList"
                    :key="gitfIndex"
                    class="gift-item"
                    @click="toProdDetails(gitfItem.prodId, gitfItem.giveawayOrderItemId)"
                  >
                    <span class="name">{{ '【' + $t('prodDetail.gift') + '】' +  gitfItem.prodName }}</span>
                    <span class="num">×{{ gitfItem.prodCount }}</span>
                  </div>
                </div>
                <!-- / 赠品 -->
              </td>
              <!-- 成交时间 -->
              <td :rowspan="prodList.length" v-if="index==0">
                <div class="deal-time">{{refundDetail.orderPayTime}}</div>
              </td>
              <!-- 数量 -->
              <td :rowspan="prodList.length" v-if="index==0">
                <div class="apply-number">{{refundDetail.goodsNum}}</div>
              </td>
              <!-- 金额 -->
              <td :rowspan="prodList.length" v-if="index==0">
                <div class="price-box">
                  <div class="all-price">{{$t('applyReturn.total')}}：<i v-if="refundDetail.orderAmount">￥{{Number(refundDetail.orderAmount).toFixed(2)}}</i><i v-if="refundDetail.orderAmount && refundDetail.refundScore">&nbsp;+&nbsp;</i><i v-if="refundDetail.refundScore">{{refundDetail.refundScore}}{{$t('applyReturn.points')}}</i></div>
                  <div class="return-price">{{$t('applyReturn.refunds')}}：<i v-if="refundDetail.refundAmount">￥{{Number(refundDetail.refundAmount).toFixed(2)}}</i><i v-if="refundDetail.refundAmount && refundDetail.refundScore">&nbsp;+&nbsp;</i><i v-if="refundDetail.refundScore">{{refundDetail.refundScore}}{{$t('applyReturn.points')}}</i></div>
                  <!--
                    修改退款金额：
                    1、仅退款(applyTyp:1)：买家申请(returnMoneySts:1)状态下可以修改
                    2、退货退款(applyTyp:2)：买家申请(returnMoneySts:1) ||
                                          卖家处理(returnMoneySts:2) ||
                                          买家发货(returnMoneySts:3)
                                          状态下可以修改
                    3、整单退款(refundType:1)：不可修改
                    4、isUsedPlatformReduce 是否使用了平台优惠 （是 则不可修改）
                  -->
                  <div
                    v-if="refundDetail.refundType !== 1 &&
                          ((refundDetail.applyType == 1 &&
                          refundDetail.returnMoneySts == 1) ||
                          (refundDetail.applyType == 2 &&
                          (refundDetail.returnMoneySts == 1 ||
                          refundDetail.returnMoneySts == 2 ||
                          refundDetail.returnMoneySts == 3))) && !isUsedPlatformReduce"
                    class="action-a"
                    @click="modifyRefundAmount()">{{$t('applyReturn.modifyRefundAmount')}}</div>
                </div>
              </td>
              <!-- 状态 -->
              <td :rowspan="prodList.length" v-if="index==0">
                <div class="status-box">
                  <div class="type">{{['',$t('applyReturn.refundsOnly'),$t('applyReturn.returnsAndRefunds')][refundDetail.applyType]}}</div>
                  <div
                    class="status"
                  >{{['',$t('applyReturn.buyerApplication'),$t('applyReturn.sellerAcceptance'),$t('applyReturn.buyerShipping'),$t('applyReturn.sellerReceipt'),$t('applyReturn.successfulRefund'),$t('applyReturn.buyerWithdrawsApplication'),$t('applyReturn.merchantRefusal')][refundDetail.returnMoneySts]}}</div>
                  <div class="status" v-if="refundDetail.returnMoneySts == -1">{{$t('applyReturn.refundClose')}}</div>
                </div>
              </td>
              <!-- 操作 -->
              <td :rowspan="prodList.length" v-if="index==0">
                <div>
                  <!-- (买家申请 || 卖家接受 || 商家拒绝) || isCancel可撤销 -->
                  <a
                    href="JavaScript:void(0)"
                    class="action-a"
                    @click="cancelApply"
                    v-if="(refundDetail.returnMoneySts == 1 || refundDetail.returnMoneySts == 2 || refundDetail.returnMoneySts == 7) && refundDetail.isCancel"
                  >{{$t('applyReturn.applicationTips5')}}</a>
                  <a href="JavaScript:void(0)" v-else class="action-a cannotuse">{{$t('applyReturn.applicationTips5')}}</a>
                </div>
                <a
                  href="JavaScript:void(0)"
                  v-if="refundDetail.returnMoneySts == 2 && refundDetail.applyType == 2"
                  class="action-a"
                  @click="writeLogisticsMsg"
                >{{$t('applyReturn.fillLogistics')}}</a>
                <a
                  href="JavaScript:void(0)"
                  v-if="refundDetail.returnMoneySts == 3 && refundDetail.applyType == 2"
                  class="action-a"
                  @click="writeLogisticsMsg"
                >{{$t('applyReturn.modifyLogistics')}}</a>
                <!-- <a
                  href="JavaScript:void(0)"
                  v-if="refundDetail.returnMoneySts == 2 && refundDetail.applyType == 2 && refundDetail.isCancel"
                  class="action-b"
                  @click="cancelApply"
                >撤销申请</a> -->
              </td>
            </tr>
          </tbody>
        </table>
      </div>
      <!-- 退款进度 -->
      <div class="return-progress">
        <div class="tit">{{$t('applyReturn.refundProgress')}}</div>
        <!-- 申请关闭 -->
        <div class="item" v-if="refundDetail.returnMoneySts == -1">
          <div class="time">{{refundDetail.updateTime}}</div>
          <div class="text-box">
            <!-- <div class="name">{{nickName}}</div> -->
            <div class="name">{{$t('applyReturn.applicationClosed')}}</div>
          </div>
        </div>
        <!-- 买家撤销 -->
        <div
          class="item"
          v-if="(refundDetail.returnMoneySts == 6 || refundDetail.returnMoneySts == -1) && refundDetail.cancelTime"
        >
          <div class="time">{{refundDetail.cancelTime}}</div>
          <div class="text-box">
            <div class="name">{{nickName}}</div>
            <div class="text">{{$t('applyReturn.refundReason14')}}</div>
          </div>
        </div>
        <!-- 商家拒绝 -->
        <div
          class="item"
          v-if="(refundDetail.returnMoneySts == 7 || refundDetail.returnMoneySts == -1) && refundDetail.rejectTime || refundDetail.rejectMessage"
        >
          <div class="time">{{refundDetail.rejectTime}}</div>
          <div class="text-box">
            <div class="name">{{refundDetail.shopName}}</div>
            <div class="text">
              <p>{{$t('applyReturn.refundReason15')}}</p>
              <p v-if="refundDetail.rejectMessage">{{$t('applyReturn.reasonsRejection')}}："{{refundDetail.rejectMessage}}"</p>
              <p v-if="refundDetail.sellerMsg">{{$t('applyReturn.sellerRemarks')}}："{{refundDetail.sellerMsg}}"</p>
              <p>{{$t('applyReturn.refundReason16')}}</p>
            </div>
          </div>
        </div>
        <!-- 退款成功 -->
        <div class="item" v-if="refundDetail.returnMoneySts == 5 && refundDetail.refundTime">
          <div class="time">{{refundDetail.refundTime}}</div>
          <div class="text-box">
            <div class="name">{{refundDetail.shopName}}</div>
            <div class="text">{{$t('applyReturn.refundReason17')}}</div>
            <p v-if="refundDetail.sellerMsg">{{$t('applyReturn.sellerRemarks')}}："{{refundDetail.sellerMsg}}"</p>
          </div>
        </div>
        <!-- 卖家收到寄回货物 -->
        <div
          class="item"
          v-if="((refundDetail.returnMoneySts == 4 || refundDetail.returnMoneySts == 5) && refundDetail.applyType == 2) && refundDetail.receiveTime"
        >
          <div class="time">{{refundDetail.receiveTime}}</div>
          <div class="text-box">
            <div class="name">{{refundDetail.shopName}}</div>
            <div class="text">{{$t('applyReturn.refundReason18')}}</div>
            <p v-if="refundDetail.sellerMsg">{{$t('applyReturn.sellerRemarks')}}："{{refundDetail.sellerMsg}}"</p>
          </div>
        </div>
        <!-- 买家寄出 -->
        <div
          class="item"
          v-if="((refundDetail.returnMoneySts > 2 && refundDetail.returnMoneySts < 6) && refundDetail.applyType == 2) && refundDetail.shipTime"
        >
          <div class="time">{{refundDetail.shipTime}}</div>
          <div class="text-box">
            <div class="name">{{nickName}}</div>
            <div class="text">
              {{$t('applyReturn.refundReason19')}}
              <span class="distance">{{$t('applyReturn.logisticsCompany')}}：{{refundDelivery.deyName}}</span>
              <span class="distance">{{$t('applyReturn.shipmentNumber')}}：{{refundDelivery.deyNu}}</span>
            </div>
          </div>
        </div>
        <!-- 卖家同意，给出地址 -->
        <div
          class="item"
          v-if="((refundDetail.returnMoneySts > 1 && refundDetail.returnMoneySts < 6) && refundDetail.applyType == 2) && refundDetail.handelTime"
        >
          <!-- (refundDetail.returnMoneySts == 2 && refundDetail.applyType == 2) &&  -->
          <div class="time">{{refundDetail.handelTime}}</div>
          <div class="text-box">
            <div class="name">{{refundDetail.shopName}}</div>
            <div class="text">
              <p>{{$t('applyReturn.refundReason20')}}</p>
              <p>{{$t('applyReturn.refundAddress')}}：{{ refundDelivery.receiverName}}&nbsp;&nbsp;{{refundDelivery.receiverMobile}}&nbsp;&nbsp;{{refundDelivery.receiverAddr}}</p>
              <p v-if="refundDetail.sellerMsg">{{$t('applyReturn.sellerRemarks')}}："{{refundDetail.sellerMsg}}"</p>
            </div>
          </div>
        </div>
        <!-- 卖家同意 -->
        <div
          class="item"
          v-if="((refundDetail.returnMoneySts > 1 && refundDetail.returnMoneySts < 6) && refundDetail.applyType == 1) && refundDetail.decisionTime"
        >
          <div class="time">{{refundDetail.decisionTime}}</div>
          <div class="text-box">
            <div class="name">{{refundDetail.shopName}}</div>
            <div class="text">
              <p>{{$t('applyReturn.refundReason20')}}</p>
              <p v-if="refundDetail.sellerMsg">{{$t('applyReturn.sellerRemarks')}}："{{refundDetail.sellerMsg}}"</p>
            </div>
          </div>
        </div>
        <!-- 买家申请 -->
        <div class="item">
          <div class="time">{{refundDetail.applyTime}}</div>
          <div class="text-box">
            <div class="name">{{nickName}}</div>
            <div class="text">
              <p>
                <span class="distance ft">{{$t('applyReturn.buyerRequestRefund')}}</span>
                <span class="distance">{{$t('applyReturn.refundType')}}：{{['',$t('applyReturn.refundsOnly'),$t('applyReturn.returnsAndRefunds')][refundDetail.applyType]}}</span>
                <span class="distance">{{$t('applyReturn.refundAmount')}}：<i v-if="refundDetail.refundAmount">￥{{Number(refundDetail.refundAmount).toFixed(2)}}</i><i v-if="refundDetail.refundAmount && refundDetail.refundScore">&nbsp;+&nbsp;</i><i v-if="refundDetail.refundScore">{{refundDetail.refundScore}}{{$t('applyReturn.points')}}</i></span>
                <span class="distance">{{$t('applyReturn.refundReason')}}：{{refundReasonArray[refundDetail.buyerReason]}}</span>
              </p>
              <p v-if="refundDetail.buyerDesc">{{$t('applyReturn.refundDescription')}}："{{refundDetail.buyerDesc}}"</p>
              <p class="ref-voucher" v-if="refundDetail.photoFiles">{{$t('applyReturn.refundVoucher')}}：
                <el-image class="ref-img" :key="pic" :src="pic" v-for="pic in refundDetail.photoFiles.split(',')" :preview-src-list="refundDetail.photoFiles.split(',')"></el-image>
              </p>
            </div>
          </div>
        </div>
      </div>

      <!-- 物流进度 -->
      <div class="return-progress" v-if="deliveryDto && deliveryDto.traceFlag">
        <div v-if="deliveryDto.traceFlag">
          <div class="tit">{{$t('orderDetails.logisticsStatus')}}</div>
          <!-- 申请关闭 -->
          <div class="item" v-for="(logItem,logIndex) in deliveryDto.traces" :key="logIndex">
            <div class="time">{{logItem.acceptTime}}</div>
            <div class="text-box">
              <!-- <div class="name">{{nickName}}</div> -->
              <div class="name acceptStation">{{logItem.acceptStation}}</div>
            </div>
          </div>
        </div>
      </div>

    </div>

    <!-- 修改退款金额弹窗 -->
    <div class="popup-mask" v-if="isModifyRefundAmount"></div>
    <div class="popup-box" v-if="isModifyRefundAmount">
      <div class="tit">
        <div class="text">{{$t('applyReturn.modifyRefundAmount')}}</div>
        <div class="close" @click="isModifyRefundAmount = false"></div>
      </div>
      <div class="con modify-amount">
        <div class="int-box">
          <input
            v-model="modifyAmount"
            type="text"
            class="int"
            :placeholder="this.$t('applyReturn.pleaseEnterAmount')"
            @blur="handleAmountInput"
            @focus="handleAmountInput"
          >
          <div v-if="!refundAmountError" class="max-amount">
            {{$t('applyReturn.maximumRefundable')}}￥{{maxRefundAmount}}
          </div>
          <div v-if="refundAmountError" class="error">
            {{ modifyAmount && Number.parseFloat(modifyAmount) > Number.parseFloat(maxRefundAmount)
              ? `${$t('applyReturn.maximumRefundable')}￥${maxRefundAmount}，${$t('applyReturn.reEnter')}`
              : $t('applyReturn.pleaseEnterAmount')}}
          </div>
        </div>
        <div class="foot-btn">
          <span class="confirm" @click="requestModify">{{$t('login.confirmChanges')}}</span>
        </div>
      </div>
    </div>
    <!-- / 修改退款金额弹窗 -->

    <!-- 物流信息弹框 -->
    <writeLogisticsInfo
      v-if="showAdd"
      @toggleAddrPop="refreshChange"
      :refundSn="refundSn"
      :orderNumber="refundDetail.orderNumber"
      :refundDelivery="refundDetail.refundDelivery"
      :returnMoneySts="refundDetail.returnMoneySts"
    ></writeLogisticsInfo>
    <!-- /物流信息弹框 -->
  </div>
</template>

<script>
import writeLogisticsInfo from '~/components/write-logistics-info'
import { picDomain } from '~/plugins/config.js'
import big from '~/plugins/big.min.js'

export default {
  components: {
    writeLogisticsInfo
  },
  data () {
    return {
      // 图片地址
      picDomain: picDomain,
      // refundReasonArray: ['拍错/多拍/不喜欢', '协商一致退款', '商品破损/少件', '商品与描述不符', '卖家发错货', '质量问题', '其他','','拼团失败'],
      refundSn: this.$route.query.refundSn,  //退款编号
      refundDetail: {},  //退款订单详情对象
      // orderItems: [],  //订单项
      refundDelivery: {}, //收货地址对象
      deliveryDto:{}, // 物流进度
      nickName: '',  //用户名
      showAdd: false,  //物流信息弹框显隐

      prodList: [], // 赠品列表

      isModifyRefundAmount: false, // 修改金额弹窗
      modifyAmount: '', // 修改金额
      refundAmountError: false,
      // 退款项中是否使用了平台优惠 (使用了则不能修改退款金额)
      isUsedPlatformReduce: false,
      maxRefundAmount: 0
    }
  },
  mounted () {
    let nickName = this.$store.state.user.nickName
    this.nickName = nickName
    this.getRefundDetail() //获取退款订单详情
  },
  computed: {
    // 退款原因（总）
    refundReasonArray: function(){
      return [this.$i18n.t('applyReturn.refundReason1'), this.$i18n.t('applyReturn.refundReason2'), this.$i18n.t('applyReturn.refundReason3'), this.$i18n.t('applyReturn.refundReason4'), this.$i18n.t('applyReturn.refundReason5'), this.$i18n.t('applyReturn.refundReason6'), this.$i18n.t('applyReturn.refundReason7'), '', this.$i18n.t('applyReturn.refundReason8')]
    }
  },
  methods: {
    /**
     * 加载默认图片
     */
    handlePicError(e){
       e.target.src=require('@/assets/img/def.png')
    },

    /**
     * 获取退款订单详情
     */
    getRefundDetail () {
      this.$axios.get('/p/orderRefund/info?refundSn=' + this.refundSn)
        .then(({ data }) => {
          let isUsedPlatformReduce = false
          data.orderItems.forEach(orderItem => {
            if (orderItem.platformShareReduce && !isUsedPlatformReduce) {
              isUsedPlatformReduce = true
            }
          })
          this.maxRefundAmount = data.maxRefundAmount
          this.isUsedPlatformReduce = isUsedPlatformReduce
          this.refundDetail = data
          this.orderItems = data.orderItems[0]
          this.refundDelivery = data.refundDelivery
          this.deliveryDto = data.deliveryDto

          if (this.deliveryDto) {
             if (!data.deliveryDto.traces || !data.deliveryDto.traces.length) {
               this.deliveryDto.traceFlag = false
             }
             else { this.deliveryDto.traceFlag = true}
          } else {
            this.deliveryDto = {}
            this.deliveryDto.traceFlag = false
          }

          // 商品列表
          this.prodList = this.prodList.splice(0, this.prodList)
          const prods = data.orderItems
          this.prodList = prods
          if (prods && prods.length === 1 && prods[0].giveawayList && prods[0].giveawayList.length) {
            // 如果有赠品，单个商品时，将主商品和赠品放在同一级列表展示
            this.prodList = [...prods, ...prods[0].giveawayList]
          }
        })
    },
    /**
     * 撤销申请
     */
    cancelApply () {
      // 买家申请 || 卖家接受 || 卖家拒绝
      if (this.refundDetail.returnMoneySts == 1 || this.refundDetail.returnMoneySts == 7 || this.refundDetail.returnMoneySts == 2) {
        this.$confirm(this.$i18n.t('applyReturn.refundReason11'), this.$i18n.t('applyReturn.tips'), {
          confirmButtonText: this.$i18n.t('determine'),
          cancelButtonText: this.$i18n.t('cancel'),
          type: 'warning'
        }).then(() => {
          this.$axios.put('/p/orderRefund/cancel', this.refundSn)
            .then(({ data }) => {
              this.$message({
                message: this.$i18n.t('applyReturn.refundReason12'),
                duration: 1000,
                type: 'success'
              });
              // this.$router.push({ path: '/user-center/uc-return' })
              this.getRefundDetail()
            })
        }).catch(() => { });
      }
    },

    /**
     * 填写 || 修改物流信息
     */
    writeLogisticsMsg () {
      this.showAdd = true
    },
    /**
    * 刷新回调
    */
    refreshChange (visible) {
      this.showAdd = visible
    },

    /**
    * 跳转到商品详情页
    */
    toProdDetails (prodId, giveawayOrderItemId) {
      if (!giveawayOrderItemId) {
        return
      }
      this.$router.push({ path: '/detail/' + prodId })
    },

    /**
     * 修改退款金额
     */
    modifyRefundAmount() {
      this.modifyAmount = ''
      this.refundAmountError = false
      this.isModifyRefundAmount = true
    },

    handleAmountInput() {
      this.refundAmountError = false
      if (!this.modifyAmount || !this.modifyAmount.trim()) {
        this.modifyAmount = this.modifyAmount.trim()
        return
      }
      this.modifyAmount = this.checkInput(this.modifyAmount)
    },
    checkInput (num) {
      if (num) {
        var tmpVal = num.replace(/[^\d^\\.]/g, '')
        var reg = /^(0|([1-9]\d*))(\.\d{1,2})?$/ // 最多允许后输入两位小数
        if (!reg.test(tmpVal)) {
          tmpVal = tmpVal + ''
          tmpVal = tmpVal.substring(0, tmpVal.indexOf('.') + 3)
          var n = (tmpVal.split('.')).length - 1
          if (n > 1) {
            tmpVal = tmpVal.substring(0, tmpVal.indexOf('.'))
          }
        }
        return tmpVal
      } else {
        return ''
      }
    },
    requestModify() {
      if (!this.modifyAmount || !this.modifyAmount.trim() || this.modifyAmount <= 0) {
        this.modifyAmount = this.modifyAmount.trim()
        this.refundAmountError = true
        return
      }
      if (Number.parseFloat(this.modifyAmount) > Number.parseFloat(this.maxRefundAmount)) {
        this.refundAmountError = true
        return
      }
      const param = {
        refundAmount: this.modifyAmount,
        refundSn: this.refundSn
      }
      this.$axios.put('/p/orderRefund/updateRefundAmount', param)
        .then(({ data }) => {
          this.$message({
            message: '修改成功',
            type: 'success',
            duration: 1000
          })
          this.isModifyRefundAmount = false
          this.refundAmountError = false
          this.refundAmount = ''
          this.getRefundDetail()
        })
    }


  },
}
</script>
<style scoped src='~/assets/css/return-detail.css'></style>
