Showing
6 changed files
with
97 additions
and
48 deletions
@@ -53,9 +53,8 @@ export default { | @@ -53,9 +53,8 @@ export default { | ||
53 | display: flex; | 53 | display: flex; |
54 | 54 | ||
55 | .item-img { | 55 | .item-img { |
56 | - min-width: 180px; | ||
57 | - max-width: 180px; | ||
58 | - max-height: 180px; | 56 | + width: 180px; |
57 | + height: 180px; | ||
59 | display: inline-block; | 58 | display: inline-block; |
60 | text-align: center; | 59 | text-align: center; |
61 | 60 |
@@ -3,9 +3,14 @@ | @@ -3,9 +3,14 @@ | ||
3 | <scroll ref="statusScroll" :data="statusList" direction="horizontal"> | 3 | <scroll ref="statusScroll" :data="statusList" direction="horizontal"> |
4 | <ul class="list-wrapper"> | 4 | <ul class="list-wrapper"> |
5 | <li | 5 | <li |
6 | - :class="i === 1 ? 'list-item active' : 'list-item'" | 6 | + :class=" |
7 | + currentStatus === statusInfo.value | ||
8 | + ? 'list-item active' | ||
9 | + : 'list-item' | ||
10 | + " | ||
7 | v-for="(statusInfo, i) in statusList" | 11 | v-for="(statusInfo, i) in statusList" |
8 | :key="i" | 12 | :key="i" |
13 | + @click="() => onHandleClick(statusInfo.value)" | ||
9 | > | 14 | > |
10 | {{ statusInfo.text }} | 15 | {{ statusInfo.text }} |
11 | </li> | 16 | </li> |
@@ -23,17 +28,28 @@ import { | @@ -23,17 +28,28 @@ import { | ||
23 | ownType | 28 | ownType |
24 | } from "../../../../../constants/order-constants"; | 29 | } from "../../../../../constants/order-constants"; |
25 | 30 | ||
31 | +import { createNamespacedHelpers } from "vuex"; | ||
32 | + | ||
33 | +const { mapState } = createNamespacedHelpers("order/orderList"); | ||
34 | + | ||
26 | export default { | 35 | export default { |
27 | components: { | 36 | components: { |
28 | Scroll | 37 | Scroll |
29 | }, | 38 | }, |
30 | computed: { | 39 | computed: { |
40 | + ...mapState(["currentStatus"]), | ||
31 | statusList: function() { | 41 | statusList: function() { |
32 | const { owner } = this.$route.params; | 42 | const { owner } = this.$route.params; |
33 | return owner === ownType.BUY | 43 | return owner === ownType.BUY |
34 | ? buyerOrderStatusList | 44 | ? buyerOrderStatusList |
35 | : sellerOrderStatusList; | 45 | : sellerOrderStatusList; |
36 | } | 46 | } |
47 | + }, | ||
48 | + methods: { | ||
49 | + onHandleClick(status) { | ||
50 | + const { owner } = this.$route.params; | ||
51 | + this.$router.push({ name: "OrderList", params: { owner, status } }); | ||
52 | + } | ||
37 | } | 53 | } |
38 | }; | 54 | }; |
39 | </script> | 55 | </script> |
@@ -3,7 +3,7 @@ const routers = [ | @@ -3,7 +3,7 @@ const routers = [ | ||
3 | // owner: {sell, buy} 订单来源 | 3 | // owner: {sell, buy} 订单来源 |
4 | // status: 订单状态 | 4 | // status: 订单状态 |
5 | { | 5 | { |
6 | - name: 'BuyerOrderList', | 6 | + name: 'OrderList', |
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 | }, |
1 | <template> | 1 | <template> |
2 | - <div> | 2 | + <div class="content-wrapper"> |
3 | <status-nav /> | 3 | <status-nav /> |
4 | - <scroll :data="orderList" class="order-list-scroll-wrap"> | 4 | + <scroll |
5 | + @pulling-up="fetchMore" | ||
6 | + :options="options" | ||
7 | + :data="orderList" | ||
8 | + class="order-list-scroll-wrap" | ||
9 | + > | ||
5 | <ul class="list-wrapper"> | 10 | <ul class="list-wrapper"> |
6 | <li v-for="order in orderList" :key="order.orderCode"> | 11 | <li v-for="order in orderList" :key="order.orderCode"> |
7 | <order-list-item :order="order"> | 12 | <order-list-item :order="order"> |
@@ -34,14 +39,21 @@ export default { | @@ -34,14 +39,21 @@ export default { | ||
34 | StatusNav | 39 | StatusNav |
35 | }, | 40 | }, |
36 | computed: { | 41 | computed: { |
37 | - ...mapState(["orderList"]) | 42 | + ...mapState(["orderList", "pullUpLoad"]), |
43 | + options: function() { | ||
44 | + return { | ||
45 | + pullUpLoad: this.pullUpLoad | ||
46 | + }; | ||
47 | + } | ||
38 | }, | 48 | }, |
49 | + | ||
39 | // 获取订单数据 | 50 | // 获取订单数据 |
40 | asyncData({ store, router }) { | 51 | asyncData({ store, router }) { |
41 | const { owner, status } = router.params; | 52 | const { owner, status } = router.params; |
42 | store.dispatch("order/orderList/fetchOrderList", { owner, status }); | 53 | store.dispatch("order/orderList/fetchOrderList", { owner, status }); |
43 | }, | 54 | }, |
44 | mounted() { | 55 | mounted() { |
56 | + console.log("-------------------", this.$route.params); | ||
45 | const { owner, status } = this.$route.params; | 57 | const { owner, status } = this.$route.params; |
46 | this.fetchOrderList({ owner, status }); | 58 | this.fetchOrderList({ owner, status }); |
47 | }, | 59 | }, |
@@ -55,41 +67,48 @@ export default { | @@ -55,41 +67,48 @@ export default { | ||
55 | }; | 67 | }; |
56 | </script> | 68 | </script> |
57 | <style lang="scss" scoped> | 69 | <style lang="scss" scoped> |
58 | -.order-list-scroll-wrap { | ||
59 | - .list-wrapper { | ||
60 | - li { | ||
61 | - padding: 40px 40px; | ||
62 | - border-bottom: 1px solid #eee; | ||
63 | - } | 70 | +.content-wrapper { |
71 | + height: calc(100vh); | ||
72 | + overflow-x: hidden; | ||
73 | + overflow-y: auto; | ||
74 | + -webkit-box-orient: vertical; | ||
64 | 75 | ||
65 | - & :last-child { | ||
66 | - border-bottom: 0; | 76 | + .order-list-scroll-wrap { |
77 | + .list-wrapper { | ||
78 | + li { | ||
79 | + padding: 40px 40px; | ||
80 | + border-bottom: 1px solid #eee; | ||
81 | + } | ||
82 | + | ||
83 | + & :last-child { | ||
84 | + border-bottom: 0; | ||
85 | + } | ||
67 | } | 86 | } |
68 | - } | ||
69 | 87 | ||
70 | - .actions { | ||
71 | - display: flex; | ||
72 | - justify-content: flex-end; | ||
73 | - margin-top: 40px; | 88 | + .actions { |
89 | + display: flex; | ||
90 | + justify-content: flex-end; | ||
91 | + margin-top: 40px; | ||
74 | 92 | ||
75 | - button { | ||
76 | - font-size: 24px; | ||
77 | - padding: 24px 64px 22px 64px; | ||
78 | - color: #999; | ||
79 | - letter-spacing: 0; | ||
80 | - border-radius: 0; | ||
81 | - background: #fff; | ||
82 | - border: 1px solid #ccc; | ||
83 | - line-height: 1.3; | ||
84 | - width: 224px; | ||
85 | - margin-right: 20px; | ||
86 | - } | 93 | + button { |
94 | + font-size: 24px; | ||
95 | + padding: 24px 64px 22px 64px; | ||
96 | + color: #999; | ||
97 | + letter-spacing: 0; | ||
98 | + border-radius: 0; | ||
99 | + background: #fff; | ||
100 | + border: 1px solid #ccc; | ||
101 | + line-height: 1.3; | ||
102 | + width: 224px; | ||
103 | + margin-right: 20px; | ||
104 | + } | ||
87 | 105 | ||
88 | - & :last-child { | ||
89 | - background: #002b47; | ||
90 | - color: #fff; | ||
91 | - border: 1px solid #002b47; | ||
92 | - margin-right: 0; | 106 | + & :last-child { |
107 | + background: #002b47; | ||
108 | + color: #fff; | ||
109 | + border: 1px solid #002b47; | ||
110 | + margin-right: 0; | ||
111 | + } | ||
93 | } | 112 | } |
94 | } | 113 | } |
95 | } | 114 | } |
@@ -27,8 +27,6 @@ export function createStore(context) { | @@ -27,8 +27,6 @@ export function createStore(context) { | ||
27 | 27 | ||
28 | // 买家订单列表 | 28 | // 买家订单列表 |
29 | notice: storeNotice(), | 29 | notice: storeNotice(), |
30 | - // buyerOderList: buyerOderList(), | ||
31 | - | ||
32 | }, | 30 | }, |
33 | 31 | ||
34 | strict: process.env.NODE_ENV !== 'production', | 32 | strict: process.env.NODE_ENV !== 'production', |
@@ -5,16 +5,26 @@ export default function() { | @@ -5,16 +5,26 @@ export default function() { | ||
5 | page: 1, | 5 | page: 1, |
6 | pageSize: 10, | 6 | pageSize: 10, |
7 | pagetotal: 0, | 7 | pagetotal: 0, |
8 | - orderList: [], | 8 | + orderList: [], // 订单列表 |
9 | + // scroll 组件参数,是否触发上拉事件 | ||
10 | + pullUpLoad: true, | ||
11 | + currentStatus: 1, | ||
9 | }, | 12 | }, |
10 | mutations: { | 13 | mutations: { |
11 | setOrderList(state, res = {}) { | 14 | setOrderList(state, res = {}) { |
12 | - const { page, pagetotal, data } = res; | 15 | + let { page, pagetotal, data = [] } = res; |
13 | 16 | ||
14 | - console.log('----------------', data); | ||
15 | - state.page = page; | 17 | + state.page = ++page; |
16 | state.pagetotal = pagetotal; | 18 | state.pagetotal = pagetotal; |
17 | - state.orderList = data || []; | 19 | + state.orderList = state.orderList.concat(data); |
20 | + | ||
21 | + // 分页结束 | ||
22 | + if (page > pagetotal) { | ||
23 | + state.pullUpLoad = false; | ||
24 | + } | ||
25 | + }, | ||
26 | + setOrderState(state, currentStatus) { | ||
27 | + state.currentStatus = +currentStatus; | ||
18 | }, | 28 | }, |
19 | }, | 29 | }, |
20 | actions: { | 30 | actions: { |
@@ -23,15 +33,21 @@ export default function() { | @@ -23,15 +33,21 @@ export default function() { | ||
23 | * @param {*} param0 vue store context | 33 | * @param {*} param0 vue store context |
24 | * @param { | 34 | * @param { |
25 | * owner: 订单来源 | 35 | * owner: 订单来源 |
26 | - * status: 订单状态 | 36 | + * status: 订单状态 默认全部 |
27 | * } | 37 | * } |
28 | * r | 38 | * r |
29 | */ | 39 | */ |
30 | - async fetchOrderList({ commit }, { owner, status } = {}) { | 40 | + async fetchOrderList( |
41 | + { | ||
42 | + commit, | ||
43 | + state: { page }, | ||
44 | + }, | ||
45 | + { owner, status = 1 } = {}, | ||
46 | + ) { | ||
31 | const res = await this.$api.get('/api/order/list', { | 47 | const res = await this.$api.get('/api/order/list', { |
32 | tabType: owner, | 48 | tabType: owner, |
33 | type: status, | 49 | type: status, |
34 | - page: 1, | 50 | + page, |
35 | limit: 5, | 51 | limit: 5, |
36 | 52 | ||
37 | // Todo 删除 | 53 | // Todo 删除 |
@@ -40,6 +56,7 @@ export default function() { | @@ -40,6 +56,7 @@ export default function() { | ||
40 | 56 | ||
41 | if (res.code === 200) { | 57 | if (res.code === 200) { |
42 | commit('setOrderList', res.data); | 58 | commit('setOrderList', res.data); |
59 | + commit('setOrderState', status); | ||
43 | } | 60 | } |
44 | }, | 61 | }, |
45 | }, | 62 | }, |
-
Please register or login to post a comment