|
@@ -0,0 +1,70 @@
|
|
|
+// pages/comment/comment.js
|
|
|
+Page({
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 页面的初始数据
|
|
|
+ */
|
|
|
+ data: {
|
|
|
+ start: 1,//短评开始
|
|
|
+ count: 10//短评显示条数
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面加载
|
|
|
+ */
|
|
|
+ onLoad: function (options) {
|
|
|
+ var that =this;
|
|
|
+ that.setData({
|
|
|
+ title: options.title,
|
|
|
+ imgUrl: options.imgUrl,
|
|
|
+ rate: options.rate,
|
|
|
+ id: options.id,
|
|
|
+ type: options.type
|
|
|
+ });
|
|
|
+ that.getComments(1);
|
|
|
+ },
|
|
|
+ getComments:function(start){
|
|
|
+ var that = this;
|
|
|
+ var type = that.data.type;
|
|
|
+ var id = that.data.id;
|
|
|
+ var dpurl;//短评的url
|
|
|
+ var count = that.data.count;//短评显示条数
|
|
|
+ var start = start;//短评开始
|
|
|
+ if (type == "movie") {
|
|
|
+ dpurl = 'https://m.douban.com/rexxar/api/v2/movie/' + id + '/interests?count=' + count + '&start=' + start;
|
|
|
+ } else if (type == "tvs" || type == "shows") {
|
|
|
+ dpurl = 'https://m.douban.com/rexxar/api/v2/tv/' + id + '/interests?count=' + count + '&start=' + start;
|
|
|
+ }
|
|
|
+ //获取短评信息
|
|
|
+ wx.request({
|
|
|
+ url: dpurl,
|
|
|
+ success: function (res) {
|
|
|
+ that.setData({
|
|
|
+ comments: res.data.interests,
|
|
|
+ start: start
|
|
|
+ });
|
|
|
+ wx.pageScrollTo({
|
|
|
+ scrollTop: 0,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onItemTapEvent:function(event){
|
|
|
+ //返回上一页
|
|
|
+ wx.navigateBack({})
|
|
|
+ },
|
|
|
+ upPage:function(event){
|
|
|
+ var that = this;
|
|
|
+ var start = that.data.start;
|
|
|
+ var count = that.data.count;
|
|
|
+ if (start - count > 0){
|
|
|
+ that.getComments(start - count);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ nextPage: function (event) {
|
|
|
+ var that = this;
|
|
|
+ var start = that.data.start;
|
|
|
+ var count = that.data.count;
|
|
|
+ that.getComments(start + count);
|
|
|
+ },
|
|
|
+})
|