index.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. "use strict";
  2. var _component = require("../common/component");
  3. var _color = require("../common/color");
  4. var _my = require("../../__antmove/api/index.js")(my);
  5. var wx = _my;
  6. (0, _component.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.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 created() {
  36. var _wx$getSystemInfoSync = wx.getSystemInfoSync(),
  37. statusBarHeight = _wx$getSystemInfoSync.statusBarHeight;
  38. this.setData({
  39. statusBarHeight: statusBarHeight
  40. });
  41. },
  42. methods: {
  43. show: function show() {
  44. var _this = this;
  45. var _this$data = this.data,
  46. duration = _this$data.duration,
  47. onOpened = _this$data.onOpened;
  48. clearTimeout(this.timer);
  49. this.setData({
  50. show: true
  51. }); // wx.nextTick(onOpened);
  52. onOpened();
  53. if (duration > 0 && duration !== Infinity) {
  54. this.timer = setTimeout(function () {
  55. _this.hide();
  56. }, duration);
  57. }
  58. },
  59. hide: function hide() {
  60. var onClose = this.data.onClose;
  61. clearTimeout(this.timer);
  62. this.setData({
  63. show: false
  64. }); // wx.nextTick(onClose);
  65. onClose();
  66. },
  67. onTap: function onTap(event) {
  68. var onClick = this.data.onClick;
  69. if (onClick) {
  70. onClick(event.detail);
  71. }
  72. }
  73. }
  74. });