抖音b端
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.

74 line
1.6 KiB

  1. //let host = 'https://biformall.youlane.cn/B'
  2. //let host = 'http://17168c59.ngrok.io/B'
  3. let host = ''
  4. const postRequest = (url, token, message, postData, doSuccess, doFail) => {
  5. let body = { ...postData };
  6. if (message != "") {
  7. tt.showLoading({
  8. title: message,
  9. })
  10. }
  11. tt.request({
  12. //项目的真正接口,通过字符串拼接方式实现
  13. url: host + url,
  14. header: {
  15. "content-type": "application/json;charset=UTF-8",
  16. "token": token
  17. },
  18. data: body,
  19. method: 'POST',
  20. success: function (res) {
  21. //参数值为res.data,直接将返回的数据传入
  22. if (message != "") {
  23. tt.hideLoading()
  24. };
  25. doSuccess(res.data);
  26. },
  27. fail: function (res) {
  28. if (message != "") {
  29. tt.hideLoading()
  30. };
  31. tt.showToast({
  32. title: '网络错误',
  33. icon:"none"
  34. })
  35. },
  36. })
  37. }
  38. const getRequest = (url, token, message, getData, doSuccess, doFail) => {
  39. let body = { ...getData };
  40. if (message != "") {
  41. tt.showLoading({
  42. title: message,
  43. })
  44. }
  45. tt.request({
  46. url: host + url,
  47. header: {
  48. "content-type": "application/json;charset=UTF-8",
  49. "token": token
  50. },
  51. data: body,
  52. method: 'GET',
  53. success: function (res) {
  54. if (message != "") {
  55. tt.hideLoading()
  56. };
  57. doSuccess(res.data);
  58. },
  59. fail: function (res) {
  60. if (message != "") {
  61. tt.hideLoading()
  62. };
  63. tt.showToast({
  64. title: '网络错误',
  65. icon:"none"
  66. })
  67. },
  68. })
  69. }
  70. module.exports = {
  71. postRequest: postRequest,
  72. getRequest: getRequest
  73. }