order-confirm.js
1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import { get, find } from 'lodash';
export const Types = {
FETCH_ORDER_DETAIL_REQUEST: 'FETCH_ORDER_DETAIL_REQUEST',
FETCH_ORDER_DETAIL_FAIL: 'FETCH_ORDER_DETAIL_FAIL',
FETCH_ORDER_DETAIL_SUCCESS: 'FETCH_ORDER_DETAIL_SUCCESS',
FETCH_ORDER_ADDRESS: 'FETCH_ORDER_ADDRESS'
};
export default function() {
return {
namespaced: true,
state: {
orderDetail: {},
fetchOrderDetail: false,
detail: {},
address: {}
},
mutations: {
[Types.FETCH_ORDER_DETAIL_REQUEST](state) {
state.fetchOrderDetail = true;
},
[Types.FETCH_ORDER_DETAIL_SUCCESS](state, data) {
state.fetchOrderDetail = false;
state.orderDetail = data;
},
[Types.FETCH_ORDER_DETAIL_FAIL](state) {
state.fetchOrderDetail = false;
},
[Types.FETCH_ORDER_ADDRESS](state, data) {
state.address = data;
}
},
actions: {
async fetchOrderDetail({ commit }, { tabType = 'sell', orderCode } = {}) {
commit(Types.FETCH_ORDER_DETAIL_REQUEST);
const result = await this.$api.post('/api/order/detail', {
tabType,
orderCode: orderCode
});
if (result.code !== 200) {
commit(Types.FETCH_ORDER_DETAIL_FAIL);
return;
}
commit(Types.FETCH_ORDER_DETAIL_SUCCESS, result.data);
},
async fetchOrderAddress({ commit }, payload) {
const orderCount = await this.$api.get('/api/order/confirm/count', payload);
if (get(orderCount, 'data.cnt', 0)) {
const addressInfo = await this.$api.get('/api/order/confirm/address');
const address = find(get(addressInfo, 'data', []), { is_default: 'Y' });
commit(Types.FETCH_ORDER_ADDRESS, address);
}
},
async fetchOrderPrice({ commit }, payload) {
}
},
getters: {},
};
}