import httpRequestApi from '../../../utils/APIClient'; Page({ data: { wareCards:[ { title:"铺满色巴掌的水泥道1", grade:"一年级 上学期", img: "../../../static/image/timg.jpg", plays: "1", likes: "2", classId: "1001" }, { title:"铺满金色巴掌的水泥道2", grade:"一年级 上学期", img: "../../../static/image/timg.jpg", plays: "12345", likes: "54321", classId: "1002" }, { title:"铺满金色巴掌的水泥道3", grade:"一年级 上学期", img: "../../../static/image/timg.jpg", plays: "12345", likes: "54321", classId: "1003" }, ] }, onLoad: function (option) { console.log(option); wx.setNavigationBarTitle({ title: '搜索' //页面标题为路由参数 }) console.log(option.keyWords) this.search(option.keyWords); // httpRequestApi.getClassDetail(uid, option.id).success(res => { // console.log(res); // this.setData({ // title: res.data.data.title, // videoUrl:res.data.data.playUrl // }) // }) }, search: function(key){ httpRequestApi.getSearchResult(1,key,1,10).success(res =>{ console.log(res); const result = res.data.data.list; const resultTemp = []; result.forEach(item => { console.log(item) const temp = {}; temp.title = item.lesson.title; temp.grade = item.lesson.gradeClassify; temp.img = item.lesson.iconImg; temp.classId = item.lesson.id resultTemp .push(temp); }); this.setData({ wareCards: resultTemp }) console.log(this.data.wareCards) }); }, openClass: (e) =>{ let id = e.currentTarget.dataset.classid; let title = e.currentTarget.dataset.title; wx.navigateTo({ url: `../class/class?id=${id}&title=${title}` }) } })