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
| /**
| * @param {string} url 请求地址
| * @param {object} data 请求参数
| * @param {string} method 请求方法
| */
| const request = (url, data, method) => {
|
| return new Promise((resole, reject) => {
| uni.request({
| url: `http://192.168.0.15:10012/web/${url}`,
| method,
| data,
| header: {
| token: token ? token : ''
| },
| success: (res) => {
| if (res.data.code === 200) {
| resole(res.data)
| } else {
| uni.showToast({
| title: res.data.msg,
| icon: 'error',
| duration: 2000
| });
| reject()
| }
| },
| fail(err) {
| reject()
| uni.showToast({
| title: err,
| icon: 'error',
| duration: 2000
| });
| }
| })
| })
| }
|
| const get = (url, data) => request(url, data, 'GET')
|
| const post = (url, data) => request(url, data, 'POST')
|
| export {
| get, post
| }
|
|