function showTodo(data){
var listData = [];
for (var i = 0; i < data.length; i++) {
//声明每一个系统数组
var list=[];
//声明一个变量用来判断是否读取
var read=1;
//console.log(JSON.stringify(data));
//data[i].systemTodo.read == "0" ? '<div>'+data[i].systemName+'<span data-id='+ data[i].systemTodo.todo_id +' class="news"></span></div>' : '<div>'+data[i].systemName+'</div>';
//声明每一个系统下内容数组
var arr=[];
//声明todo_id
var readId="";
list["header"] = '<div>'+data[i].systemName+'<span class="read"></span></div>';
// alert(data[i].systemTodo.length);
for(var j=0; j < data[i].systemTodo.length; j++){
if(data[i].systemTodo[j].read == "0"){
read=0;
readId+=data[i].systemTodo[j].todo_id+',';
}
var content=[];
content["title"] = '<div class="ub"><div class="ulev-1 ub-f1 sc-text" style="min-height:2em;">'+ data[i].systemTodo[j].title +'</div></div><div class="ulev-1 sc-text">'+ new Date().getFullYear()+'/'+new Date().getMonth()+1+'/'+new Date().getDate()+'</div>';
arr.push(content);
}
readId=readId.substring(0,readId.length-1);
if(read == 0){
list["header"] = '<div>'+data[i].systemName+'<span data-id='+ readId +' class="news"></span></div>';
}
list["content"] = arr;
listData.push(list);
}
var tv = appcan.treeview({
selector : "#List",
defaultOpen : 1//默认打开第几项,必须包含数据
});
tv.set(listData);
$(".treeview").on("click",function(){
var self=$(this);
if(self.find("*").hasClass('news')){
var todoId=self.find("*").find(".news").attr("data-id");
//修改未读为已读
appcan.ajax({
url : host + "/portalMobile/home/userTodoRead",
data : {
todoId : todoId
},
type : 'POST',
dataType : 'json',
success : function(data) {
console.log(data.status);
if(data.status == "success"){
self.find("*").find(".news").removeClass("news").addClass("read");
}
},
error : function(xhr, errorType, error, msg) {
//alert(msg);
}
})
}
});
}