util.js 848 B

123456789101112131415161718192021
  1. export function tansParams(params) {
  2. let result = ''
  3. for (const propName of Object.keys(params)) {
  4. const value = params[propName];
  5. var part = encodeURIComponent(propName) + "=";
  6. if (value !== null && typeof (value) !== "undefined") {
  7. if (typeof value === 'object') {
  8. for (const key of Object.keys(value)) {
  9. if (value[key] !== null && typeof (value[key]) !== 'undefined') {
  10. let params = propName + '[' + key + ']';
  11. var subPart = encodeURIComponent(params) + "=";
  12. result += subPart + encodeURIComponent(value[key]) + "&";
  13. }
  14. }
  15. } else {
  16. result += part + encodeURIComponent(value) + "&";
  17. }
  18. }
  19. }
  20. return result
  21. }