index.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. "use strict";
  2. var _page = _interopRequireDefault(require("../../common/page"));
  3. var _toast = _interopRequireDefault(require("../../dist/toast/toast"));
  4. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  5. (0, _page["default"])({
  6. data: {
  7. minHour: 10,
  8. maxHour: 20,
  9. minDate: new Date(2018, 0, 1).getTime(),
  10. maxDate: new Date(2019, 10, 1).getTime(),
  11. currentDate1: new Date(2018, 2, 31).getTime(),
  12. currentDate2: null,
  13. currentDate3: new Date(2018, 0, 1),
  14. currentDate4: "12:00",
  15. loading: false,
  16. formatter: function formatter(type, value) {
  17. if (type === "year") {
  18. return "".concat(value, "\u5E74");
  19. }
  20. if (type === "month") {
  21. return "".concat(value, "\u6708");
  22. }
  23. return value;
  24. },
  25. filter: function filter(type, options) {
  26. if (type === "minute") {
  27. return options.filter(function (option) {
  28. return option % 5 === 0;
  29. });
  30. }
  31. return options;
  32. }
  33. },
  34. onInput: function onInput(event) {
  35. var detail = event.detail,
  36. currentTarget = event.currentTarget;
  37. var result = this.getResult(detail, currentTarget.dataset.type);
  38. (0, _toast["default"])(result);
  39. },
  40. getResult: function getResult(time, type) {
  41. var date = new Date(time);
  42. switch (type) {
  43. case "datetime":
  44. return date.toLocaleString();
  45. case "date":
  46. return date.toLocaleDateString();
  47. case "year-month":
  48. return "".concat(date.getFullYear(), "/").concat(date.getMonth() + 1);
  49. case "time":
  50. return time;
  51. default:
  52. return "";
  53. }
  54. }
  55. });