api.js 705 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. const http = uni.$u.http
  2. function SetBaseUrl(url){
  3. http.setConfig((config) => {
  4. /* config 为默认全局配置*/
  5. config.baseURL = url; /* 根域名 */
  6. return config
  7. })
  8. }
  9. function GetToken(url, username, password) {
  10. return http.post(url, {username, password}, {
  11. custom:{auth: false}
  12. })
  13. }
  14. function GetConfig(url) {
  15. return http.get(url)
  16. }
  17. function SetConfig(url, conf) {
  18. return http.put(url, conf)
  19. }
  20. function UploadFile(url, imei, file, name){
  21. return http.upload(url,{
  22. filePath: plus.io.convertAbsoluteFileSystem(file),
  23. name,
  24. formData: {
  25. imei
  26. }
  27. })
  28. }
  29. export default {
  30. SetBaseUrl,
  31. GetToken,
  32. GetConfig,
  33. SetConfig,
  34. UploadFile
  35. }