作者 刘朕
1 个管道 的构建 通过 耗费 1 秒

合并分支 'Branch_liuzhen' 到 'master'

Branch liuzhen



查看合并请求 !147
@@ -136,6 +136,8 @@ class Hot extends Api @@ -136,6 +136,8 @@ class Hot extends Api
136 $list = $inform->items(); 136 $list = $inform->items();
137 $view_model = new StoreInformView(); 137 $view_model = new StoreInformView();
138 foreach ($list as &$v) { 138 foreach ($list as &$v) {
  139 + // 发布时间调整
  140 + $v['createtime'] = tranTime(strtotime($v['createtime']));
139 // 获取点赞数及是否点赞 141 // 获取点赞数及是否点赞
140 $where_g = [ 142 $where_g = [
141 'object_id' => $v['id'] 143 'object_id' => $v['id']
@@ -398,4 +398,34 @@ if(!function_exists('array_sort')) { @@ -398,4 +398,34 @@ if(!function_exists('array_sort')) {
398 } 398 }
399 return $array; 399 return $array;
400 } 400 }
  401 +}
  402 +
  403 +if(!function_exists('tranTime')) {
  404 + function tranTime($time)
  405 + {
  406 + $rtime = date("m-d H:i", $time);
  407 + $htime = date("H:i", $time);
  408 + $time = time() - $time;
  409 + if ($time < 60) {
  410 + $str = '刚刚';
  411 + } elseif ($time < 60 * 60) {
  412 + $min = floor($time / 60);
  413 + $str = $min . '分钟前';
  414 + } elseif ($time < 60 * 60 * 24) {
  415 + $h = floor($time / (60 * 60));
  416 + $str = $h . '小时前 ' . $htime;
  417 + } else {
  418 + $str = floor($time / 86400) . '天前';
  419 + }
  420 +// elseif ($time < 60 * 60 * 24 * 3) {
  421 +// $d = floor($time / (60 * 60 * 24));
  422 +// if ($d == 1)
  423 +// $str = '昨天 ' . $rtime;
  424 +// else
  425 +// $str = '前天 ' . $rtime;
  426 +// } else {
  427 +// $str = $rtime;
  428 +// }
  429 + return $str;
  430 + }
401 } 431 }