//查询售电文章是否过期
$.getJSON('http://www.sgcio.com/index.php?m=content&c=index&a=get_sell&catid=4&id=87396&modelid=1&'+Math.random()+'&callback=?', function(data){
//alert(data.fettle);
if(data.timearr==2){
$('#fettle').html('已失效');
}else {
if(data.fettle==1){
$('#fettle').html('热销中');
}else if(data.fettle==2){
$('#fettle').html('已售完');
}else if(data.fettle==3){
$('#fettle').html('已失效');
}else{
$('#fettle').html('');
}
}
})
//查询购电文章是否过期
$.getJSON('http://www.sgcio.com/index.php?m=content&c=index&a=get_buy&catid=4&id=87396&modelid=1&'+Math.random()+'&callback=?', function(data){
//alert(data.fettle);
if(data.timearr==2){
$('#fettle_buy').html('已失效');
}else {
if(data.fettle==1){
$('#fettle_buy').html('求购中');
}else if(data.fettle==2){
$('#fettle_buy').html('已购买');
}else if(data.fettle==3){
$('#fettle_buy').html('已失效');
}else{
$('#fettle_buy').html('');
}
}
})
//收藏
function digg() {
$.getJSON('http://www.sgcio.com/index.php?m=digg&c=index&a=post&id=4-87396-1&typeid=1&'+Math.random()+'&callback=?', function(data){
if(data.status==1) {
if(data.isup==1){
layer.msg('收藏成功');
$('.btn_digg').addClass('cur');
$('.btn_digg').attr('data-islike','true');
$('.article-like .text').html('已收藏');
}else{
layer.msg('取消收藏');
$('.btn_digg').removeClass('cur');
$('.btn_digg').attr('data-islike','false');
$('.article-like .text').html('我要收藏');
}
}else {
//alert(data.data);
layer.msg(data.data,{
time: 2000
}, function(){
window.location.href="http://www.sgcio.com/index.php?m=member&c=index&a=login&forward=http%3A%2F%2Fwww.sgcio.com%2Feduinfo%2Fhd%2F87396.html&siteid=1";
});
}
})
}
$.getJSON('http://www.sgcio.com/index.php?m=digg&c=index&a=get&id=4-87396-1&typeid=1&'+Math.random()+'&callback=?', function(data){
var userid = '';
if(userid){
if(data.data!=0){
$('.btn_digg').addClass('cur');
$('.btn_digg').attr('data-islike','true');
$('.article-like .text').html('已收藏');
}else {
$('.btn_digg').removeClass('cur');
$('.btn_digg').attr('data-islike','false');
$('.article-like .text').html('我要收藏');
}
}else{
$('.btn_digg').removeClass('cur');
$('.btn_digg').attr('data-islike','false');
$('.article-like .text').html('我要收藏');
}
})
//赞
function digg_up() {
$.getJSON('http://www.sgcio.com/index.php?m=digg&c=index&a=post&id=4-87396-1&typeid=2&'+Math.random()+'&callback=?', function(data){
if(data.status==1) {
if(data.isup==1){
layer.msg('赞一个');
$('.btn_digg_up').addClass('cur');
$('.btn_digg_up').attr('data-isup','true');
$('.article-up .text').children('em').html(data.data);
$('.article-up .text').children('span').html('个赞');
}else{
layer.msg('取消赞');
$('.btn_digg_up').removeClass('cur');
$('.btn_digg_up').attr('data-isup','false');
$('.article-up .text').children('em').html(data.data);
$('.article-up .text').children('span').html('个赞');
}
}else {
//alert(data.data);
layer.msg(data.data,{
time: 2000
}, function(){
window.location.href="http://www.sgcio.com/index.php?m=member&c=index&a=login&forward=http%3A%2F%2Fwww.sgcio.com%2Feduinfo%2Fhd%2F87396.html&siteid=1";
});
}
})
}
$.getJSON('http://www.sgcio.com/index.php?m=digg&c=index&a=get&id=4-87396-1&typeid=2&'+Math.random()+'&callback=?', function(data){
var userid = '';
if(userid){
if(data.data!=0){
$('.btn_digg_up').addClass('cur');
$('.btn_digg_up').attr('data-isup','true');
$('.article-up .text').children('em').html(data.data);
$('.article-up .text').children('span').html('个赞');
}else {
$('.btn_digg_up').removeClass('cur');
$('.btn_digg_up').attr('data-isup','false');
$('.article-up .text').children('em').html('');
$('.article-up .text').children('span').html('点个赞吧');
}
}else {
$('.btn_digg_up').removeClass('cur');
$('.btn_digg_up').attr('data-isup','false');
if(data.data==0){
$('.article-up .text').children('em').html('');
$('.article-up .text').children('span').html('点个赞吧');
}else{
$('.article-up .text').children('em').html(data.data);
$('.article-up .text').children('span').html('个赞');
}
}
})
//踩
function digg_down() {
$.getJSON('http://www.sgcio.com/index.php?m=digg&c=index&a=post&id=4-87396-1&typeid=3&'+Math.random()+'&callback=?', function(data){
if(data.status==1) {
if(data.isup==1){
layer.msg('踩了一下');
$('.btn_digg_down').addClass('cur');
$('.btn_digg_down').attr('data-isdown','true');
$('.article-down .text').children('em').html(data.data);
$('.article-down .text').children('span').html('被踩');
$('.article-down .text').children('font').html('下');
}else{
layer.msg('取消踩');
$('.btn_digg_down').removeClass('cur');
$('.btn_digg_down').attr('data-isdown','false');
$('.article-down .text').children('em').html(data.data);
$('.article-down .text').children('span').html('被踩');
$('.article-down .text').children('font').html('下');
}
}else {
//alert(data.data);
layer.msg(data.data,{
time: 2000
}, function(){
window.location.href="http://www.sgcio.com/index.php?m=member&c=index&a=login&forward=http%3A%2F%2Fwww.sgcio.com%2Feduinfo%2Fhd%2F87396.html&siteid=1";
});
}
})
}
$.getJSON('http://www.sgcio.com/index.php?m=digg&c=index&a=get&id=4-87396-1&typeid=3&'+Math.random()+'&callback=?', function(data){
var userid = '';
if(userid){
if(data.data!=0){
$('.btn_digg_down').addClass('cur');
$('.btn_digg_down').attr('data-isdown','true');
$('.article-down .text').children('em').html(data.data);
$('.article-down .text').children('span').html('被踩');
$('.article-down .text').children('font').html('下');
}else {
$('.btn_digg_down').removeClass('cur');
$('.btn_digg_down').attr('data-isdown','false');
$('.article-down .text').children('em').html('');
$('.article-down .text').children('font').html('');
$('.article-down .text').children('span').html('踩一下');
}
}else {
$('.btn_digg_down').removeClass('cur');
$('.btn_digg_down').attr('data-isdown','false');
if(data.data==0){
$('.article-down .text').children('em').html('');
$('.article-down .text').children('font').html('');
$('.article-down .text').children('span').html('踩一下');
}else{
$('.article-down .text').children('em').html(data.data);
$('.article-down .text').children('span').html('被踩');
$('.article-down .text').children('font').html('下');
}
}
})
//分享
$('.article-share').hover(function(){
$('#share-popover').show();
},function(){
$('#share-popover').hide();
})
$(document).on("click", "#btn_loading", function() {
var cookiepage = getcookie('loadpage') ? getcookie('loadpage') : '0';
var loadednum = $('#clist').children('li').length;
var newpage = Math.ceil(loadednum/10) + 1;
var thepage = $('#clist').attr('data-page') ? $('#clist').attr('data-page') : newpage;
if(parseInt(cookiepage) < parseInt(thepage)){
ajaxRead(thepage);
setcookie('loadpage',thepage,'1');
}else{
ajaxRead(newpage);
}
})
//页面加载完成 默认显示
$(function(){
var cookiepage = getcookie('loadpage') ? getcookie('loadpage') : '0';
var loadednum = $('#clist').children('li').length;
var newpage = Math.ceil(loadednum/10) + 1;
var thepage = $('#clist').attr('data-page') ? $('#clist').attr('data-page') : newpage;
if(parseInt(cookiepage) < parseInt(thepage)){
ajaxRead(thepage);
setcookie('loadpage',thepage,'1');
}else{
ajaxRead(newpage);
}
});
setcookie('loadpage','0','1');
function show(){
if($(window).scrollTop()+$(window).height()>=$(document).height()){
var cookiepage = getcookie('loadpage') ? getcookie('loadpage') : '0';
var loadednum = $('#clist').children('li').length;
var newpage = Math.ceil(loadednum/10) + 1;
var thepage = $('#clist').attr('data-page') ? $('#clist').attr('data-page') : newpage;
if(parseInt(cookiepage) < parseInt(thepage)){
ajaxRead(thepage);
setcookie('loadpage',thepage,'1');
}else{
}
}
}
function ajaxRead(page){
var html="";
var loadednum = $('#clist').children('li').length;
var newpage = Math.ceil(loadednum/10) + 1;
var thepage = $('#clist').attr('data-page') ? $('#clist').attr('data-page') : newpage;
var page = arguments[0] ? arguments[0] : thepage;
var thenum = $('#clist').attr('data-num') ? $('#clist').attr('data-num') : '0';
thenum = parseInt(thenum);
page = parseInt(page);
$.ajax({
type:'get',
dataType:'json',
url:'http://www.sgcio.com/index.php?m=comment&c=index&a=init&commentid=content_4-87396-1&type=1&page='+page,
beforeSend:function(){},
success:function(data){
var theload = $('#clist').attr('data-load') ? $('#clist').attr('data-load') : 'true';
//alert(obj2string(data));
//$('.section-hotchannel').next('.section-show').html(obj2string(data)).css('height','200px').css('overfllow','hidden');
if(obj2string(data) != '[]'){
$('#clist').attr('data-load','ture');
$.each(data,function(i,item){
html+='
';
html+='';
html+='';
html+='
';
html+='
'+item.content+'
';
html+='
';
html+='
'+date('Y-m-d H:i:s',item.creat_at)+'';
html+='
';
html+='';
html+='';
html+='
';
html+='
';
html+='
';
html+='
';
html+='';
html+='';
thenum = thenum +1;
$('#clist').attr('data-num',thenum);
});
page = page + 1;
//alert(page);
$('#clist').attr('data-page',page);
$('#clist').append($(html));
}else{
$('#clist').attr('data-load','false');
$('#btn_loading').html('暂无更多的数据了');
return false;
}
},
complete:function(){
if(theload == 'true'){
}else{
$('#btn_loading').html('暂无更多的数据了');
}
}
});
}
//支持
function support(id, commentid) {
$.getJSON('http://www.sgcio.com/index.php?m=comment&c=index&a=support&format=jsonp&commentid='+commentid+'&id='+id+'&callback=?', function(data){
if(data.status == 1) {
layer.msg('顶一下');
$('#support_'+id).html(parseInt($('#support_'+id).html())+1);
$('#cdigg_'+commentid+'_'+id).addClass('digged');
} else {
layer.msg(data.msg);
}
});
}
//回复
function reply(id,commentid) {
var str = '';
$('.reply_div').addClass('hide').removeClass('active').hide();
$('#reply_'+id).removeClass('hide').addClass('active').html(str).toggle();
}
$('.reply_div.active .cinput-reply').change(function() {
$('.reply_div.active .csubmit-reply').addClass('active');
});
//留言条数
$.getJSON('http://www.sgcio.com/index.php?m=comment&c=index&a=get&commentid=content_4-87396-1&siteid=1&'+Math.random()+'&callback=?', function(data){
if(data.status==1){
if(data.data==0){
$('.ctotal').html('赶紧留言抢沙发吧~');
$('#btn_loading').hide();
if ($('#clist').html().length < 1){
ajaxRead(1);
}
}else{
$('#ctotalnum').html(data.data);
$('.ctotalnum').html(data.data);
}
}else {
$('.ctotal').html('赶紧留言抢沙发吧~');
$('#btn_loading').hide();
}
})
//检查状态
$.getJSON('http://www.sgcio.com/index.php?m=member&c=index&a=get&typeid=1&'+Math.random()+'&callback=?', function(data){
if(data.status==1){
$('#cavatar').attr('data-id',data.userid);
$('#cavatar').css('background-image','url('+data.avatar+')');
$('.btn_login').remove();
if ($('#clist').html().length < 1){
ajaxRead(1);
}
}else {
$('#cavatar').attr('data-id','');
$('#cavatar').css('background-image','');
//$('.ceditzone').hide();
}
})
$(document).on("click", ".csubmit-reply", function() {
if($('#cavatar').attr('data-id') == ''){
layer.open({
type: 2,
title: false,
maxmin: false,
shadeClose: true,
shade: 0.5,
//closeBtn: false,
area: ['520px', '380px'],
fix: false, //不固定
scrollbar: false,
content: ['http://www.sgcio.com/index.php?m=member&c=index&a=login&type=1&forward=http%3A%2F%2Fwww.sgcio.com%2Feduinfo%2Fhd%2F87396.html&siteid=1', 'no']
});
}else{
var id = $(this).attr('data-id');
var mytextarea = $('#cinput-'+id).val();
var myarr = mytextarea.split('\n');
//alert(myarr[0]);
if(mytextarea != ''){
var ctitle = $('.ctitle').val();
var curl = $('.curl').val();
var cinput = encodeURIComponent($('#cinput-'+id).val());
$.getJSON('http://www.sgcio.com/index.php?m=comment&c=index&a=post_ajax&format=jsonp&commentid=content_4-87396-1&id='+id+'&content='+cinput+'&callback=?', function(data){
if(data.status == 1) {
layer.msg('评论提交中...', {time: 500},function(){
//window.location.reload();
if(data.msg==99){
layer.msg('评论已提交,等待审核中', {time: 500},function(){});
$('.csubmit').removeClass('active');
$('.cinput').val('');
}else{
var html="";
var item = data.msg;
html+='';
html+='';
html+='';
html+='
';
html+='
'+item.content+'
';
html+='
';
html+='
'+date('Y-m-d H:i:s',item.creat_at)+'';
html+='
';
html+='';
html+='';
html+='
';
html+='
';
html+='
';
html+='
';
html+='';
html+='';
$('#clist').prepend($(html));
$('.csubmit').removeClass('active');
$('.cinput').val('');
$('.reply_div').removeClass('focus').removeClass('active').addClass('hide');
$('body,html').stop().animate({scrollTop: ($('#clist').offset().top-50)}, 300);
layer.msg('感谢您的评论', {time: 500},function(){});
}
});
} else {
layer.msg(data.msg);
}
});
}else{
layer.msg('请输入评论内容...', {time: 500},function(){
$('#cinput-'+id).focus();
});
}
}
})
//举报
$(document).on("click", ".creport", function() {
var commentid = $(this).attr('commentid');
var cid = $(this).attr('id');
layer.open({
type: 2,
title: '举报此评论',
closeBtn: 1,
area: ['500px', '350px'],
skin: 'layui-layer-nobg', //没有背景色
shadeClose: true,
content: ['http://www.sgcio.com/index.php?m=formguide&c=index&a=show&formid=47&siteid=1&&commentid='+commentid+'&id='+cid+'&pop=1', 'no']
});
})
//评论留言
$('#cinput').bind('input propertychange', function() {
$('#csubmit').addClass('active');
});
$('.btn_login,#cinput').bind('click', function() {
if($('#cinput').val() == '' && $('#cavatar').attr('data-id') == ''){
layer.open({
type: 2,
title: false,
maxmin: false,
shadeClose: true,
shade: 0.5,
//closeBtn: false,
area: ['520px', '380px'],
fix: false, //不固定
scrollbar: false,
content: ['http://www.sgcio.com/index.php?m=member&c=index&a=login&type=1&forward=http%3A%2F%2Fwww.sgcio.com%2Feduinfo%2Fhd%2F87396.html&siteid=1', 'no']
});
}
});
$(document).on("click", ".creply", function() {
if($('#cavatar').attr('data-id') == ''){
layer.open({
type: 2,
title: false,
maxmin: false,
shadeClose: true,
shade: 0.5,
//closeBtn: false,
area: ['520px', '380px'],
fix: false, //不固定
scrollbar: false,
content: ['http://www.sgcio.com/index.php?m=member&c=index&a=login&type=1&forward=http%3A%2F%2Fwww.sgcio.com%2Feduinfo%2Fhd%2F87396.html&siteid=1', 'no']
});
}
});
$(document).on("click", "#csubmit", function() {
if($('#cavatar').attr('data-id') == ''){
layer.open({
type: 2,
title: false,
maxmin: false,
shadeClose: true,
shade: 0.5,
//closeBtn: false,
area: ['520px', '380px'],
fix: false, //不固定
scrollbar: false,
content: ['http://www.sgcio.com/index.php?m=member&c=index&a=login&type=1&forward=http%3A%2F%2Fwww.sgcio.com%2Feduinfo%2Fhd%2F87396.html&siteid=1', 'no']
});
}else{
var mytextarea = $('#cinput').val();
var myarr = mytextarea.split('\n');
//alert(myarr[0]);
if($('#csubmit').hasClass('active') && myarr[0] != ''){
var ctitle = $('.ctitle').val();
var curl = $('.curl').val();
var cinput = encodeURIComponent($('#cinput').val());
$.getJSON('http://www.sgcio.com/index.php?m=comment&c=index&a=post_ajax&format=jsonp&commentid=content_4-87396-1&title='+ctitle+'&url='+curl+'&content='+cinput+'&callback=?', function(data){
if(data.status == 1) {
layer.msg('评论提交中...', {time: 500},function(){
//window.location.reload();
if(data.msg==99){
layer.msg('评论已提交,等待审核中', {time: 500},function(){})
$('.csubmit').removeClass('active');
$('.cinput').val('');;
}else{
var html="";
var item = data.msg;
html+='';
html+='';
html+='';
html+='
';
html+='
'+item.content+'
';
html+='
';
html+='
'+date('Y-m-d H:i:s',item.creat_at)+'';
html+='
';
html+='';
html+='';
html+='
';
html+='
';
html+='
';
html+='
';
html+='';
html+='';
$('#clist').prepend($(html));
$('.csubmit').removeClass('active');
$('.cinput').val('');
layer.msg('感谢您的评论', {time: 500},function(){});
}
});
} else {
layer.msg(data.msg);
}
});
}else{
//layer.msg('请输入评论内容...');
layer.msg('请输入评论内容...', {time: 500},function(){
$('#cinput').focus();
});
}
}
})
$(document).on("click", ".snszone i", function() {
if($(this).hasClass('checked')){
$(this).removeClass('checked');
}else{
$(this).addClass('checked');
}
})
//nav
$(function(){
$(".cat-4").addClass("cur");
$(".cat-95").addClass("cur");
$(".cat-0").addClass("cur");
});
//search
//
$(document).on("click", ".btn-search", function() {
if($('#q').val() == ''){
var typeid = $('#typeid').attr('data');
if(typeid!=''){
$('#typeid-'+typeid).addClass('on');
}else{
$('#typeid-0').addClass('on');
}
layer.msg('请输入关键词');
$('#q').focus();
return false;
}else{
var keyword = $('#q').val();
var typeid = $('#typeid').attr('data'); if(typeid && typeid != '0'){
window.location.href = 'http://www.sgcio.com/'+typeid+'/search/'+encodeURIComponent(keyword);
}else{
window.location.href = 'http://www.sgcio.com/search/'+encodeURIComponent(keyword);
}
}
})
if($.isFunction(keyDownSearch)){
}else{
document.onkeydown=keyDownSearch;
function keyDownSearch(e) {
var theEvent = e || window.event;
var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
if (code == 13 && $('#q').val() != '') {
if($('#q').val() == ''){
layer.msg('请输入关键词');
$('#q').focus();
return false;
}else{
var keyword = $('#q').val();
var typeid = $('#typeid').attr('data'); if(typeid && typeid != '0'){
window.location.href = 'http://www.sgcio.com/'+typeid+'/search/'+encodeURIComponent(keyword);
}else{
window.location.href = 'http://www.sgcio.com/search/'+encodeURIComponent(keyword);
}
}
return false;
}
return true;
}
}
//if (document.location.host != "www.sgcio.com") {
//location.href = location.href.replace(document.location.host,'www.sgcio.com');
//}
//feedback
function suggest(e) {
var userid = '';
layer.open({
type: 2,
title: '建议反馈',
closeBtn: 1,
area: ['500px', '350px'],
skin: 'layui-layer-nobg', //没有背景色
shadeClose: true,
content: ['http://www.sgcio.com/index.php?m=formguide&c=index&a=show&formid=46&siteid=1&&userid='+userid+'&url='+encodeURIComponent(location.href)+'&pop=1', 'no']
});
}