util.js 910 B

1234567891011121314151617181920212223242526272829
  1. "use strict";
  2. const config_env = require("../config/env.js");
  3. function formatTime(time, format = "yyyy年MM月dd日") {
  4. const date = new Date(time);
  5. const formatObj = {
  6. "y+": date.getFullYear(),
  7. "M+": date.getMonth() + 1,
  8. "d+": date.getDate(),
  9. "H+": date.getHours(),
  10. "m+": date.getMinutes(),
  11. "s+": date.getSeconds()
  12. };
  13. for (let key in formatObj) {
  14. if (new RegExp(`(${key})`).test(format)) {
  15. const str = formatObj[key].toString();
  16. format = format.replace(
  17. RegExp.$1,
  18. RegExp.$1.length === 1 ? str : ("00" + str).slice(str.length)
  19. );
  20. }
  21. }
  22. return format;
  23. }
  24. function getImageUrl(path) {
  25. return config_env.env.baseUrl + "/service?ssServ=dlByHttp&wdConfirmationCaptchaService=0&type=img&path=" + path;
  26. }
  27. exports.formatTime = formatTime;
  28. exports.getImageUrl = getImageUrl;
  29. //# sourceMappingURL=../../.sourcemap/mp-weixin/utils/util.js.map