|
@@ -3,20 +3,20 @@ 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
|
dict: {
|
|
@@ -27,14 +27,14 @@ const $api = {
|
27
|
27
|
},
|
28
|
28
|
banner: {
|
29
|
29
|
list: {
|
30
|
|
- methods: 'GET',
|
31
|
|
- url: `${BaseAPIURl}/wx/banner`
|
|
30
|
+ method: 'GET',
|
|
31
|
+ url: `${BaseAPIURl}wx/banner`
|
32
|
32
|
}
|
33
|
33
|
},
|
34
|
34
|
building: {
|
35
|
35
|
list: {
|
36
|
|
- methods: 'GET',
|
37
|
|
- url: `${BaseAPIURl}/wx/building/list`
|
|
36
|
+ method: 'GET',
|
|
37
|
+ url: `${BaseAPIURl}wx/building/list`
|
38
|
38
|
},
|
39
|
39
|
detail: {
|
40
|
40
|
methods: 'GET',
|
|
@@ -43,22 +43,22 @@ const $api = {
|
43
|
43
|
},
|
44
|
44
|
dynamic: { // 项目
|
45
|
45
|
list: { // 项目列表
|
46
|
|
- methods: 'GET',
|
47
|
|
- url: `${BaseAPIURl}/wx/buildingDynamiceList`
|
|
46
|
+ method: 'GET',
|
|
47
|
+ url: `${BaseAPIURl}wx/buildingDynamiceList`
|
48
|
48
|
},
|
49
|
49
|
detail: { // 项目详情
|
50
|
|
- methods: 'GET',
|
51
|
|
- url: `${BaseAPIURl}/wx/buildingDynamiceInfo/:id`
|
|
50
|
+ method: 'GET',
|
|
51
|
+ url: `${BaseAPIURl}wx/buildingDynamiceInfo/:id`
|
52
|
52
|
}
|
53
|
53
|
},
|
54
|
54
|
activity: {
|
55
|
55
|
list: { // 活动列表
|
56
|
|
- methods: 'GET',
|
57
|
|
- url: `${BaseAPIURl}/wx/activity`
|
|
56
|
+ method: 'GET',
|
|
57
|
+ url: `${BaseAPIURl}wx/activity`
|
58
|
58
|
},
|
59
|
59
|
detail: { // 活动详情
|
60
|
|
- methods: 'GET',
|
61
|
|
- url: `${BaseAPIURl}/wx/activity/:id`
|
|
60
|
+ method: 'GET',
|
|
61
|
+ url: `${BaseAPIURl}wx/activity/:id`
|
62
|
62
|
}
|
63
|
63
|
},
|
64
|
64
|
appointment: {
|
|
@@ -87,6 +87,33 @@ const $api = {
|
87
|
87
|
}
|
88
|
88
|
}
|
89
|
89
|
|
|
90
|
+const hasKey = (o, k) => Object.keys(o).indexOf(k) > -1
|
|
91
|
+
|
|
92
|
+// 获取 api 支持 a.b.c 字符串格式
|
|
93
|
+function get(k = '') {
|
|
94
|
+ let found = true
|
|
95
|
+ return k.split('.').reduce((acc, key) => {
|
|
96
|
+ if (!found) return acc;
|
|
97
|
+
|
|
98
|
+ if (acc === 0) {
|
|
99
|
+ if (hasKey($api, key)) {
|
|
100
|
+ return $api[key]
|
|
101
|
+ } else {
|
|
102
|
+ found = false
|
|
103
|
+ return {}
|
|
104
|
+ }
|
|
105
|
+ } else {
|
|
106
|
+ if (hasKey(acc, key)) {
|
|
107
|
+ return acc[key]
|
|
108
|
+ } else {
|
|
109
|
+ found = false
|
|
110
|
+ return acc
|
|
111
|
+ }
|
|
112
|
+ }
|
|
113
|
+ }, 0)
|
|
114
|
+}
|
|
115
|
+
|
90
|
116
|
module.exports = {
|
91
|
|
- $api: $api
|
92
|
|
-}
|
|
117
|
+ $api: $api,
|
|
118
|
+ get: get,
|
|
119
|
+}
|