order-confirm.js
2.08 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
70
71
72
73
74
75
76
77
78
79
80
81
82
import { get, find } from 'lodash';
export const Types = {
FETCH_ORDER_ADDRESS: 'FETCH_ORDER_ADDRESS',
FETCH_ORDER_USER_STATUS: 'FETCH_ORDER_USER_STATUS',
FETCH_ORDER_FEE: 'FETCH_ORDER_FEE',
CHANGE_PRICE: 'CHANGE_PRICE',
CHANGE_AGREE: 'CHANGE_AGREE'
};
export default function() {
return {
namespaced: true,
state: {
productDetail: {},
fetchProductDetail: false,
address: {},
fee: {
income: '',
bankTransferFee: '',
platformFee: {
amount: '',
appraiseFee: '',
goodsPaymentRatePercent: '',
packageFee: '',
payChannelPercentage: '',
serviceFee: ''
}
},
alipayStatus: false,
userStatus: false,
price: '',
agree: false
},
mutations: {
[Types.FETCH_ORDER_ADDRESS](state, data) {
state.address = data;
},
[Types.FETCH_ORDER_FEE](state, data) {
state.fee = data;
},
[Types.CHANGE_PRICE](state, data) {
state.price = data;
},
[Types.CHANGE_AGREE](state, data) {
state.agree = data;
}
},
actions: {
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) {
const order = await this.$api.post('/api/order/confirm/compute', payload);
if (order.code !== 200) {
return {
error: order.message
};
}
commit(Types.FETCH_ORDER_FEE, order.data);
return {};
},
async fetchUserStatus() {
const alipayStatus = await this.$api.get('/api/order/alipay/status');
const userStatus = await this.$api.get('/api/order/user/status');
}
},
getters: {},
};
}