更新了URL,但是subject是obejct,没有数据
来源:20-14 电影页面数据绑定(下)
森林迷了鹿Andera
2018-06-06
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);
}
})
1回答
-
kekestudy
2018-06-18
doubanBase:"https://douban.uieee.com"
00
相似问题