common.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 showConfirm(content) {
  10. return new Promise((resolve, reject) => {
  11. common_vendor.index.showModal({
  12. title: "提示",
  13. content,
  14. cancelText: "取消",
  15. confirmText: "确定",
  16. success: function(res) {
  17. resolve(res);
  18. }
  19. });
  20. });
  21. }
  22. function tansParams(params) {
  23. let result = "";
  24. for (const propName of Object.keys(params)) {
  25. const value = params[propName];
  26. var part = encodeURIComponent(propName) + "=";
  27. if (value !== null && value !== "" && typeof value !== "undefined") {
  28. if (typeof value === "object") {
  29. for (const key of Object.keys(value)) {
  30. if (value[key] !== null && value[key] !== "" && typeof value[key] !== "undefined") {
  31. let params2 = propName + "[" + key + "]";
  32. var subPart = encodeURIComponent(params2) + "=";
  33. result += subPart + encodeURIComponent(value[key]) + "&";
  34. }
  35. }
  36. } else {
  37. result += part + encodeURIComponent(value) + "&";
  38. }
  39. }
  40. }
  41. return result;
  42. }
  43. exports.showConfirm = showConfirm;
  44. exports.tansParams = tansParams;
  45. exports.toast = toast;