Skip to content

Commit

Permalink
沸点页补充下拉、上拉逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
myvin committed Feb 28, 2019
1 parent 45b2422 commit 5cf49eb
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions pages/feidian/feidian.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Page({
list: [],
auth: {},
scrollTop: 0,
after: ''
},
onShow () {
// 如果 scrollTop 为 0,也 reload
Expand Down Expand Up @@ -93,24 +94,24 @@ Page({
const auth = this.data.auth
let list = this.data.list
if (utils.isEmptyObject(list) || reload) {
list = [{ createdAt: '' }]
this.setData({
list: [],
after: '',
})
}
let createdAt = (list.slice(-1)[0].createdAt) || ''
let after = ''
wx.request({
url: `https://web-api.juejin.im/query`,
header: {
'X-Agent': 'Juejin/Web',
// 'X-Legacy-Device-Id': '1549612042913',
// 'X-Legacy-Token': 'eyJhY2Nlc3NfdG9rZW4iOiJDRUlYajJaOTRvQUdGczNwIiwicmVmcmVzaF90b2tlbiI6InczdXBHNnpoeFFBOGQzN24iLCJ0b2tlbl90eXBlIjoibWFjIiwiZXhwaXJlX2luIjoyNTkyMDAwfQ==',
// 'X-Legacy-Uid': '5b39bb10518825749d2d6d1e',
},
method: 'POST',
data: {
operationName: '',
query: "",
variables: {
size: 20,
after: ''
after: this.data.after,
},
extensions: {
query: {
Expand All @@ -123,6 +124,9 @@ Page({
data = data.data
if (!utils.isEmptyObject(data)) {
const items = data.recommendedActivityFeed.items
this.setData({
after: (items.pageInfo && items.pageInfo.endCursor) || ''
})
const edges = items.edges || []
this.setData({
list: this.data.list.concat(edges)
Expand Down

0 comments on commit 5cf49eb

Please sign in to comment.