| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- Component({
- data: {
- pageToken: 0,
- favorData: []
- },
- lifetimes: {
- ready: function () {
- wx.showLoading({
- title: "加载中"
- })
- wx.cloud.callFunction({
- name: 'listMessages',
- data: {
- favorite: true,
- page_token: this.data.pageToken,
- page_size: 20
- }
- }).then(res => {
- wx.hideLoading()
- if (res.result.status !== 'OK') {
- wx.showToast({
- title: res.result.errMsg,
- icon: 'none'
- })
- return
- }
- this.setData({
- favorData: this.data.favorData.concat(res.result.list),
- pageToken: res.result.next_page_token
- })
- })
- // const db = wx.cloud.database()
- // db.collection("likeData").where({
- // type: "message"
- // }).get({
- // success: function (res) {
- // if (res.data.length == 0) {
- // wx.hideLoading()
- // return
- // }
- // this.processData(res.data)
- // }.bind(this)
- // })
- }
- },
- methods: {
- processData: function (arr) {
- const db = wx.cloud.database()
- for (let i = 0; i < arr.length; i++) {
- db.collection("mainData").doc(arr[i].id).get({
- success: function (res) {
- arr[i].publisherAvatar = res.data.publisherAvatar
- arr[i].publisherName = res.data.publisherName
- arr[i].title = res.data.title
- arr[i].subTitle = res.data.subTitle
- this.setData({
- newNews: arr
- })
- wx.hideLoading()
- }.bind(this)
- })
- }
- }
- }
- })
|