|
@@ -0,0 +1,121 @@
|
|
|
+// pages/detail/detail.js
|
|
|
+Page({
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 页面的初始数据
|
|
|
+ */
|
|
|
+ data: {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面加载
|
|
|
+ */
|
|
|
+ onLoad: function (options) {
|
|
|
+ var that=this;
|
|
|
+ var type = options.type;
|
|
|
+ var id = options.id;
|
|
|
+ that.setData({
|
|
|
+ type: type,
|
|
|
+ id: id
|
|
|
+ });
|
|
|
+ var url;//详情url
|
|
|
+ var dpurl;//短评的url
|
|
|
+ var count = 3;//短评显示条数
|
|
|
+ var start = 1;//短评开始
|
|
|
+ if(type =="movie"){
|
|
|
+ url = "https://m.douban.com/rexxar/api/v2/movie/" + id;
|
|
|
+ dpurl = 'https://m.douban.com/rexxar/api/v2/movie/' + id + '/interests?count=' + count + '&start=' + start;
|
|
|
+ } else if (type == "tvs" || type == "shows") {
|
|
|
+ url = 'https://m.douban.com/rexxar/api/v2/tv/' + id;
|
|
|
+ dpurl = 'https://m.douban.com/rexxar/api/v2/tv/' + id + '/interests?count=' + count + '&start=' + start;
|
|
|
+ }
|
|
|
+ //获取详情信息
|
|
|
+ wx.request({
|
|
|
+ url: url,
|
|
|
+ success:function(res){
|
|
|
+ var item= res.data;
|
|
|
+ var genres = item.genres;
|
|
|
+ genres=genres.join("/");
|
|
|
+ item.genres = genres;
|
|
|
+ var actors = item.actors;
|
|
|
+ var actorNames = [];
|
|
|
+ if (actors.length > 3) {
|
|
|
+ actors = actors.slice(0, 3);
|
|
|
+ }
|
|
|
+ for (var index = 0; index < actors.length; index++) {
|
|
|
+ var actor = actors[index];
|
|
|
+ actorNames.push(actor.name);
|
|
|
+ }
|
|
|
+ actorNames = actorNames.join("/");
|
|
|
+ var director = item.directors[0].name;
|
|
|
+ var authors = director + "(导演) /" + actorNames;
|
|
|
+ item.authors = authors;
|
|
|
+ that.setData({
|
|
|
+ item:item
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ //获取短评信息
|
|
|
+ wx.request({
|
|
|
+ url: dpurl,
|
|
|
+ success:function(res){
|
|
|
+ that.setData({
|
|
|
+ comments: res.data.interests
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面初次渲染完成
|
|
|
+ */
|
|
|
+ onReady: function () {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面显示
|
|
|
+ */
|
|
|
+ onShow: function () {
|
|
|
+ //页面加载时滚动到头部
|
|
|
+ wx.pageScrollTo({
|
|
|
+ scrollTop: 0,
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面隐藏
|
|
|
+ */
|
|
|
+ onHide: function () {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面卸载
|
|
|
+ */
|
|
|
+ onUnload: function () {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 页面相关事件处理函数--监听用户下拉动作
|
|
|
+ */
|
|
|
+ onPullDownRefresh: function () {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 页面上拉触底事件的处理函数
|
|
|
+ */
|
|
|
+ onReachBottom: function () {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 用户点击右上角分享
|
|
|
+ */
|
|
|
+ onShareAppMessage: function () {
|
|
|
+
|
|
|
+ }
|
|
|
+})
|