/*! * 版本:myui copyright © 2019 * 作者:qq726662013版权所有 * 官网:https://www.mytheme.cn */ var myui = { 'comment': { 'init':function(){ $('body').on('click', '.my_comment_submit', function(e){ if($(this).parent().parent().parent().find(".comment_data").val() == ''){ layer.msg("请输入评论内容"); return false; } myui.comment.submit(); }); $('body').on('click', '.my_comment_report', function(e){ var $that = $(this); if($(this).attr("data-id")){ mytheme.ajax(maccms.path + '/index.php/comment/report.html?id='+$that.attr("data-id"),'get','json','',function(r){ $that.addclass('disabled'); layer.msg(r.msg); }); } }); $('body').on('click', '.my_comment_reply', function(e){ var $that = $(this); if($that.attr("data-id")){ var str = $that.html(); $('.comment_reply_form').remove(); if (str == '取消回复') { $that.html('回复'); return false; } if (str == '回复') { $('.my_comment_reply').html('回复'); } var html = $('.comment_form').prop("outerhtml"); var oo = $(html); oo.addclass('comment_reply_form'); oo.find('input[name="comment_pid"]').val( $that.attr("data-id") ); $that.parent().after(oo); $that.html('取消回复'); } }); $('body').on('click', '.my_comment_report', function(e){ var $that = $(this); if($(this).attr("data-id")){ mytheme.ajax(maccms.path + '/index.php/comment/report.html?id='+$that.attr("data-id"),'get','json','',function(r){ $that.addclass('disabled'); layer.msg(r.msg); }); } }); }, 'show':function($page){ mytheme.ajax(maccms.path + '/index.php/comment/ajax.html?rid='+$('.myui_comment').attr('data-id')+'&mid='+ $('.myui_comment').attr('data-mid') +'&page='+$page,'get','json','',function(r){ $(".myui_comment").html(r); },function(){ $(".myui_comment").html('

评论加载失败,点击我刷新...

'); }); }, 'submit':function(){ mytheme.ajax(maccms.path + '/index.php/comment/savedata','post','json',$(".comment_form").serialize() + '&comment_mid='+ $('.myui_comment').attr('data-mid') + '&comment_rid=' + $('.myui_comment').attr('data-id'),function(r){ if(r.code==1){ layer.msg(r.msg,{anim:5},function(){ myui.comment.show(1); }); } else { if(mac.gbook.verify==1){ $('#verify_img').click(); } layer.msg(r.msg); } }); } }, 'gbook': { 'init':function(){ $('body').on('click', '.gbook_submit', function(e){ if($(".gbook_data").val() == ''){ layer.msg("请输入留言内容"); return false; } myui.gbook.submit(); }); }, 'submit':function(){ mytheme.ajax(maccms.path + '/index.php/gbook/savedata','post','json',$("#myform").serialize(),function(r){ if(r.code==1){ layer.msg(r.msg,{anim:5},function(){ location.reload(); }); } else { if(mac.gbook.verify==1){ $('#verify_img').click(); } layer.msg(r.msg); } }); } }, 'score':function(){ var hadpingfen = 0; $("ul.rating li").each(function(i) { var $title = $(this).attr("title"); var $lis = $("ul.rating li"); var num = $(this).index(); var n = num + 1; $(this).click(function () { if (hadpingfen > 0) { layer.msg('已经评分,请务重复评分'); } else { $lis.removeclass("active"); $("ul.rating li:lt(" + n + ")").find(".fa").addclass("fa-star").removeclass("fa-star-o"); $("#ratewords").html($title); $.getjson(maccms.path+'/index.php/ajax/score?mid='+$('#rating').attr('data-mid')+'&id='+$('#rating').attr('data-id')+'&score='+($(this).attr('val')*2), function (r) { if (parseint(r.code) == 1) { layer.msg(r.msg); hadpingfen = 1; } else { hadpingfen = 1; layer.msg(r.msg); } }); } } ).hover(function () { this.mytitle = this.title; this.title = ""; $(this).nextall().find(".fa").addclass("fa-star-o").removeclass("fa-star"); $(this).prevall().find(".fa").addclass("fa-star").removeclass("fa-star-o"); $(this).find(".fa").addclass("fa-star").removeclass("fa-star-o"); $("#ratewords").html($title); }, function () { this.title = this.mytitle; $("ul.rating li:lt(" + n + ")").removeclass("hover"); }); }); }, 'autocomplete': function() { var searchwidth= $('#search').width(); try { $('.search_wd').autocomplete(maccms.path + '/index.php/ajax/suggest?mid=1', { resultsclass: "autocomplete-suggestions", width: searchwidth, scrollheight: 410, minchars: 1, matchsubset: 0, cachelength: 10, multiple: false, matchcontains: true, autofill: false, datatype: "json", parse: function (r) { if (r.code == 1) { $(".head-dropdown").hide(); var parsed = []; $.each(r['list'], function (index, row) { row.url = r.url; parsed[index] = { data: row }; }); return parsed; } else { return {data: ''}; } }, formatitem: function (row, i, max) { return row.name; }, formatresult: function (row, i, max) { return row.text; } }).result(function (event, data, formatted) { $(this).val(data.name); location.href = data.url.replace('mac_wd', encodeuricomponent(data.name)); }); } catch(e){} }, 'favorite': function() { if($('.favorite').length>0){ $('body').on('click', 'a.favorite', function(e){ var $that = $(this); if($that.attr("data-id")){ $.ajax({ url: maccms.path+'/index.php/user/ajax_ulog/?ac=set&mid='+$that.attr("data-mid")+'&id='+$that.attr("data-id")+'&type='+$that.attr("data-type"), cache: false, datatype: 'json', success: function($r){ layer.msg($r.msg); } }); } }); } }, 'user': { 'buypopedom':function(o){ var $that = $(o); if($that.attr("data-id")){ if (confirm('您确认购买此条数据访问权限吗?')) { mytheme.ajax(maccms.path + '/index.php/user/ajax_buy_popedom.html?id=' + $that.attr("data-id") + '&mid=' + $that.attr("data-mid") + '&sid=' + $that.attr("data-sid") + '&nid=' + $that.attr("data-nid") + '&type=' + $that.attr("data-type"),'get','json','',function(r){ $that.addclass('disabled'); layer.msg($r.msg); if (r.code == 1) { top.location.reload(); } $that.removeclass('disabled'); }); } } }, 'login':function(){ mytheme.layer.div('.ajax_login'); $('body').on('click', '.login_form_submit', function(e){ $(this).unbind('click'); mytheme.ajax(maccms.path + '/index.php/user/login','post','json',$('.mac_login_form').serialize(),function(r){ layer.msg(r.msg); if(r.code == 1){ layer.msg(r.msg,{anim:5},function(){ location.reload(); }); } }); }); } }, 'other': { 'top': function(high){ $(window).scroll(function(){ if($(window).scrolltop()>10){ $("#header-top").removeclass("color"); }else if($(window).scrolltop()<110){ $("#header-top").addclass("color"); } }); }, 'topbg': function(high){ $(".myui-topbg").css({"height":high}); $("#header-top").addclass("color"); if(myui.topfixed==1){ myui.other.top(); } } } }; $(function(){ myui.comment.init(); myui.gbook.init(); myui.autocomplete(); myui.favorite(); });