Home  >  Article  >  Backend Development  >  Implementation method of thinkPHP order digital reminder function_php example

Implementation method of thinkPHP order digital reminder function_php example

WBOY
WBOYOriginal
2016-12-05 13:28:201188browse

The example in this article describes the implementation method of thinkPHP order digital reminder function. Share it with everyone for your reference, the details are as follows:

The operation effect diagram is as follows:

html:

<ul class="am-avg-sm-5">
  <li class="condition-li" status="0">
    <span class="condition">全部<if condition="$num.all neq 0"><span class="badge">{sh:$num.all}</span></if></span>
  </li>
  <li class="condition-li" status="1">
    <span class="condition">待付款
    <if condition="$num.unpaid neq 0"><span class="badge">{sh:$num.unpaid}</span></if>
    </span>
  </li>
  <li class="condition-li" status="2">
    <span class="condition">待发货
    <if condition="$num.unsent neq 0"><span class="badge">{sh:$num.unsent}</span></if>
    </span>
  </li>
  <li class="condition-li" status="3">
    <span class="condition">待收货
    <if condition="$num.unresevied neq 0"><span class="badge">{sh:$num.unresevied}</span></if>
    </span>
  </li>
  <li class="condition-li" status="4">
    <span class="condition">已收货
    <if condition="$num.resevied neq 0"><span class="badge">{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);

This time the value is passed in the form of an array, which is consistent.

Add a fixed layout effect

css:

<style type="text/css">
  .badge {
    background-color:#FFC245;
    position: absolute;
    top:-5px;
    right:-20px;
  }
  .condition{
    position: relative;
  }
</style>

Readers who are interested in more thinkPHP-related content can check out the special topics on this site: "Introduction to ThinkPHP Tutorial", "Summary of thinkPHP Template Operation Skills", "Summary of Common Methods of ThinkPHP", "Introduction to Codeigniter Tutorial", "CI (CodeIgniter) Framework" Advanced Tutorial", "Basic Tutorial for Getting Started with Smarty Templates" and "Summary of PHP Template Technology".

I hope that what is described in this article will be helpful to everyone’s PHP program design based on the ThinkPHP framework.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn