index.js 682 B

12345678910111213141516171819202122232425262728293031323334353637
  1. Component({
  2. attached () { this._init(); },
  3. pageLifetimes: { show () { this._init() } },
  4. properties: {
  5. },
  6. /**
  7. * 组件的初始数据
  8. */
  9. data: {
  10. durations: { enter: 300, leave: 1000 },
  11. time: 3000,
  12. },
  13. /**
  14. * 组件的方法列表
  15. */
  16. methods: {
  17. // 定义调用组件的js方法
  18. _init () {
  19. wx.lxd = wx.lxd || {}, wx.lxd.Notify = e => {
  20. e.show = true;
  21. console.warn(e)
  22. this.setData({
  23. ...e
  24. })
  25. if (!!e.show) {
  26. const time = setTimeout(() => {
  27. this.setData({ show: false })
  28. clearTimeout(time)
  29. }, this.data.time)
  30. }
  31. }
  32. },
  33. }
  34. })