request.js 944 B

12345678910111213141516171819202122232425262728293031
  1. // const imageUrl = 'https://jlxwjr.jljrkg.com';
  2. // const baseUrl = 'https://ccss.windd.cn';
  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. timeout: 5000,
  12. header: {'content-type': 'application/json'},
  13. dataType: 'json',
  14. success: resolve,
  15. fail: reject,
  16. });
  17. });
  18. },
  19. fetch({url, id}) {
  20. return new Promise((resolve, reject) => {
  21. wx.request({
  22. url: `${baseUrl}/${url}/${id}`,
  23. method: 'GET',
  24. header: {'content-type': 'application/json'},
  25. dataType: 'json',
  26. success: resolve,
  27. fail: reject,
  28. });
  29. });
  30. },
  31. }