You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.2 KiB
64 lines
1.2 KiB
function request (url, method, data, header = {},type) { |
|
var headType = 'application/json' |
|
// var BASE_API = 'https://www.biutag.com:8765/face' |
|
// var BASE_API = 'http://localhost:9903' |
|
var BASE_API = 'https://kd.biutag.com:9903' |
|
// var BASE_API = 'http://localhost:9903' |
|
switch (type) { |
|
case 'json': |
|
headType = 'application/json' |
|
break; |
|
case 'form': |
|
headType = 'application/x-www-form-urlencoded' |
|
break; |
|
case 'other': |
|
break; |
|
} |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
uni.showLoading({ |
|
title: '加载中', |
|
mask: true |
|
}) |
|
|
|
uni.request({ |
|
url: BASE_API + url, |
|
method: method, |
|
data: data, |
|
header: { |
|
'Access-Control-Allow-Origin': 'http://localhost:8000' |
|
}, |
|
success: function (res) { |
|
uni.hideLoading() |
|
resolve(res.data) |
|
}, |
|
fail: function (res) { |
|
uni.hideLoading() |
|
uni.showToast({ |
|
title: '网络错误', |
|
icon: 'none' |
|
}) |
|
resolve(res) |
|
}, |
|
complete: function () { |
|
uni.hideLoading() |
|
} |
|
}) |
|
}) |
|
} |
|
|
|
|
|
function get (obj) { |
|
return request(obj.url, 'GET', obj.data,{},obj.type) |
|
} |
|
|
|
function post (obj) { |
|
return request(obj.url, 'POST', obj.data,{},obj.type) |
|
} |
|
|
|
export default { |
|
request, |
|
get, |
|
post, |
|
}
|
|
|