企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持知识库和私有化部署方案 广告
~~~ // pages/index/index.js //import {http} from "../../utils/http"; import {MovieModel} from "../../models/MovieModel" const movieModel=new MovieModel(); Page({ data:{ movies:[], total:null, }, onReachBottom(){ var length=this.data.movies.length; if(length<this.data.total){ wx.showLoading(); // http("top250?start="+length+"&count=20",this.handleData); movieModel.getOnBottom(length,res=>{ this.handleData(res); }) } }, onLoad(){ // http("top250",this.handleData); movieModel.getTop250(res=>{ this.handleData(res); }) }, handleData(res){ var movies=[]; var subjects=res.data.subjects; // subjects.forEach(item => { // var imageUrl=item.images.large; // var title=item.title.slice(0,6)+"..."; // var average=item.rating.average; // var temp={ // imageUrl, // title, // average // }; // movies.push(temp); // }) for(var i=0;i<subjects.length;i++){ var imageUrl=subjects[i].images.large; var title=subjects[i].title.slice(0,6)+"..."; var average=subjects[i].rating.average; var id=subjects[i].id; var temp={ imageUrl, title, average, id, } movies.push(temp); } movies=this.data.movies.concat(movies); this.setData({ movies, total:res.data.total }) wx.hideLoading(); } }) ~~~