$(function () {
$("#zgh_search input[type='text']").focus(function () {
$(window).keydown(function (event) {
if(event.keyCode==13){
zghSearch()
}
})
});
$("#zgh_search button").click(function () {
zghSearch()
});
function zghSearch() {
var value = $("#zgh_search input[type='text']").val();
if(value != ''){
$("#zgh_search").attr('action','./qt/search.html?title='+ value);
$("#zgh_search").submit()
}else {
alert("请输入关键字");
event.preventDefault();
}
}
});
var vm = new Vue({
el: "#main",
data: function(){
return{
carouselPics: [],
xiongZhenWorks:[],
unionNews:[],
announcements:[],
specialColumns:[],
onlineReceptionRooms:[],
policiesAndRegulations:[],
lamorParks:[],
publications:[],
iscarousel:false,
iscom:false,
ispub:false,
tabIndex: 1
}
},
mounted: function () {
//这个是钩子函数
//如果cartView函数要执行,必须先执行钩子函数
//这个钩子函数完成了对cratView函数的调用
//应该注意的是,使用mounted 并不能保证钩子函数中的 this.$el 在 document 中。为此还应该引入 Vue.nextTick/vm.$nextTick
this.$nextTick(function () {
this.initData();
})
},
watch: {
iscarousel: function () {
this.$nextTick(function () {
//轮播图js
var sWidth = $("#carousel-focus").width();
var len = $("#carousel-focus ul li").length;
var index = 0;
var picTimer;
var btn = "
";
for(var i = 0; i < len; i++) {
btn += "";
}
btn += "
";
$("#carousel-focus").append(btn);
$("#carousel-focus .btnBg").css("opacity", 0.5);
$("#carousel-focus .btn span").css("opacity", 0.4).mouseenter(function() { //显示相对应的图片下标图片
index = $("#carousel-focus .btn span").index(this);
showPics(index);
}).eq(0).trigger("mouseenter");
$("#carousel-focus .preNext").css("opacity", 0.2).hover(function() {
$(this).stop(true, false).animate({
"opacity": "0.5"
}, 300)
}, function() {
$(this).stop(true, false).animate({
"opacity": "0.2"
}, 300)
});
$("#carousel-focus .pre").click(function() {
index -= 1;
if(index == -1) {
index = len - 1;
}
showPics(index)
});
$("#carousel-focus .next").click(function() {
index += 1;
if(index == len) {
index = 0;
}
showPics(index)
});
$("#carousel-focus ul").css("width", sWidth * (len));
$("#carousel-focus").hover(function() {
clearInterval(picTimer)
}, function() {
picTimer = setInterval(function() {
showPics(index);
index++;
if(index == len) {
index = 0;
}
}, 5000);
}).trigger("mouseleave");
function showPics(index) {
var nowLeft = -index * sWidth;
$("#carousel-focus ul").stop(true, false).animate({
"left": nowLeft
}, 300);
$("#carousel-focus .btn span").stop(true, false).animate({
"opacity": "0.4"
}, 300).eq(index).stop(true, false).animate({
"opacity": "1"
}, 300)
}
})
},
iscom: function() {
// console.log('iscom的数据发生变化'+this.iscom);
//在进行v-for的渲染 数据未更新完
this.$nextTick(function(){
/*现在数据已经渲染完毕*/
// 劳模园地
var lamorStyle = new ScrollPic();
lamorStyle.scrollContId = "lamor_scrollbox"; //内容容器ID
lamorStyle.arrLeftId = "lamor_arrLeft"; //左箭头ID
lamorStyle.arrRightId = "lamor_arrRight"; //右箭头ID
lamorStyle.frameWidth = 516; //显示框宽度
lamorStyle.pageWidth = 516; //翻页宽度
lamorStyle.speed = 8; //移动速度(单位毫秒,越小越快)
lamorStyle.space = 8; //每次移动像素(单位px,越大越快)
lamorStyle.autoPlay = false; //自动播放
lamorStyle.autoPlayTime = 3; //自动播放间隔时间(秒)
lamorStyle.initialize(); //初始化
})
},
ispub: function() {
// console.log('ispub的数据发生变化'+this.ispub);
//在进行v-for的渲染 数据未更新完
this.$nextTick(function(){
/*现在数据已经渲染完毕*/
// 五一风刊物
var publicationStyle = new ScrollPic();
publicationStyle.scrollContId = "publication_scrollbox"; //内容容器ID
publicationStyle.arrLeftId = "publication_arrLeft"; //左箭头ID
publicationStyle.arrRightId = "publication_arrRight"; //右箭头ID
publicationStyle.frameWidth = 329; //显示框宽度
publicationStyle.pageWidth = 329; //翻页宽度
publicationStyle.speed = 8; //移动速度(单位毫秒,越小越快)
publicationStyle.space = 8; //每次移动像素(单位px,越大越快)
publicationStyle.autoPlay = false; //自动播放
publicationStyle.autoPlayTime = 3; //自动播放间隔时间(秒)
publicationStyle.initialize(); //初始化
})
}
},
methods: {
initData: function () {
//轮播图
var carousel = {
page: 1 ,
limit: 4
};
$.ajax({
type: 'post',
url: '../jk/jgsubject/articlelist',
data: carousel,
sync:true,
dataType: 'json',
success: function (r) {
if (r.code === 0) {
r.page.list.forEach(function (item, index, array) {
var obj = new Object();
obj = item;
vm.carouselPics.push(obj);
});
vm.iscarousel = true;
}
},
error: function () {
}
});
// 雄镇工事
var p = {
id: 10202,
page: 1 ,
limit:10
};
$.ajax({
type: 'post',
url: '../jk/jgsubject/list',
data: p,
sync:true,
dataType: 'json',
success: function (r) {
if (r.code === 0) {
r.page.list.forEach(function (item, index, array) {
var obj = new Object();
obj.id = item.id;
obj.title = item.title;
obj.menuId = item.menuId;
obj.time = item.pubDate.substring(0,10);
vm.xiongZhenWorks.push(obj);
});
}
},
error: function () {
}
});
// 工会要闻
var news = {
id: 10201,
page: 1 ,
limit:10
};
$.ajax({
type: 'post',
url: '../jk/jgsubject/list',
data: news,
sync:true,
dataType: 'json',
success: function (r) {
if (r.code === 0) {
r.page.list.forEach(function (item, index, array) {
var obj = new Object();
obj.id = item.id;
obj.title = item.title;
obj.menuId = item.menuId;
obj.time = item.pubDate.substring(0,10);
vm.unionNews.push(obj);
});
}
},
error: function () {
}
});
// 通知公告
var params = {
id: 30201,
page: 1 ,
limit: 5
};
$.ajax({
type: 'post',
url: '../jk/jgsubject/list',
data: params,
sync:true,
dataType: 'json',
success: function (r) {
if (r.code === 0) {
r.page.list.forEach(function (item, index, array) {
var obj = new Object();
obj.id = item.id;
obj.title = item.title;
obj.menuId = item.menuId;
obj.time = item.pubDate.substring(0,10);
vm.announcements.push(obj);
});
}
},
error: function () {
}
});
//专题专栏
var special = {
id: 30501,
page: 1 ,
limit: 2
};
$.ajax({
type: 'post',
url: '../jk/jgsubject/list',
data: special,
sync:true,
dataType: 'json',
success: function (r) {
if (r.code === 0) {
r.page.list.forEach(function (item, index, array) {
var obj = new Object();
obj.id = item.id;
obj.title = item.title;
obj.atta = item.atta;
obj.time = item.pubDate.substring(0,10);
vm.specialColumns.push(obj);
});
}
},
error: function () {
}
});
// 网上接待室
var online = {
page: 1 ,
limit: 10,
sidx:''
};
$.ajax({
type: 'post',
url: '../zhgh/reception/list',
data: online,
sync:true,
dataType: 'json',
success: function (r) {
if (r.code === 0) {
vm.allPage = r.page.totalPage;
r.page.list.forEach(function (item, index, array) {
//咨询列表
var obj = new Object();
obj.id = item.id;
obj.title = item.title;
obj.create_time = item.askTime.substring(0,10);
obj.type = item.typ;
obj.resolve_time = item.ansTime;
if(obj.resolve_time == "" || obj.resolve_time == null){
obj.status = "未处理"
}else{
obj.resolve_time = item.ansTime.substring(0,10);
obj.status = "已处理"
}
vm.onlineReceptionRooms.push(obj);
})
}
},
error: function () {
}
});
// 政策法规
var policies = {
id: 30401,
page: 1 ,
limit: 6
};
$.ajax({
type: 'post',
url: '../jk/jgsubject/list',
data: policies,
sync:true,
dataType: 'json',
success: function (r) {
if (r.code === 0) {
r.page.list.forEach(function (item, index, array) {
var obj = new Object();
obj.id = item.id;
obj.title = item.title;
obj.menuId = item.menuId;
obj.time = item.pubDate.substring(0,10);
vm.policiesAndRegulations.push(obj);
});
}
},
error: function () {
}
});
// 劳模园地
var lamor = {
id: 10503,
page: 1 ,
limit: 9,
sidx: 'atta',
order: 'desc'
};
$.ajax({
type: 'post',
url: '../jk/jgsubject/list',
data: lamor,
sync:true,
dataType: 'json',
success: function (r) {
if (r.code === 0) {
r.page.list.forEach(function (item, index, array) {
var obj = new Object();
obj.id = item.id;
obj.title = item.title;
obj.remark = item.remark;
obj.atta = item.atta;
vm.lamorParks.push(obj);
});
vm.iscom = true ;
}
},
error: function () {
}
});
// 五一风刊物
var publication = {
id: 20401,
page: 1 ,
limit: 6
};
$.ajax({
type: 'post',
url: '../jk/jgsubject/list',
data: publication,
sync:true,
dataType: 'json',
success: function (r) {
if (r.code === 0) {
r.page.list.forEach(function (item, index, array) {
var obj = new Object();
obj.id = item.id;
obj.title = item.title;
obj.remark = item.remark;
obj.atta = item.atta;
vm.publications.push(obj);
});
vm.ispub = true ;
}
},
error: function () {
}
});
},
// 改变tab
changeTab: function(index){
vm.tabIndex = index;
}
}
});
// 服务中心js
var timesStyle = new ScrollPic();
timesStyle.scrollContId = "service_scrollbox"; //内容容器ID
timesStyle.arrLeftId = "service_arrLeft"; //左箭头ID
timesStyle.arrRightId = "service_arrRight"; //右箭头ID
timesStyle.dotListId = "service_Index"; //下标
timesStyle.dotClassName = "IndexDot";
timesStyle.dotOnClassName = "OnIndexDot";
timesStyle.frameWidth = 910; //显示框宽度
timesStyle.pageWidth = 910; //翻页宽度
timesStyle.speed = 8; //移动速度(单位毫秒,越小越快)
timesStyle.space = 8; //每次移动像素(单位px,越大越快)
timesStyle.autoPlay = true; //自动播放
timesStyle.autoPlayTime = 3; //自动播放间隔时间(秒)
timesStyle.initialize(); //初始化