运行效果图如下:
html:
<ul> <li status="0"> <span>全部<if condition="$num.all neq 0"><span>{sh:$num.all}</span></if></span> </li> <li status="1"> <span>待付款 <if condition="$num.unpaid neq 0"><span>{sh:$num.unpaid}</span></if> </span> </li> <li status="2"> <span>待发货 <if condition="$num.unsent neq 0"><span>{sh:$num.unsent}</span></if> </span> </li> <li status="3"> <span>待收货 <if condition="$num.unresevied neq 0"><span>{sh:$num.unresevied}</span></if> </span> </li> <li status="4"> <span>已收货 <if condition="$num.resevied neq 0"><span>{sh:$num.resevied}</span></if> </span> </li> </ul>
php:
// 各种状态的数字提醒 $whereall = array('member_id' => $this->member_id); $allorder = $this->orderModel->where($whereall)->select(); $num = array('all'=>0,'unpaid'=>0,'unsent'=>0,'unresevied'=>0,'resevied'=>0); foreach ($allorder as $k => $order) { if ( $order['paytime'] == 0 ) { $num['unpaid']++ ; } if ($order['paytime'] != 0 && $order['sendtime'] == 0) { $num['unsent'] ++ ; } if ($order['paytime'] != 0 && $order['sendtime'] != 0 && $order['receivetime'] == 0) { $num['unresevied'] ++ ; } if ($order['paytime'] != 0 && $order['sendtime'] != 0 && $order['receivetime'] != 0) { $num['resevied'] ++ ; } $num['all'] ++ ; } $this->assign('num',$num);
本次采用数组的形式传值,具有统一性。
再加一个固定布局效果
css:
<style type="text/css"> .badge { background-color:#FFC245; position: absolute; top:-5px; right:-20px; } .condition{ position: relative; } </style>
更多关于thinkPHP相关内容感兴趣的读者可查看本站专题:《ThinkPHP入门教程》、《thinkPHP模板操作技巧总结》、《ThinkPHP常用方法总结》、《codeigniter入门教程》、《CI(CodeIgniter)框架进阶教程》、《smarty模板入门基础教程》及《PHP模板技术总结》。