index.js 754 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // components/l-noticebar/index.js
  2. Component({
  3. attached () { this._init(); },
  4. pageLifetimes: { show () { this._init() } },
  5. properties: {
  6. },
  7. /**
  8. * 组件的初始数据
  9. */
  10. data: {
  11. active: 0,
  12. time: 8000,
  13. },
  14. /**
  15. * 组件的方法列表
  16. */
  17. methods: {
  18. _init () {
  19. wx.lxd = wx.lxd || {}, wx.lxd.NoticeBar = e => {
  20. e.datalist = e.datalist.map((item, index) => {
  21. index == 0 ? item["active"] = true : item["active"] = false;
  22. return item;
  23. })
  24. this.setData({
  25. ...e
  26. })
  27. }
  28. },
  29. success (e) {
  30. let { datalist } = this.data, { index } = e.currentTarget.dataset;
  31. wx.navigateTo({
  32. url: datalist[index]["url"],
  33. })
  34. }
  35. }
  36. })