いくつかのニュースやメッセージのプロンプトがある場合があり、絶対的なポジショニングを使用して効果を達成できます。
原則は何ですか?
1.数またはステータスを取得します。
次のようにコードコードをコピーします。
関数getNewScount(){
$ time = date( "ymd"、strtotime( "-3 day"));
$ where ["news.checked =?"] = array( "val" => 1、 "type" => 1);
$ where ["news.updateTime> =?"] = array( "val" => $ time、 "type" => 1); // '2014-01-10' '
$ news = $ this-> dao_news-> getNews($ where);
return count($ news);
}
関数getStatus($ user_id){
$ where ["lx_messageto.user_id =?"] = array( "val" => $ user_id、 "type" => 1);
$ where ["lx_messageto.status =?"] = array( "val" => 1、 "type" => 1);
$ message = $ this-> dao_message-> getMessageto($ where);
return count($ message);
}
2。フロントエンド処理ディスプレイ。 JSを使用して処理します。
次のようにコードコードをコピーします。
<div style = "position:absolute;">
<! - {if $ statuscount neq ""} - >
<div>
<! - {$ statusCount} - >
</div>
<! - {/if} - >
</div>
<div style = "position:absolute;">
<! - {if $ newscount neq ""} - >
<div>
<img src = "/images/common/new.png">
</div>
<! - {/if} - >
</div>
CSS
次のようにコードコードをコピーします。
.status_num {
ポーズ:絶対;
左:70px:0px;
バックグラウンドイメージ:-webkit-gradient(線形、0、0、0ボトム、(rgba(234、87、122、1))、(rgba(136、4、25、1)));
高さ:30px;
垂直アライイン:中央;
フォントファミリー:ヴェルダナ、ジュネーブ、sans-serif;
font-size:14px; -webkit-border-radius:30px;
パディング:0px 10px;
-webkit-box-shadow:1px 1px 3px#999;}
.status_icon {
ポーズ:絶対;
左:70px:0px;
}
JS処理
次のようにコードコードをコピーします。
$(function(){
amess = $( "a [href ^= '/message']");
anews = $( "a [href ^= '/news/index']");
var status = $( "。status1");
var statusnews = $( "。status2");
anews.prendy(statusnews);
amess.prept(status);
});
3。または、Ajaxを使用してデータを取得し、Ajax処理
次のようにコードコードをコピーします。
$(function(){
if($( "a [href *= '/news/mgr']")!= ""){
anews = $( "a [href *= '/news/mgr']");
$ .ajax({
データタイプ:「html」、
タイプ:「投稿」、
url: "/default/index/ajaxgetNewstatus"、
成功:function(msg){
if(msg> 0){
var num = '<div style = "position:absolute;">'
+'<div>'+msg+'</div> </div>';
anews.predent(num);}
}
});
};
});