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

78 lines
1.8 KiB

  1. //let host = 'https://biformall.youlane.cn/B'
  2. //let host = 'http://17168c59.ngrok.io/B'
  3. let host = 'https://btest.malls.iformall.com/B'
  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. // "token": "0b272d7d-d669-401a-8d4b-a9eef9340dc1:1027:tt-cuser"
  18. },
  19. data: body,
  20. method: 'POST',
  21. success: function (res) {
  22. //参数值为res.data,直接将返回的数据传入
  23. if (message != "") {
  24. tt.hideLoading()
  25. };
  26. doSuccess(res.data);
  27. },
  28. fail: function (res) {
  29. if (message != "") {
  30. tt.hideLoading()
  31. };
  32. tt.showToast({
  33. title: '网络错误',
  34. icon:"none"
  35. })
  36. },
  37. })
  38. }
  39. const getRequest = (url, token, message, getData, doSuccess, doFail) => {
  40. let body = { ...getData };
  41. if (message != "") {
  42. tt.showLoading({
  43. title: message,
  44. })
  45. }
  46. tt.request({
  47. url: host + url,
  48. header: {
  49. "content-type": "application/json;charset=UTF-8",
  50. "token": token
  51. // "token": "0b272d7d-d669-401a-8d4b-a9eef9340dc1:1027:tt-cuser"
  52. },
  53. data: body,
  54. method: 'GET',
  55. success: function (res) {
  56. if (message != "") {
  57. tt.hideLoading()
  58. };
  59. doSuccess(res.data);
  60. },
  61. fail: function (err) {
  62. console.log(err);
  63. if (message != "") {
  64. tt.hideLoading()
  65. };
  66. tt.showToast({
  67. title: '网络错误',
  68. icon:"none"
  69. })
  70. },
  71. })
  72. }
  73. module.exports = {
  74. postRequest: postRequest,
  75. getRequest: getRequest
  76. }