|
@@ -3,56 +3,83 @@ const BaseAPIURl = require('./baseUrl.js').basePath.BASE_API_URL;
|
3
|
3
|
const $api = {
|
4
|
4
|
user: {
|
5
|
5
|
login: { // 模拟用户登陆
|
6
|
|
- methods: 'POST',
|
7
|
|
- url: `${BaseAPIURl}/wx/registered`
|
|
6
|
+ method: 'POST',
|
|
7
|
+ url: `${BaseAPIURl}wx/registered`
|
8
|
8
|
},
|
9
|
9
|
info: {
|
10
|
|
- methods: 'GET',
|
11
|
|
- url: `${BaseAPIURl}/wx/info/:appid`
|
|
10
|
+ method: 'GET',
|
|
11
|
+ url: `${BaseAPIURl}wx/info/:appid`
|
12
|
12
|
},
|
13
|
13
|
getCode: {
|
14
|
|
- methods: 'GET',
|
15
|
|
- url: `${BaseAPIURl}/wx/getOpenid`
|
|
14
|
+ method: 'GET',
|
|
15
|
+ url: `${BaseAPIURl}wx/getOpenid`
|
16
|
16
|
},
|
17
|
17
|
update: {
|
18
|
|
- methods: 'PUT',
|
19
|
|
- url: `${BaseAPIURl}/wx/user`
|
|
18
|
+ method: 'PUT',
|
|
19
|
+ url: `${BaseAPIURl}wx/user`
|
20
|
20
|
}
|
21
|
21
|
},
|
22
|
22
|
banner: {
|
23
|
23
|
list: {
|
24
|
|
- methods: 'GET',
|
25
|
|
- url: `${BaseAPIURl}/wx/banner`
|
|
24
|
+ method: 'GET',
|
|
25
|
+ url: `${BaseAPIURl}wx/banner`
|
26
|
26
|
}
|
27
|
27
|
},
|
28
|
28
|
building: {
|
29
|
29
|
list: {
|
30
|
|
- methods: 'GET',
|
31
|
|
- url: `${BaseAPIURl}/wx/building/list`
|
|
30
|
+ method: 'GET',
|
|
31
|
+ url: `${BaseAPIURl}wx/building/list`
|
32
|
32
|
},
|
33
|
33
|
},
|
34
|
34
|
dynamic: { // 项目
|
35
|
35
|
list: { // 项目列表
|
36
|
|
- methods: 'GET',
|
37
|
|
- url: `${BaseAPIURl}/wx/buildingDynamiceList`
|
|
36
|
+ method: 'GET',
|
|
37
|
+ url: `${BaseAPIURl}wx/buildingDynamiceList`
|
38
|
38
|
},
|
39
|
39
|
detail: { // 项目详情
|
40
|
|
- methods: 'GET',
|
41
|
|
- url: `${BaseAPIURl}/wx/buildingDynamiceInfo/:id`
|
|
40
|
+ method: 'GET',
|
|
41
|
+ url: `${BaseAPIURl}wx/buildingDynamiceInfo/:id`
|
42
|
42
|
}
|
43
|
43
|
},
|
44
|
44
|
activity: {
|
45
|
45
|
list: { // 活动列表
|
46
|
|
- methods: 'GET',
|
47
|
|
- url: `${BaseAPIURl}/wx/activity`
|
|
46
|
+ method: 'GET',
|
|
47
|
+ url: `${BaseAPIURl}wx/activity`
|
48
|
48
|
},
|
49
|
49
|
detail: { // 活动详情
|
50
|
|
- methods: 'GET',
|
51
|
|
- url: `${BaseAPIURl}/wx/activity/:id`
|
|
50
|
+ method: 'GET',
|
|
51
|
+ url: `${BaseAPIURl}wx/activity/:id`
|
52
|
52
|
}
|
53
|
53
|
},
|
54
|
54
|
}
|
55
|
55
|
|
|
56
|
+const hasKey = (o, k) => Object.keys(o).indexOf(k) > -1
|
|
57
|
+
|
|
58
|
+// 获取 api 支持 a.b.c 字符串格式
|
|
59
|
+function get(k = '') {
|
|
60
|
+ let found = true
|
|
61
|
+ return k.split('.').reduce((acc, key) => {
|
|
62
|
+ if (!found) return acc;
|
|
63
|
+
|
|
64
|
+ if (acc === 0) {
|
|
65
|
+ if (hasKey($api, key)) {
|
|
66
|
+ return $api[key]
|
|
67
|
+ } else {
|
|
68
|
+ found = false
|
|
69
|
+ return {}
|
|
70
|
+ }
|
|
71
|
+ } else {
|
|
72
|
+ if (hasKey(acc, key)) {
|
|
73
|
+ return acc[key]
|
|
74
|
+ } else {
|
|
75
|
+ found = false
|
|
76
|
+ return acc
|
|
77
|
+ }
|
|
78
|
+ }
|
|
79
|
+ }, 0)
|
|
80
|
+}
|
|
81
|
+
|
56
|
82
|
module.exports = {
|
57
|
|
- $api: $api
|
58
|
|
-}
|
|
83
|
+ $api: $api,
|
|
84
|
+ get: get,
|
|
85
|
+}
|