followNews.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. Component({
  2. data: {
  3. newMessage: []
  4. },
  5. lifetimes: {
  6. ready: function() {
  7. this.init()
  8. }
  9. },
  10. pageLifetimes: {
  11. show: function () {
  12. this.init()
  13. }
  14. },
  15. methods: {
  16. init: function () {
  17. wx.showNavigationBarLoading()
  18. const db = wx.cloud.database()
  19. const _ = db.command
  20. db.collection("likeData").where({
  21. type: "publisher"
  22. }).get({
  23. success: function (res) {
  24. if (res.data.length == 0) {
  25. wx.hideNavigationBarLoading()
  26. return
  27. }
  28. var con = _.eq(res.data[0].id)
  29. for (let j = 1; j < res.data.length; j++) {
  30. con = con.or(_.eq(res.data[j].id))
  31. }
  32. db.collection("mainData").orderBy("time", "desc").limit(20).where({
  33. publisherId: con
  34. }).get({
  35. success: function (res) {
  36. this.setData({
  37. newMessage: res.data
  38. })
  39. wx.hideNavigationBarLoading()
  40. }.bind(this)
  41. })
  42. }.bind(this)
  43. })
  44. }
  45. }
  46. })