goodsVerification.vue 6.2 KB
<template>
  <div
    class="layout"
    v-if="flag"
  >
    <div class="box order">
      <div class="title">订单信息</div>
      <template v-for="(i,index) in orderObj">
        <div
          class="item"
          :key="index"
        >
          <div class="label">{{i.label}}:</div>
          <div class="value">
            <template v-if="i.format">
              {{ i.format(detail)}}
            </template>
            <template v-else>
              {{detail[i.key] || ''}}
            </template>
          </div>
        </div>
      </template>
    </div>
    <div class="box">
      <div class="title">订单商品</div>
      <div class="subtitle">{{detail.merchantName}}</div>
      <div class="goods-box">
        <template v-for="(i,index) in detail.orderGoods">
          <div
            class="item flex"
            :key="index"
          >
            <img
              :src="i.goodsImage"
              class="icon"
            >
            <div class="info flex">
              <div class="name">{{i.goodsName}}</div>
              <div class="price flex">
                ¥ {{i.activityPrice ||i.retailPrice || 0}}
                <div class="num">x{{i.goodsNumber || 1}}</div>
              </div>
            </div>
          </div>
        </template>
      </div>
    </div>
    <div class="box order-price">
      <div class="title">订单金额</div>
      <div class="flex item">
        <div class="label">商品总价:</div>
        <div class="value">¥{{price}}</div>
      </div>
      <div class="flex item">
        <div class="label">运费:</div>
        <div class="value">¥{{detail.expressFee}}</div>
      </div>
      <div class="total flex item">
        <div class="label">订单金额:</div>
        <div class="value">
          <span class="unit">¥</span>{{total}}
        </div>
      </div>
    </div>
    <div
      class="btn text-center"
      @click="submit"
      v-if="!hideBtn"
    >确认核销</div>
  </div>
</template>

<script type='text/ecmascript-6'>
import { shopmallApi } from '@/api'
export default {
  name: '',
  data () {
    return {
      flag: false,
      hideBtn: false,
      detail: {},
      total: 0,
      price: 0,
      orderObj: [
        {
          label: '客户姓名',
          key: 'customerName'
        },
        {
          label: '下单日期',
          format (item) {
            return new Date(item.createdDate).format('yyyy.MM.dd hh:mm')
          }
        },
        {
          label: '订单编号',
          key: 'orderCode'
        },
        {
          label: '收货地址',
          key: 'shipAddress'
        },
        {
          label: '订单状态',
          format (item) {
            return {
              1: '待付款',
              2: '已支付',
              3: '已关闭',
              4: '已发货',
              5: '已收货',
              6: '待发货',
              7: '待安装',
              8: '已安装',
              9: '售后中',
              10: '售后完成'
            }[item.orderStatus]
          }
        }
      ]
    }
  },
  activated () {
    let { verficationCode, orderCode } = this.getParams()
    this.showLoading()
    if (orderCode) this.getGoodsDetail(orderCode)
    else shopmallApi
      .getGoodsVerficationDetail(verficationCode)
      .then(res => {
        this.setData(res)
      })
  },
  mounted () {

  },
  deactivated () {
    Object.assign(this.$data, this.$options.data.call(this))
  },
  methods: {
    setData (res) {
      res.orderGoods.map(e => (this.price += e.activityPrice ? e.activityPrice : e.retailPrice))
      this.detail = res
      this.flag = true
      this.total = this.price + res.expressFee
      this.hideLoading()
    },
    getGoodsDetail (orderCode) {
      shopmallApi.getGoodsDetail(orderCode).then(res => {
        this.setData(res)
        this.hideBtn = true
      })
    },
    submit () {
      let { verficationCode } = this.getParams()
      this.showLoading()
      shopmallApi
        .verficationGoods(verficationCode)
        .then(res => {
          this.hideLoading()
          if (res) {
            this.$route.params.isGoods = true
            this.showToast('已核销', () => {
              this.$router.back()
            })
          }
        })
    }
  }
}
</script>

<style scoped lang='scss'>
.layout {
  padding: 0 16px 60px;
  .box {
    background: linear-gradient(180deg, #ffffff 0%, #ffffff 100%);
    border-radius: 4px;
    padding: 12px;
    margin-top: 10px;
    font-size: 12px;
    .title {
      font-size: 16px;
      font-weight: 500;
      color: #282829;
      margin-bottom: 12px;
    }
    .subtitle {
      color: #2d2d2e;
      margin-bottom: 16px;
    }
    .goods-box {
      .item {
        margin-bottom: 20px;
        .icon {
          width: 80px;
          height: 80px;
          margin-right: 10px;
        }
        .info {
          width: calc(100% - 90px);
          height: 80px;
          flex-direction: column;
          justify-content: space-between;
          align-items: flex-start;
          .name {
            font-size: 15px;
            font-weight: 500;
            color: #333333;
          }
          .price {
            font-size: 14px;
            color: #3975c6;
            width: 100%;
            .num {
              margin-left: auto;
              color: #656566;
            }
          }
        }
        &:last-of-type {
          margin-bottom: 0;
        }
      }
    }
  }
  .order {
    .item {
      display: flex;
      color: #282829;
      line-height: 24px;
      .label {
        width: 70px;
        flex-shrink: 0;
      }
      .value {
        width: 246px;
        color: #656566;
      }
    }
  }
  .order-price {
    .item {
      justify-content: space-between;
      font-size: 12px;
      color: #656566;
      line-height: 30px;
      .value {
        font-weight: 600;
        font-size: 14px;
        color: #3975c6;
        .unit {
          font-size: 12px;
        }
      }
    }
    .total {
      margin-bottom: 2px;
      border-top: 1px solid #e3e3e6;
    }
  }
  .btn {
    position: fixed;
    width: 343px;
    left: 50%;
    bottom: 16px;
    transform: translateX(-50%);
    height: 42px;
    font-size: 14px;
    border-radius: 21px;
    box-sizing: border-box;
  }
}
</style>