Commit e2eaa8a22bf7709ba95bc19172c2c85dc8e4c944
1 parent
697c1032cd
Exists in
master
请求地址提取
Showing
4 changed files
with
110 additions
and
20 deletions
Show diff stats
src/store/modules/myOrder.js
... | ... | @@ -0,0 +1,41 @@ |
1 | +const state = { | |
2 | + orderList: [], | |
3 | +}; | |
4 | + | |
5 | +const mutations = { | |
6 | + getOrder: (state, data) => { | |
7 | + state.orderList = data; | |
8 | + }, | |
9 | +}; | |
10 | + | |
11 | +const actions = { | |
12 | + fetch({ commit }, param) { | |
13 | + uni | |
14 | + .request({ | |
15 | + url: "", | |
16 | + method: "post", | |
17 | + data: {}, | |
18 | + header: { | |
19 | + "Content-Type": "application/x-www-form-urlencoded", | |
20 | + }, | |
21 | + timeout: 3000, | |
22 | + withCredentials: false, | |
23 | + success: (res) => { | |
24 | + commit('getOrder', res.data.data) | |
25 | + }, | |
26 | + fail: (res) => { | |
27 | + console.log("fail status === > ", res); | |
28 | + }, | |
29 | + complete: (res) => { | |
30 | + console.log("complete status === > ", res); | |
31 | + } | |
32 | + }) | |
33 | + } | |
34 | +} | |
35 | + | |
36 | +export default { | |
37 | + namespaced: true, | |
38 | + state, | |
39 | + mutations, | |
40 | + actions, | |
41 | +} | |
0 | 42 | \ No newline at end of file | ... | ... |
src/store/modules/test.js
1 | + import urlAlias from '../url'; | |
2 | + import request from '../request'; | |
3 | + | |
4 | + const { | |
5 | + shopList | |
6 | + } = urlAlias; | |
7 | + | |
1 | 8 | const state = { |
2 | 9 | list: [], |
3 | 10 | }; |
... | ... | @@ -10,26 +17,38 @@ const mutations = { |
10 | 17 | |
11 | 18 | const actions = { |
12 | 19 | fetch({ commit }, param) { |
13 | - uni | |
14 | - .request({ | |
15 | - url: "https://api.glass.xiuyetang.com/app/prod/list", | |
16 | - method: "post", | |
17 | - data: {}, | |
18 | - header: { | |
19 | - "Content-Type": "application/x-www-form-urlencoded", | |
20 | - }, | |
21 | - timeout: 3000, | |
22 | - withCredentials: false, | |
23 | - success: (res) => { | |
24 | - commit('INIT', res.data.data) | |
25 | - }, | |
26 | - fail: (res) => { | |
27 | - console.log("fail status === > ", res); | |
28 | - }, | |
29 | - complete: (res) => { | |
30 | - console.log("complete status === > ", res); | |
31 | - }, | |
32 | - }); | |
20 | + request({ | |
21 | + url: shopList, | |
22 | + success: (res) => { | |
23 | + commit('INIT', res.data.data) | |
24 | + }, | |
25 | + fail: (res) => { | |
26 | + console.log("fail status === > ", res); | |
27 | + }, | |
28 | + complete: (res) => { | |
29 | + console.log("complete status === > ", res); | |
30 | + }, | |
31 | + }) | |
32 | + // uni | |
33 | + // .request({ | |
34 | + // url: "https://api.glass.xiuyetang.com/app/prod/list", | |
35 | + // method: "post", | |
36 | + // data: {}, | |
37 | + // header: { | |
38 | + // "Content-Type": "application/x-www-form-urlencoded", | |
39 | + // }, | |
40 | + // timeout: 3000, | |
41 | + // withCredentials: false, | |
42 | + // success: (res) => { | |
43 | + // commit('INIT', res.data.data) | |
44 | + // }, | |
45 | + // fail: (res) => { | |
46 | + // console.log("fail status === > ", res); | |
47 | + // }, | |
48 | + // complete: (res) => { | |
49 | + // console.log("complete status === > ", res); | |
50 | + // }, | |
51 | + // }); | |
33 | 52 | }, |
34 | 53 | }; |
35 | 54 | ... | ... |
src/store/request.js
... | ... | @@ -0,0 +1,24 @@ |
1 | +const DOMAIN = 'https://api.glass.xiuyetang.com/'; | |
2 | + | |
3 | +export default async function request({ | |
4 | + url, | |
5 | + success, | |
6 | + fail, | |
7 | + complete, | |
8 | +}) { | |
9 | + console.log("DOMAIN", DOMAIN, url); | |
10 | + uni | |
11 | + .request({ | |
12 | + url: DOMAIN + url, | |
13 | + method: "post", | |
14 | + data: {}, | |
15 | + header: { | |
16 | + "Content-Type": "application/x-www-form-urlencoded", | |
17 | + }, | |
18 | + timeout: 3000, | |
19 | + withCredentials: false, | |
20 | + success, | |
21 | + fail, | |
22 | + complete, | |
23 | + }) | |
24 | +} | |
0 | 25 | \ No newline at end of file | ... | ... |
src/store/url.js