|
@@ -0,0 +1,127 @@
|
|
|
+// pages/list/list.js
|
|
|
+Page({
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 页面的初始数据
|
|
|
+ */
|
|
|
+ data: {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面加载
|
|
|
+ */
|
|
|
+ onLoad: function (options) {
|
|
|
+ var that = this;
|
|
|
+ wx.showLoading({
|
|
|
+ title: '正在加载中...',
|
|
|
+ });
|
|
|
+ that.setData({
|
|
|
+ type: options.type
|
|
|
+ })
|
|
|
+ if (options.type=='movie'){
|
|
|
+ //请求电影
|
|
|
+ wx.request({
|
|
|
+ url: 'https://m.douban.com/rexxar/api/v2/subject_collection/movie_showing/items',
|
|
|
+ success: function (res) {
|
|
|
+ var movies = res.data.subject_collection_items;
|
|
|
+
|
|
|
+ //设置如果最后剩下2个的情况下在添加一个空元素
|
|
|
+ var itemsCount = movies.length;
|
|
|
+ var left = itemsCount%3;
|
|
|
+ if(left==2){
|
|
|
+ movies.push(null);
|
|
|
+ }
|
|
|
+
|
|
|
+ that.setData({
|
|
|
+ movies: movies
|
|
|
+ })
|
|
|
+ wx.hideLoading();
|
|
|
+ }
|
|
|
+ })
|
|
|
+ //设置标题
|
|
|
+ wx.setNavigationBarTitle({
|
|
|
+ title: '电影',
|
|
|
+ })
|
|
|
+ } else if (options.type == 'tvs'){
|
|
|
+ //请求电视剧
|
|
|
+ wx.request({
|
|
|
+ url: 'https://m.douban.com/rexxar/api/v2/subject_collection/tv_hot/items',
|
|
|
+ success: function (res) {
|
|
|
+ var movies = res.data.subject_collection_items;
|
|
|
+ that.setData({
|
|
|
+ movies: movies
|
|
|
+ });
|
|
|
+ wx.hideLoading();
|
|
|
+ }
|
|
|
+ })
|
|
|
+ wx.setNavigationBarTitle({
|
|
|
+ title: '电视剧',
|
|
|
+ })
|
|
|
+ } else if (options.type == 'shows'){
|
|
|
+ //请求综艺
|
|
|
+ wx.request({
|
|
|
+ url: 'https://m.douban.com/rexxar/api/v2/subject_collection/tv_variety_show/items',
|
|
|
+ success: function (res) {
|
|
|
+ var movies = res.data.subject_collection_items;
|
|
|
+ that.setData({
|
|
|
+ movies: movies
|
|
|
+ });
|
|
|
+ wx.hideLoading();
|
|
|
+ }
|
|
|
+ })
|
|
|
+ wx.setNavigationBarTitle({
|
|
|
+ title: '综艺',
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面初次渲染完成
|
|
|
+ */
|
|
|
+ onReady: function () {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面显示
|
|
|
+ */
|
|
|
+ onShow: function () {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面隐藏
|
|
|
+ */
|
|
|
+ onHide: function () {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面卸载
|
|
|
+ */
|
|
|
+ onUnload: function () {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 页面相关事件处理函数--监听用户下拉动作
|
|
|
+ */
|
|
|
+ onPullDownRefresh: function () {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 页面上拉触底事件的处理函数
|
|
|
+ */
|
|
|
+ onReachBottom: function () {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 用户点击右上角分享
|
|
|
+ */
|
|
|
+ onShareAppMessage: function () {
|
|
|
+
|
|
|
+ }
|
|
|
+})
|