index.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. component_1.VantComponent({
  6. props: {
  7. message: String,
  8. background: String,
  9. type: {
  10. type: String,
  11. value: 'danger'
  12. },
  13. color: {
  14. type: String,
  15. value: color_1.WHITE
  16. },
  17. duration: {
  18. type: Number,
  19. value: 3000
  20. },
  21. zIndex: {
  22. type: Number,
  23. value: 110
  24. },
  25. safeAreaInsetTop: {
  26. type: Boolean,
  27. value: false
  28. }
  29. },
  30. data: {
  31. show: false,
  32. },
  33. created: function () {
  34. var statusBarHeight = wx.getSystemInfoSync().statusBarHeight;
  35. this.setData({ statusBarHeight: statusBarHeight });
  36. },
  37. methods: {
  38. show: function () {
  39. var _this = this;
  40. var _a = this.data, duration = _a.duration, onOpened = _a.onOpened;
  41. clearTimeout(this.timer);
  42. this.setData({ show: true });
  43. wx.nextTick(onOpened);
  44. if (duration > 0 && duration !== Infinity) {
  45. this.timer = setTimeout(function () {
  46. _this.hide();
  47. }, duration);
  48. }
  49. },
  50. hide: function () {
  51. var onClose = this.data.onClose;
  52. clearTimeout(this.timer);
  53. this.setData({ show: false });
  54. wx.nextTick(onClose);
  55. },
  56. onTap: function (event) {
  57. var onClick = this.data.onClick;
  58. if (onClick) {
  59. onClick(event.detail);
  60. }
  61. }
  62. }
  63. });