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.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
// pages/fenlei/fenlei.js
Page ( {
data : {
'book' : [ ] ,
cateItems : [
{
cate _id : 1 ,
cate _name : "玄幻" ,
ishaveChild : true ,
// 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"
// }
// ]
} ,
{
cate _id : 2 ,
cate _name : "魔幻" ,
ishaveChild : true ,
// 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"
// }
// ]
} ,
{
cate _id : 3 ,
cate _name : "奇幻" ,
ishaveChild : true ,
// 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"
// }
// ]
} ,
{
cate _id : 4 ,
cate _name : "都市" ,
ishaveChild : true ,
// children: [
// {
// child_id: 1,
// name: 'Java Web',
// image: "/pages/index/image/java.jpg"
// },
// {
// child_id: 2,
// name: '计算机网络',
// image:"/pages/index/image/jsswl.jpg"
// },
// ]
}
] ,
curNav : 1 ,
curIndex : 0
} ,
onload : function ( ) {
var thats = this
wx . request ( {
url : "http://45.76.158.31:8080/web/GetFrontInfo.do? type=" + 1 ,
header : {
"content-type" : "json"
} ,
success : function ( res ) {
console . log ( res . data )
if ( res . statusCode == 200 ) {
thats . setData ( {
book : res . data ,
} )
//wx.hideNavigationBarLoading()
}
}
} )
} ,
//事件处理函数
switchRightTab : function ( e ) {
// 获取item项的id, 和数组的下标值
let id = e . target . dataset . id ,
index = parseInt ( e . target . dataset . index ) ;
console . log ( id )
var thats = this
wx . request ( {
url : "http://45.76.158.31:8080/web/GetFrontInfo.do? type=" + 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()
}
}
} )
// 把点击到的某一项, 设为当前index
this . setData ( {
curNav : id ,
curIndex : index
} )
}
} )