请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

更新了URL,但是subject是obejct,没有数据

var app = getApp();


// pages/movies/movies.js

Page({


onLoad: function (options) {


var gloabalBase = app.globalData.douBanBase;


var inTheatersURL = gloabalBase + "/v2/movie/in_theaters" +"?start=0&count=3";

var commningSoonURL = gloabalBase + "/v2/movie/coming_soon" + "?start=0&count=3";

var topURL = gloabalBase + "/v2/movie/top250" + "?start=0&count=3";


this.getMovieListData(inTheatersURL);

// this.getMovieListData(commningSoonURL);

// this.getMovieListData(topURL);


},

getMovieListData:function(url){

var that = this;


wx.request({

url:url ,

method: 'GET',

header: {

'Content-Type': 'json'

},

success: function (res) {

console.log(res.data);

that.processMovieData(res.data);

}


});


},


processMovieData:function(movieData){


var movies = [];

for(var item in movieData.subjects){

var subject = movieData.subjects[item];

var title = subject.title;

if(title.length >6){

title = title.substring(0,6)+"...";

}

var temp = {

title:title,

id:subject.id,

img: subject.images.large,

average: subject.rating.average

}

movies.push(temp);

}

this.setData({

movies : movies

});


console.log("movies:"+movies);

}

})


正在回答 回答被采纳积分+3

1回答

kekestudy 2018-06-18 13:10:25

doubanBase:"https://douban.uieee.com"


0 回复 有任何疑惑可以回复我~
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信