|
- //let host = 'https://biformall.youlane.cn/B'
- //let host = 'http://17168c59.ngrok.io/B'
- let host = ''
-
- const postRequest = (url, token, message, postData, doSuccess, doFail) => {
- let body = { ...postData };
- if (message != "") {
- tt.showLoading({
- title: message,
- })
- }
- tt.request({
- //项目的真正接口,通过字符串拼接方式实现
- url: host + url,
- header: {
- "content-type": "application/json;charset=UTF-8",
- "token": token
- },
- data: body,
- method: 'POST',
- success: function (res) {
- //参数值为res.data,直接将返回的数据传入
- if (message != "") {
- tt.hideLoading()
- };
- doSuccess(res.data);
- },
- fail: function (res) {
- if (message != "") {
- tt.hideLoading()
- };
- tt.showToast({
- title: '网络错误',
- icon:"none"
- })
- },
- })
- }
- const getRequest = (url, token, message, getData, doSuccess, doFail) => {
- let body = { ...getData };
- if (message != "") {
- tt.showLoading({
- title: message,
- })
- }
- tt.request({
- url: host + url,
- header: {
- "content-type": "application/json;charset=UTF-8",
- "token": token
- },
- data: body,
- method: 'GET',
- success: function (res) {
- if (message != "") {
- tt.hideLoading()
- };
- doSuccess(res.data);
- },
- fail: function (res) {
- if (message != "") {
- tt.hideLoading()
- };
- tt.showToast({
- title: '网络错误',
- icon:"none"
- })
- },
- })
- }
- module.exports = {
- postRequest: postRequest,
- getRequest: getRequest
- }
|