Authored by lea guo

出售订单列表

1 -<template>  
2 - <scroll class="order-list-wrapper"> </scroll>  
3 -</template>  
4 -  
5 -<script>  
6 -import { Scroll } from "cube-ui";  
7 -export default {  
8 - components: {  
9 - Scroll  
10 - }  
11 -};  
12 -</script>  
13 -  
14 -<style lang="scss" scoped>  
15 -.order-list-wrapper {  
16 - height: 100vh;  
17 -}  
18 -</style>  
  1 +<template>
  2 + <div class="content-wrapper">
  3 + <scroll
  4 + @pulling-up="fetchData"
  5 + :options="options"
  6 + :data="orderList"
  7 + class="order-list-scroll-wrap"
  8 + >
  9 + <ul class="list-wrapper">
  10 + <li v-for="order in orderList" :key="order.orderCode">
  11 + <order-list-item :order="order" />
  12 + <!-- 订单操作 -->
  13 + <order-actions :order="order" />
  14 + </li>
  15 + </ul>
  16 + </scroll>
  17 + </div>
  18 +</template>
  19 +
  20 +<script>
  21 +import { Button, Scroll } from "cube-ui";
  22 +import { createNamespacedHelpers } from "vuex";
  23 +import OrderListItem from "./components/order-list-item";
  24 +import OrderActions from "../components/order-actions";
  25 +
  26 +const { mapActions, mapState, mapGetters } = createNamespacedHelpers(
  27 + "order/inSaleOrderList"
  28 +);
  29 +
  30 +export default {
  31 + components: {
  32 + Button,
  33 + Scroll,
  34 + OrderListItem,
  35 + OrderActions
  36 + },
  37 + computed: {
  38 + ...mapState(["entryOrder", "notEntryOrder"]),
  39 + ...mapGetters(["orderList", "pullUpload"]),
  40 + options: function() {
  41 + return {
  42 + pullUpload: this.pullUpload
  43 + };
  44 + },
  45 + isFetchEntryOrder() {
  46 + return this.entryOrder.pullUpload;
  47 + }
  48 + },
  49 +
  50 + // 获取订单数据
  51 + asyncData({ store, router }) {
  52 + // const { owner, status } = router.params;
  53 + // store.dispatch("order/orderList/fetchOrderList", { owner, status });
  54 + },
  55 + mounted() {
  56 + this.fetchData();
  57 + },
  58 + methods: {
  59 + ...mapActions(["fetchEntryOrderList", "fetchNotEntryOrderList"]),
  60 + fetchData() {
  61 + if (this.isFetchEntryOrder) {
  62 + this.fetchEntryOrderList(this.$route.params);
  63 + } else {
  64 + this.fetchNotEntryOrderList(this.$route.params);
  65 + }
  66 + }
  67 + },
  68 + watch: {
  69 + isFetchEntryOrder(val) {
  70 + if (!val) {
  71 + this.fetchData();
  72 + }
  73 + }
  74 + }
  75 +};
  76 +</script>
  77 +<style lang="scss" scoped>
  78 +.content-wrapper {
  79 + height: calc(100vh);
  80 + overflow-x: hidden;
  81 + overflow-y: auto;
  82 + -webkit-box-orient: vertical;
  83 +
  84 + .order-list-scroll-wrap {
  85 + .list-wrapper {
  86 + li {
  87 + padding: 40px 40px;
  88 + border-bottom: 1px solid #eee;
  89 + }
  90 +
  91 + & :last-child {
  92 + border-bottom: 0;
  93 + }
  94 + }
  95 + }
  96 +}
  97 +</style>
@@ -7,6 +7,13 @@ const routers = [ @@ -7,6 +7,13 @@ const routers = [
7 path: '/xianyu/:owner/order/list/:status?', 7 path: '/xianyu/:owner/order/list/:status?',
8 component: () => import('./order-list'), 8 component: () => import('./order-list'),
9 }, 9 },
  10 +
  11 + // 出售订单列表
  12 + {
  13 + name: 'InSaleOrderList',
  14 + path: '/xianyu/in/sale/order/list/:type?',
  15 + component: () => import('./in-sell-order-list'),
  16 + },
10 ]; 17 ];
11 18
12 export default routers; 19 export default routers;
  1 +export default function() {
  2 + return {
  3 + namespaced: true,
  4 + state: {
  5 + entryOrder: {
  6 + page: 1,
  7 + pageSize: 10,
  8 + pagetotal: 0,
  9 + list: [], // 订单列表
  10 + pullUpload: true,
  11 + },
  12 + notEntryOrder: {
  13 + page: 1,
  14 + pageSize: 10,
  15 + pagetotal: 0,
  16 + list: [], // 订单列表
  17 + pullUpload: true,
  18 + },
  19 + },
  20 + mutations: {
  21 + setEntryOrder(state, res) {
  22 + let { page, pagetotal, data = [] } = res;
  23 +
  24 + state.entryOrder.page = ++page;
  25 + state.entryOrder.pagetotal = pagetotal;
  26 + state.entryOrder.list = state.entryOrder.list.concat(data);
  27 +
  28 + // 分页结束
  29 + if (page > pagetotal) {
  30 + state.entryOrder.pullUpload = false;
  31 + }
  32 + },
  33 + setNotEntryOrder(state, res) {
  34 + let { page, pagetotal, data = [] } = res;
  35 +
  36 + state.notEntryOrder.page = ++page;
  37 + state.notEntryOrder.pagetotal = pagetotal;
  38 + state.notEntryOrder.list = state.entryOrder.list.concat(data);
  39 +
  40 + // 分页结束
  41 + if (page > pagetotal) {
  42 + state.notEntryOrder.pullUpload = false;
  43 + }
  44 + },
  45 + },
  46 + getters: {
  47 + // scroll 组件参数,是否触发上拉事件
  48 + pullUpload: state =>
  49 + state.entryOrder.pullUpload || state.notEntryOrder.pullUpload,
  50 + orderList: state => {
  51 + const {
  52 + entryOrder: { list: entryOrderList },
  53 + notEntryOrder: { list: notEntryOrderList },
  54 + } = state;
  55 +
  56 + return entryOrderList.concat(notEntryOrderList);
  57 + },
  58 + },
  59 + actions: {
  60 + async fetchEntryOrderList(
  61 + {
  62 + commit,
  63 + state: { entryOrder },
  64 + },
  65 + params,
  66 + ) {
  67 + const { page } = entryOrder;
  68 + const { type = 1 } = params;
  69 + const res = await this.$api.get('/api/ufo/seller/entryPrdList', {
  70 + page,
  71 + type: +type,
  72 + });
  73 +
  74 + if (res.code === 200) {
  75 + commit('setEntryOrder', res.data);
  76 + }
  77 + },
  78 + async fetchNotEntryOrderList(
  79 + {
  80 + commit,
  81 + state: { notEntryOrder },
  82 + },
  83 + params,
  84 + ) {
  85 + const { page } = notEntryOrder;
  86 + const { type = 1 } = params;
  87 + const res = await this.$api.get('/api/ufo/seller/notEntryPrdList', {
  88 + page,
  89 + type: +type,
  90 + });
  91 +
  92 + if (res.code === 200) {
  93 + commit('setEntryOrder', res.data);
  94 + }
  95 + },
  96 + },
  97 + };
  98 +}
@@ -4,6 +4,7 @@ import orderConfirm from './order-confirm'; @@ -4,6 +4,7 @@ import orderConfirm from './order-confirm';
4 import orderDetail from './order-detail'; 4 import orderDetail from './order-detail';
5 import orderLogistics from './order-logistics'; 5 import orderLogistics from './order-logistics';
6 import orderDeliver from './order-deliver'; 6 import orderDeliver from './order-deliver';
  7 +import inSaleOrderList from './in-sale-order-list';
7 8
8 export default function() { 9 export default function() {
9 return { 10 return {
@@ -15,6 +16,7 @@ export default function() { @@ -15,6 +16,7 @@ export default function() {
15 orderDetail: orderDetail(), 16 orderDetail: orderDetail(),
16 logisticsInfo: orderLogistics(), 17 logisticsInfo: orderLogistics(),
17 orderDeliver: orderDeliver(), 18 orderDeliver: orderDeliver(),
  19 + inSaleOrderList: inSaleOrderList(),
18 }, 20 },
19 }; 21 };
20 } 22 }
@@ -217,6 +217,11 @@ module.exports = { @@ -217,6 +217,11 @@ module.exports = {
217 auth: true, 217 auth: true,
218 ufo: true, 218 ufo: true,
219 api: 'ufo.seller.notEntryPrdList', 219 api: 'ufo.seller.notEntryPrdList',
  220 + params: {
  221 + type: { type: Number, require: true },
  222 + limit: { type: Number }, // page size
  223 + page: { type: Number, require: true }, // page number
  224 + },
220 }, 225 },
221 226
222 // 入住商家类表 227 // 入住商家类表
@@ -224,6 +229,11 @@ module.exports = { @@ -224,6 +229,11 @@ module.exports = {
224 auth: true, 229 auth: true,
225 ufo: true, 230 ufo: true,
226 api: 'ufo.seller.entryPrdList', 231 api: 'ufo.seller.entryPrdList',
  232 + params: {
  233 + limit: { type: Number }, // page size
  234 + page: { type: Number, require: true }, // page number
  235 + type: { type: Number, require: true },
  236 + },
227 }, 237 },
228 238
229 // 订单数量 239 // 订单数量