Commit 4e5fb860bcd7364035537e5f4e6427694e9e2198
1 parent
e92e93f736
Exists in
master
支付接口参数修改
Showing
1 changed file
with
1 additions
and
1 deletions
Show diff stats
src/store/modules/order.js
1 | import urlAlias from '../url' | 1 | import urlAlias from '../url' |
2 | import request from '../request' | 2 | import request from '../request' |
3 | 3 | ||
4 | const { orderBuild, buyNow, pay } = urlAlias | 4 | const { orderBuild, buyNow, pay } = urlAlias |
5 | 5 | ||
6 | const state = { list: [], param: {} } | 6 | const state = { list: [], param: {} } |
7 | 7 | ||
8 | const mutations = { | 8 | const mutations = { |
9 | LIST: (state, list) => { | 9 | LIST: (state, list) => { |
10 | state.list = list | 10 | state.list = list |
11 | }, | 11 | }, |
12 | SAVE: (state, param) => { | 12 | SAVE: (state, param) => { |
13 | state.param = param | 13 | state.param = param |
14 | }, | 14 | }, |
15 | } | 15 | } |
16 | 16 | ||
17 | const actions = { | 17 | const actions = { |
18 | // 立即购买->创建订单 | 18 | // 立即购买->创建订单 |
19 | buyNow({ commit }, param) { | 19 | buyNow({ commit }, param) { |
20 | return new Promise((resolve) => request({ | 20 | return new Promise((resolve) => request({ |
21 | url: buyNow, | 21 | url: buyNow, |
22 | data: param, | 22 | data: param, |
23 | success: (res) => { | 23 | success: (res) => { |
24 | resolve(res) | 24 | resolve(res.data) |
25 | }, | 25 | }, |
26 | fail: () => { | 26 | fail: () => { |
27 | uni.showModal({ | 27 | uni.showModal({ |
28 | content: '创建订单失败', | 28 | content: '创建订单失败', |
29 | showCancel: false, | 29 | showCancel: false, |
30 | }) | 30 | }) |
31 | }, | 31 | }, |
32 | })) | 32 | })) |
33 | }, | 33 | }, |
34 | // 购物车->创建订单 | 34 | // 购物车->创建订单 |
35 | build({ commit }, param) { | 35 | build({ commit }, param) { |
36 | return new Promise((resolve, reject) => request({ | 36 | return new Promise((resolve, reject) => request({ |
37 | url: orderBuild, | 37 | url: orderBuild, |
38 | data: param, | 38 | data: param, |
39 | success: (res) => { | 39 | success: (res) => { |
40 | resolve(res.data) | 40 | resolve(res.data) |
41 | }, | 41 | }, |
42 | fail: () => { | 42 | fail: () => { |
43 | uni.showModal({ | 43 | uni.showModal({ |
44 | content: '订单生成失败', | 44 | content: '订单生成失败', |
45 | showCancel: false, | 45 | showCancel: false, |
46 | }) | 46 | }) |
47 | }, | 47 | }, |
48 | })) | 48 | })) |
49 | }, | 49 | }, |
50 | // 支付 | 50 | // 支付 |
51 | pay({ commit }, param) { | 51 | pay({ commit }, param) { |
52 | return new Promise((resolve, reject) => request({ | 52 | return new Promise((resolve, reject) => request({ |
53 | url: pay, | 53 | url: pay, |
54 | data: param, | 54 | data: param, |
55 | success: (res) => { | 55 | success: (res) => { |
56 | resolve(res.data) | 56 | resolve(res.data) |
57 | }, | 57 | }, |
58 | fail: () => { | 58 | fail: () => { |
59 | uni.showModal({ | 59 | uni.showModal({ |
60 | content: '订单生成失败', | 60 | content: '订单生成失败', |
61 | showCancel: false, | 61 | showCancel: false, |
62 | }) | 62 | }) |
63 | }, | 63 | }, |
64 | })) | 64 | })) |
65 | }, | 65 | }, |
66 | // 储存创建订单参数 | 66 | // 储存创建订单参数 |
67 | saveParams({ commit }, param) { | 67 | saveParams({ commit }, param) { |
68 | console.log('save', param) | 68 | console.log('save', param) |
69 | commit('SAVE', param) | 69 | commit('SAVE', param) |
70 | }, | 70 | }, |
71 | } | 71 | } |
72 | 72 | ||
73 | export default { | 73 | export default { |
74 | namespaced: true, | 74 | namespaced: true, |
75 | state, | 75 | state, |
76 | mutations, | 76 | mutations, |
77 | actions, | 77 | actions, |
78 | } | 78 | } |
79 | 79 |