index.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var component_1 = require("../common/component");
  4. var color_1 = require("../common/color");
  5. var utils_1 = require("../common/utils");
  6. (0, component_1.VantComponent)({
  7. props: {
  8. message: String,
  9. background: String,
  10. type: {
  11. type: String,
  12. value: 'danger',
  13. },
  14. color: {
  15. type: String,
  16. value: color_1.WHITE,
  17. },
  18. duration: {
  19. type: Number,
  20. value: 3000,
  21. },
  22. zIndex: {
  23. type: Number,
  24. value: 110,
  25. },
  26. safeAreaInsetTop: {
  27. type: Boolean,
  28. value: false,
  29. },
  30. top: null,
  31. },
  32. data: {
  33. show: false,
  34. onOpened: null,
  35. onClose: null,
  36. onClick: null,
  37. },
  38. created: function () {
  39. var statusBarHeight = (0, utils_1.getSystemInfoSync)().statusBarHeight;
  40. this.setData({ statusBarHeight: statusBarHeight });
  41. },
  42. methods: {
  43. show: function () {
  44. var _this = this;
  45. var _a = this.data, duration = _a.duration, onOpened = _a.onOpened;
  46. clearTimeout(this.timer);
  47. this.setData({ show: true });
  48. wx.nextTick(onOpened);
  49. if (duration > 0 && duration !== Infinity) {
  50. this.timer = setTimeout(function () {
  51. _this.hide();
  52. }, duration);
  53. }
  54. },
  55. hide: function () {
  56. var onClose = this.data.onClose;
  57. clearTimeout(this.timer);
  58. this.setData({ show: false });
  59. wx.nextTick(onClose);
  60. },
  61. onTap: function (event) {
  62. var onClick = this.data.onClick;
  63. if (onClick) {
  64. onClick(event.detail);
  65. }
  66. },
  67. },
  68. });