You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
hunjianghu/江可飞/小程序开发/pages/fenlei/fenlei.js

156 lines
3.8 KiB

6 years ago
// pages/fenlei/fenlei.js
Page({
data: {
6 years ago
'book':[],
6 years ago
cateItems: [
{
cate_id: 1,
6 years ago
cate_name: "玄幻",
6 years ago
ishaveChild: true,
6 years ago
// children:
// [
// {
// child_id: 1,
// name: '福尔摩斯',
// image: "/pages/index/image/xs1.jpg"
// },
// {
// child_id: 2,
// name: '莫泊桑',
// image: "/pages/index/image/xs2.jpg"
// },
// {
// child_id: 3,
// name: '盗墓笔记',
// image: "/pages/index/image/xs3.jpg"
// },
// {
// child_id: 4,
// name: '明朝那些事',
// image: "/pages/index/image/xs4.jpg"
// }
// ]
6 years ago
},
{
cate_id: 2,
6 years ago
cate_name: "魔幻",
6 years ago
ishaveChild: true,
6 years ago
// children:
// [
// {
// child_id: 1,
// name: '世界百科',
// image: "/pages/index/image/kxqk1.jpg"
// },
// {
// child_id: 2,
// name: '动物百科',
// image: "/pages/index/image/kxqk2.jpg"
// },
// {
// child_id: 3,
// name: '趣味科学',
// image: "/pages/index/image/kxqk3.jpg"
// }
// ]
6 years ago
},
{
cate_id: 3,
6 years ago
cate_name: "奇幻",
6 years ago
ishaveChild: true,
6 years ago
// children:
// [
// {
// child_id: 1,
// name: '父与子全集',
// image: "/pages/index/image/etsj1.jpg"
// },
// {
// child_id: 2,
// name: '丁丁历险记',
// image: "/pages/index/image/etsj2.jpg"
// },
// {
// child_id: 3,
// name: '美丽星空',
// image: "/pages/index/image/etsj3.jpg"
// },
// {
// child_id: 4,
// name: '小虎神探队',
// image: "/pages/index/image/etsj4.jpg"
// }
// ]
6 years ago
},
{
cate_id: 4,
6 years ago
cate_name: "都市",
6 years ago
ishaveChild: true,
6 years ago
// children: [
// {
// child_id: 1,
// name: 'Java Web',
// image: "/pages/index/image/java.jpg"
// },
// {
// child_id: 2,
// name: '计算机网络',
// image:"/pages/index/image/jsswl.jpg"
// },
// ]
6 years ago
}
],
curNav: 1,
curIndex: 0
6 years ago
},
6 years ago
onload:function(){
var thats = this
wx.request({
url: "http://45.76.158.31:8080/web/GetFrontInfo.dotype=" + 1,
header: {
"content-type": "json"
},
success: function (res) {
console.log(res.data)
if (res.statusCode == 200) {
thats.setData({
book: res.data,
})
//wx.hideNavigationBarLoading()
}
}
})
},
6 years ago
//事件处理函数
switchRightTab: function (e) {
// 获取item项的id和数组的下标值
let id = e.target.dataset.id,
index = parseInt(e.target.dataset.index);
6 years ago
console.log(id)
var thats = this
wx.request({
url: "http://45.76.158.31:8080/web/GetFrontInfo.dotype="+id,
header: {
"content-type": "json"
},
success: function (res) {
console.log(res.data)
if (res.statusCode == 200) {
thats.setData({
book: res.data,
ppt: res.data
})
//wx.hideNavigationBarLoading()
}
}
})
6 years ago
// 把点击到的某一项设为当前index
this.setData({
curNav: id,
curIndex: index
})
6 years ago
}
6 years ago
})