order-actions.vue 5.01 KB
<template>
  <div class="pane-body">
    <div
      class="video-wrapper"
      v-if="appraiseVideoUrl && pageName === 'list'"
      @click="() => onVideoHandler({videoUrl:appraiseVideoUrl, orderCode: order.orderCode})"
    >
      <div class="play-btn"></div>
      <div class="play-txt">鉴定视频</div>
    </div>
    <div class="after-video" v-else></div>
    <div class="actions-wrapper">
      <Button
        v-for="action in actionList"
        :key="action.code"
        @click="() => onActionHandler(action)"
      >{{ action.text }}</Button>
    </div>
  </div>
</template>

<script>
import { orderActionsMap, ownType } from "constants/order-constants";
import { createNamespacedHelpers } from "vuex";

const { mapActions } = createNamespacedHelpers("order/orderList");
const { mapMutations } = createNamespacedHelpers("address/address");

export default {
  props: {
    order: {
      type: Object,
      default: {}
    },
    pageName: {
      type: String,
      default: ""
    }
  },
  computed: {
    actionList: function() {
      return this.order.buttons;
    },
    appraiseVideoUrl: function() {
      return this.order.appraiseVideoUrl;
    }
  },
  methods: {
    ...mapActions([
      "deleteOrder",
      "cancelTradeConfirmInfo",
      "cancelTrade",
      "confirmReceipt"
    ]),
    ...mapMutations(["STORE_UPDATE_ADDRESS_INFO"]),
    onActionHandler(action) {
      const { owner = ownType.SELL } = this.$route.params;
      const {
        orderCode,
        priceInfo = {},
        goodsInfo = {},
        // 订单类表和订单详情地址信息返回地段不一致
        addressInfo,
        userAddress
      } = this.order;

      const { productId, storageId, skup } = goodsInfo;

      switch (action.name) {
        // 再次购买
        case orderActionsMap.BUY_AGAIN.name:
          this.$router.push({
            name: "ProductDetail",
            params: { productId }
          });
          break;

        // 查看详情
        case orderActionsMap.SHOW_DETAIL.name:
          const name =
            owner === ownType.SELL ? "sellOrderDetail" : "buyOrderDetail";
          this.$router.push({
            name,
            params: { owner, code: orderCode }
          });
          break;

        // 再次出售
        case orderActionsMap.SOLD_AGAIN.name:
          this.$router.push({
            name: "OrderSellConfirm",
            query: { productId, storageId }
          });
          break;

        // 查看物流
        case orderActionsMap.SHOW_EXPRESS.name:
          this.$router.push({
            name: "orderLogisticsInfo",
            params: { owner, code: orderCode }
          });
          break;
        // 调价
        // 非入住商家
        case orderActionsMap.NOT_ENTRY_CHANGE_PRICE.name:
          this.$router.push({
            name: "PriceChangeNoEntry",
            params: { orderCode }
          });
          break;

        // 入住商家
        case orderActionsMap.STORAGE_MANAGE.name:
          this.$router.push({
            name: "PriceChangeEntry",
            params: { orderId: productId }
          });
          break;

        // 我要发货
        case orderActionsMap.DELIVER_GOODS.name:
          this.$router.push({
            name: "order.deliver",
            params: { skup, code: orderCode }
          });
          break;

        // 修改地址
        case orderActionsMap.MODIFY_ADDRESS.name: {
          // 保存地址到store
          let info = JSON.stringify(addressInfo || userAddress || {});
          let updateInfo = JSON.parse(info || "{}");
          Object.assign(updateInfo, { isUpdate: true, orderCode: orderCode });
          this.STORE_UPDATE_ADDRESS_INFO(updateInfo);
          this.$router.push({
            name: 'addressEdit',
            query: {
              fromPage: 'OrderList'
            }
          });
          break;
        }

        default:
          this.$emit("on-action", action);
      }
    },
    onVideoHandler(params) {
      this.$emit("on-video", params);
    }
  }
};
</script>

<style lang="scss">
.action-dialog-content {
  text-align: center;
  color: #000;
}

.action-confirm {
  color: #d0021b;
}

.action-cancel {
  color: #000;
}
</style>

<style lang="scss" scoped>
.pane-body {
  display: flex;
  justify-content: space-between;
}

.video-wrapper {
  display: flex;
  align-items: center;

  .play-btn {
    width: 28.4px;
    height: 28.4px;
    background: url("~statics/image/order/play@3x.png");
    background-size: cover;
  }
  .play-txt {
    margin-left: 6.8px;
    color: #000;
    font-size: 24px;
    line-height: 1.4;
  }
}

.after-video {
  background-color: transparent;
}

.actions-wrapper {
  display: flex;
  justify-content: flex-end;

  button {
    font-size: 24px;
    padding: 18.4px 64px;
    color: #999;
    letter-spacing: 0;
    background: #fff;
    border: 1px solid #ccc;
    line-height: 1.4;
    margin-right: 20px;
    white-space: nowrap;
    border-radius: 40px;
  }

  & :last-child {
    background: #002b47;
    color: #fff;
    border: 1px solid #002b47;
    margin-right: 0;
  }
}
</style>