in-sell-order-list.vue 3.08 KB
<template>
  <layout-app title="出售中">
    <div class="content-wrapper">
      <scroll
        @pulling-up="fetchData"
        @pulling-down="onRefresh"
        :options="options"
        :data="orderList"
        class="order-list-scroll-wrap"
        v-show="!isShowEmpty"
      >
        <ul class="list-wrapper">
          <li v-for="(order, i) in orderList" :key="i">
            <order-item :order="order" />
            <!-- 订单操作 -->
            <div class="footer-wrapper">
              <count-down :leftTime="order.leftTime" />
              <order-actions
                class="actions"
                :order="order"
                @on-action="action => onInSaleOrderAction({ action, order })"
              />
            </div>
          </li>
        </ul>
      </scroll>
      <empty-list
        class="empty-wrapper"
        tip="这里什么都没有..."
        v-show="isShowEmpty"
      />
    </div>
  </layout-app>
</template>

<script>
import { Scroll } from "cube-ui";
import { createNamespacedHelpers } from "vuex";

import OrderItem from "./components/in-sale-order-item";

import EmptyList from "components//ufo-no-item";

import OrderActions from "../components/order-actions";
import CountDown from "../components/count-down";

import orderInSaleActionMixin from "../mixin/order-in-sale-action";

const IN_SALE_STORE_PATH = "order/inSaleOrderList";

const {
  mapActions,
  mapState,
  mapGetters,
  mapMutations
} = createNamespacedHelpers(IN_SALE_STORE_PATH);

export default {
  // 订单操作
  mixins: [orderInSaleActionMixin],
  components: {
    Scroll,
    OrderItem,
    EmptyList,
    OrderActions,
    CountDown
  },
  computed: {
    ...mapState(["entryOrder", "notEntryOrder", "isShowEmpty"]),
    ...mapGetters(["orderList", "pullUpLoad"]),
    options: function() {
      return {
        pullUpLoad: this.pullUpLoad,
        pullDownRefresh: true
      };
    },
    isFetchEntryOrder() {
      return this.entryOrder.pullUpLoad;
    }
  },

  // 获取订单数据
  asyncData({ store, router }) {
    store.commit(`${IN_SALE_STORE_PATH}/resetData`);
    return store.dispatch(
      `${IN_SALE_STORE_PATH}/fetchEntryOrderList`,
      router.params
    );
  },
  methods: {
    ...mapActions(["fetchEntryOrderList", "fetchNotEntryOrderList"]),
    ...mapMutations(["resetData"]),
    onRefresh() {
      this.resetData();
      this.fetchData();
    },
    fetchData() {
      if (this.isFetchEntryOrder) {
        this.fetchEntryOrderList();
      } else {
        this.fetchNotEntryOrderList();
      }
    }
  }
};
</script>
<style lang="scss" scoped>
.content-wrapper {
  height: calc(100vh - 100px);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-box-orient: vertical;

  .empty-wrapper {
    margin: auto 0;
    position: absolute;
    top: 0;
    bottom: 0;
  }

  .footer-wrapper {
    display: flex;
    margin-top: 40px;

    .actions {
      flex: 1;
    }
  }

  .order-list-scroll-wrap {
    .list-wrapper {
      li {
        padding: 40px 40px;
        border-bottom: 1px solid #eee;
      }

      & :last-child {
        border-bottom: 0;
      }
    }
  }
}
</style>