common.js 986 B

12345678910111213141516171819202122232425262728293031
  1. "use strict";
  2. const common_vendor = require("../common/vendor.js");
  3. function toast(content) {
  4. common_vendor.index.showToast({
  5. icon: "none",
  6. title: content
  7. });
  8. }
  9. function tansParams(params) {
  10. let result = "";
  11. for (const propName of Object.keys(params)) {
  12. const value = params[propName];
  13. var part = encodeURIComponent(propName) + "=";
  14. if (value !== null && value !== "" && typeof value !== "undefined") {
  15. if (typeof value === "object") {
  16. for (const key of Object.keys(value)) {
  17. if (value[key] !== null && value[key] !== "" && typeof value[key] !== "undefined") {
  18. let params2 = propName + "[" + key + "]";
  19. var subPart = encodeURIComponent(params2) + "=";
  20. result += subPart + encodeURIComponent(value[key]) + "&";
  21. }
  22. }
  23. } else {
  24. result += part + encodeURIComponent(value) + "&";
  25. }
  26. }
  27. }
  28. return result;
  29. }
  30. exports.tansParams = tansParams;
  31. exports.toast = toast;