index.js 1.5 KB

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