只显示了部分电影的星星评分,其他的为0星
来源:20-15 星星评分组件的实现
飞翔的光少
2017-08-28
其他的电影评分没有显示,查了一下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); }, })
写回答
1回答
-
7七月
2017-08-29
这肯定是 那个评分转换函数写的不对,调试看看每个变量的变化状态就能找到原因。
052017-08-31
相似问题