C端小程序
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.

70 lines
1.5 KiB

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