request.js 911 B

123456789101112131415161718192021222324252627282930
  1. const baseUrl = 'https://jlxwjr.jljrkg.com';
  2. const imageUrl = 'https://jlxwjr.jljrkg.com';
  3. module.exports = {
  4. imageUrl,
  5. query({url, data, method = 'GET'}) {
  6. return new Promise((resolve, reject) => {
  7. wx.request({
  8. url: `${baseUrl}/${url}`,
  9. data: data,
  10. method: method,
  11. header: {'content-type': 'application/json'},
  12. dataType: 'json',
  13. success: resolve,
  14. fail: reject,
  15. });
  16. });
  17. },
  18. fetch({url, id}) {
  19. return new Promise((resolve, reject) => {
  20. wx.request({
  21. url: `${baseUrl}/${url}/${id}`,
  22. method: 'GET',
  23. header: {'content-type': 'application/json'},
  24. dataType: 'json',
  25. success: resolve,
  26. fail: reject,
  27. });
  28. });
  29. },
  30. }