-
Notifications
You must be signed in to change notification settings - Fork 0
/
reviews.js
59 lines (58 loc) · 1.29 KB
/
reviews.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
const COUNT = 20
Page({
data: {
id: '',
start: 0,
reviews: [],
reviewsTotal: 0,
hasMore: true,
lowerLoadingShow: false
},
onLoad: function(option) {
wx.showLoading({
title: '正在加载中'
})
var id = option.id
this.setData({
id: id
})
var that = this
this.getReviews(this.data.start, COUNT, this.data.reviews, that)
},
getReviews: function(start, count, list, that) {
wx.request({
url: 'https://douban.uieee.com/v2/movie/subject/' + that.data.id + '/reviews',
header:{
"Content-Type": 'json'
},
data: {
start: start,
count: count
},
method: 'GET',
success: function(res) {
if (res.statusCode === 200) {
that.setData({
start: start,
reviewsTotal: res.data.total,
reviews: list.concat(res.data.reviews),
hasMore: res.data.total > (COUNT + start),
lowerLoadingShow: false
})
wx.hideLoading()
}
}
})
},
getMoreReviews: function() {
if (!this.data.hasMore) {
return
}
this.setData({
lowerLoadingShow: true
})
var start = this.data.start + COUNT
var that = this
this.getReviews(start, COUNT, this.data.reviews, that)
}
})