|
实现了一些简单的页面效果,学习的人会喜欢的;
[mw_shl_code=html,true]var app = getApp()
Page({
data: {
dataList : []
},
initData : function(){
return [
{
id : 1,
title : '紧急任务',
themes :[{
id : 11,
selected : true,
interact : false,
partake : true,
complete :'Page() 函数用来注册一个页面。接受一个 object 参数,其指定页面的初始数据、生命周期函数、事件处理函数等。',
partakes :[
'../../images/1.jpg',
'../../images/2.jpg',
'../../images/3.jpg',
'../../images/4.png',
'../../images/5.jpg',
'../../images/0.jpg']
},{
id : 12,
selected : false,
interact : false,
partake : true,
complete :'在组件上使用wx:for控制属性绑定一个数组,即可使用数组中各项的数据重复渲染该组件。',
partakes :[
'../../images/1.jpg',
'../../images/2.jpg',
'../../images/3.jpg']
}]
},{
id : 2,
title : '延期任务',
themes :[{
id : 21,
selected : false,
interact : false,
partake : true,
complete :'App() 函数用来注册一个小程序。接受一个 object 参数,其指定小程序的生命周期函数等。',
partakes :[
'../../images/2.jpg',
'../../images/3.jpg',
'../../images/4.png',
'../../images/5.jpg',
'../../images/0.jpg']
}]
}
]
},
//事件处理函数
bindViewTap: function() {
wx.navigateTo({
url: '../logs/logs'
})
},
onLoad: function () {
var that = this
wx.showNavigationBarLoading()
that.setData({
dataList : that.initData()
})
wx.hideNavigationBarLoading()
},
onPullDownRefresh : function(){ //下拉刷新
var that = this
wx.showNavigationBarLoading()
that.setData({
dataList : that.initData()
})
wx.hideNavigationBarLoading()
wx.stopPullDownRefresh()
},
onReachBottom : function(){ //下拉底部分页
var that = this
wx.showNavigationBarLoading()
that.setData({
dataList : that.initData()
})
wx.stopPullDownRefresh()
wx.hideNavigationBarLoading()
},
onSelected : function(e){ //处理
wx.showNavigationBarLoading()
var that = this
var value = e.detail.value[0]
var themeId = e.target.dataset.id
var dataId = e.target.dataset.parentId
var selectItem = that.lgGetThemeItemById(dataId, themeId)
var dataItem = that.lgGetDataItemById(dataId)
selectItem.selected = !selectItem.selected
console.log(selectItem)
wx.hideNavigationBarLoading()
},
onThemeInfo : function(e){ //详情
var themeId = e.target.dataset.id
wx.navigateTo({
url: '../work-info/work-info?id='+themeId
})
},
lgGetDataList : function(){ //逻辑处理
var that = this
return that.data.dataList
},
lgGetDataItemById : function(id){
var that = this
var dataList = that.lgGetDataList()
var i = 0 , len = dataList.length
var retItem = null
for(; i < len; ++i){
var item = dataList
if(id == item.id){
retItem = item
break
}
}
return retItem
},
lgGetThemes : function(dataId){
var that = this
return that.lgGetDataItemById(dataId).themes
},
lgGetThemeItemById : function(dataId, themeId){
var that = this
var themes = that.lgGetThemes(dataId)
console.log(themes)
var i = 0, len = themes.length
var retItem = null
for(; i < len; ++i){
var item = themes
if(themeId == item.id){
retItem = item
break
}
}
return retItem
}
})[/mw_shl_code]
|
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
×
|