network.js 730 B

1234567891011121314151617181920212223242526272829303132
  1. // method OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
  2. function request(dever, url, param, callback, method, header){
  3. if(!method) {
  4. method = 'get';
  5. }
  6. if (!header) {
  7. var header = {};
  8. header['content-type'] = 'application/x-www-form-urlencoded';
  9. }
  10. for (var i in dever.config.host) {
  11. if (url.indexOf(i + '.') != -1) {
  12. url = url.replace(i + '.', dever.config.host[i]);
  13. break;
  14. }
  15. }
  16. wx.request({
  17. url: url,
  18. data: param,
  19. method: method.toUpperCase(),
  20. header: header,
  21. success: callback.success,
  22. fail: callback.fail,
  23. complete: callback.complete
  24. })
  25. }
  26. module.exports = {
  27. request:request
  28. }