moremovie.js获取movies.js传递过来的类名category,根据category跳转对应的case,加载对应的电影。
var util = require('../../../utils/util.js');
Page({
data: {
categoryTitle: "",
},
onLoad: function(options) {
var dataUrl = ""
var category = options.category;
this.data.categoryTitle = category
console.log(category, "category")
switch (category) {
case "正在热映":
var dataUrl = app.globalData.doubanBase + 'v2/movie/in_theaters';
break;
case "即将上映":
var dataUrl = app.globalData.doubanBase + 'v2/movie/coming_soon';
break;
case "top250":
var dataUrl = app.globalData.doubanBase + 'v2/movie/top250';
break;
}
util.http(dataUrl, this.callBack)
},
callBack: function(data) {
console.log(data)
},
util.js
function http(url,callBack) {
wx.request({
url: url,
method: 'GET',
header: {
"content-Type": ""
},
success: function(res) {
console.log(res)
callBack(res.data);
},
fail: function(error) {
console.log(error)
}
})
}
module.exports = {
http: http
}
网友评论