其他的电影评分没有显示,查了一下appdata,是因为其他电影的评分处理出来的分数是0,0,0,0,0数组,觉得好奇怪,复用都是对的,求有没有共同问题的小伙伴。
// 这是movie.js的代码 var util = require('../../utils/util.js'); var app = getApp(); Page({ data: { inTheaters:{}, comingSoon:{}, top250:{} }, onLoad:function(event){ var inTheatersUrl = app.globalData.doubanBase + "/v2/movie/in_theaters" + "?start=0&count=3"; var comingSoonUrl = app.globalData.doubanBase + "/v2/movie/coming_soon" + "?start=0&count=3"; var top250Url = app.globalData.doubanBase + "/v2/movie/top250" + "?start=0&count=3"; this.getMovieListData(inTheatersUrl,"inTheaters"); this.getMovieListData(comingSoonUrl,"comingSoon"); this.getMovieListData(top250Url,".top250"); }, getMovieListData:function(url,settedKey){ var that = this; wx.request({ url: url, method: 'GET', header: { "Content-Type": "application/xml" }, success: function (res) { console.log(res); that.processDoubanData(res.data,settedKey); }, fail: function () { console.log("failed"); } }) }, processDoubanData:function(moviesDouban,settedKey){ var movies = []; for(var idx in moviesDouban.subjects){ var subject = moviesDouban.subjects[idx]; var title = subject.title; if(title.length >= 6){ title = title.substring(0,6) + "···"; } var temp = { stars:util.convertToStarsArray(subject.rating.stars), title:title, average:subject.rating.average, coverageUrl:subject.images.large, movieId:subject.id } movies.push(temp); } var readyData = {}; readyData[settedKey] = { movies:movies }; this.setData(readyData); }, })
4年同步微信官方迭代,累计20000+人学习, 比微信官方更火爆!
了解课程