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
| /**
| * @param {string} url url地址
| * @param {any} postData 参数
| * @param {string} method 请求方式
| * @param {boolean} hideLoading 是否load
| * @description: 格式化时间
| */
| export function request(url, postData, method = 'POST', hideLoading = 'false') {
| if (!hideLoading) {
| uni.showLoading({
| title: '请稍候...',
| mask: true
| })
| }
| return new Promise((resolve, reject) => {
| const token = uni.getStorageSync('token');
| // const URL = 'http://47.76.147.249:8080/rsf-server/pda' + url;
| // const URL = 'http://192.168.4.24:8080/rsf-server/pda' + url;
| const URL = 'http://127.0.0.1:8080/rsf-server/pda' + url;
| uni.request({
| url: URL,
| data: postData,
| header: {
| 'content-type': 'application/json',
| 'authorization': token
| },
| method: method, //'GET','POST'
| dataType: 'json',
| success: (res) => {
| !hideLoading && uni.hideLoading()
| resolve(res.data)
|
| },
| fail: (res) => {
| // !hideLoading && toast("网络不给力,请稍后再试~")
| //wx.hideLoading()
| reject(res)
| }
| })
| })
| }
|
|