index.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. top: null,
  30. },
  31. data: {
  32. show: false,
  33. },
  34. created: function () {
  35. var statusBarHeight = wx.getSystemInfoSync().statusBarHeight;
  36. this.setData({ statusBarHeight: statusBarHeight });
  37. },
  38. methods: {
  39. show: function () {
  40. var _this = this;
  41. var _a = this.data,
  42. duration = _a.duration,
  43. onOpened = _a.onOpened;
  44. clearTimeout(this.timer);
  45. this.setData({ show: true });
  46. wx.nextTick(onOpened);
  47. if (duration > 0 && duration !== Infinity) {
  48. this.timer = setTimeout(function () {
  49. _this.hide();
  50. }, duration);
  51. }
  52. },
  53. hide: function () {
  54. var onClose = this.data.onClose;
  55. clearTimeout(this.timer);
  56. this.setData({ show: false });
  57. wx.nextTick(onClose);
  58. },
  59. onTap: function (event) {
  60. var onClick = this.data.onClick;
  61. if (onClick) {
  62. onClick(event.detail);
  63. }
  64. },
  65. },
  66. });