$(function() {
// 详情
$('.blue').live('click', function() {
var id = $(this).attr('id');
detailConsultInfo(id);
});
// 加载列表数据
loadData();
});
/**
* 加载列表数据
*/
function loadData() {
var paramObj = _parserUrl(window.location.href);
var id = paramObj.did;
var url = 'detailById';
$.ajax({
type : 'post',
url : url,
data : {
id : id
},
cache : false,
dataType : 'json',
success : function(result) {
var data = result.queryResult.data;
console.log(data);
$.each(data, function(i,item) {
if(i==0){
$('#title').html(item.title);
$('#createDate').html(formatterTime(item.createDate,"yyyy-MM-dd"));
$('#content').html(item.content);
/*if(item.type==1){
$(".title h3").html("业务流程")
}else{
$(".title h3").html("经验分享")
}*/
}else if(i==1){
if(item!=null){
//如果标题长度大于30 取30位长度
var title = item.title;
if(title.length > 30){
title=title.substring(0,30)+'...';
}
$('#up').html(''+"上一篇:"+title+'');
}
}else{
if(item!=null){
//如果标题长度大于30 取30位长度
var title = item.title;
if(title.length > 30){
title=title.substring(0,30)+'...';
}
$('#next').html(''+"下一篇:"+title+'');
}
}
});
},
error : function() {
jAlert(message.defaults.queryError, message.defaults.tipTitleError);
}
});
}
/**
* 返回指定格式日期
* @param time 时间 长整型
* @param fmt 格式,如:yyyy-MM-dd HH:mm:ss
* @returns
*/
function formatterTime(time, fmt) {
var time = new Date(time);
var z = {
M: time.getMonth() + 1,
d: time.getDate(),
h: time.getHours(),
m: time.getMinutes(),
s: time.getSeconds()
};
fmt = fmt.replace(/(M+|d+|h+|m+|s+)/g, function(v) {
return ((v.length > 1 ? "0" : "") + eval('z.' + v.slice(-1))).slice(-2);
});
return fmt.replace(/(y+)/g, function(v) {
return time.getFullYear().toString().slice(-v.length);
});
}
/**
* 查看详情
* @param id id
*/
function detailConsultInfo(id) {
var helpType =$("#helpType").val();
if(helpType==1){
window.location.href = "queryWorkFlowDetail?id=-998&did=" + id;
}else{
window.location.href = "queryExperienceDetail?id=-998&did=" + id;
}
}