Commit 59fe3792 authored by 杨培's avatar 杨培

后台课程列表显示可读的时长与文件大小等

parent 57769f93
......@@ -6,6 +6,7 @@
* @var $pagination \yii\data\Pagination
* @var $qiniu \common\components\Qiniu
*/
use common\libs\Utils;
use common\models\Course;
use yii\helpers\Html;
use yii\helpers\Url;
......@@ -49,11 +50,11 @@ $qiniu = \Yii::$app->qiniu;
<tr role="row">
<th>课程ID</th>
<th colspan="2">视频</th>
<th>时长/秒</th>
<th>时长</th>
<th>文件大小</th>
<th>原始格式</th>
<th>价格/元</th>
<th>免费试看/分钟</th>
<th>免费试看</th>
<th>ACTION</th>
</tr>
</thead>
......@@ -63,11 +64,11 @@ $qiniu = \Yii::$app->qiniu;
<td class="sorting_1"><?=$course['id']?></td>
<td width="110"><a href="<?=$qiniu->getUrl('public', $course['preview_pic'])?>-m.preview" target="_blank"><img src="<?=$qiniu->getUrl('public', $course['preview_pic'])?>-s.preview" height="50"></a></td>
<td><a href="#"><?=Html::encode($course['name'])?></a><span class="help-block"><?=date('Y-m-d H:i:s', $course['created_at'])?></span></td>
<td><?=$course['courseware']['time']?></td>
<td><?=$course['courseware']['size']?></td>
<td><?=Utils::humanSeconds($course['courseware']['time'])?></td>
<td><?=Utils::byteConvert($course['courseware']['size'])?></td>
<td><?=$course['courseware']['format']?></td>
<td><?=$course['price']?></td>
<td><?=$course['free_time']?></td>
<td><?=($course['free_time'] ? $course['free_time'].'分钟' : '-')?></td>
<td>
<a class="btn btn-info btn-xs COURSE_DETAIL" href="<?=Url::to(['course/detail', 'id'=>$course['id']])?>" target="_blank"><i class="fa fa-info"></i> 详情</a>
<?php if ($course['status'] == Course::STATUS_OK) { ?>
......
......@@ -207,6 +207,39 @@ class Utils
return $count;
}
public static function byteConvert($bytes)
{
if ($bytes == 0)
return "0.00 B";
$s = array('B', 'KB', 'MB', 'GB', 'TB', 'PB');
$e = floor(log($bytes, 1024));
return round($bytes/pow(1024, $e), 2).' '.$s[$e];
}
/**
* 将秒数转换为自然时间
*
* @param int
* @return string
*/
public static function humanSeconds($tl)
{
$units = ['年'=>31536000, '月'=>2628000, '天'=>86400, '小时'=>3600, '分钟'=>60, '秒'=>1];
$str = '';
foreach ($units as $un => $it) {
if ($tl >= $it) {
$floor = floor($tl / $it);
$tl = fmod($tl, $it);
$str .= $floor.$un;
}
}
return $str;
}
/**
* @param $rootElementName
* @param $ar
......
......@@ -112,7 +112,5 @@ $qiniu = \Yii::$app->qiniu;
<?= LinkPager::widget(['pagination' => $pagination]) ?>
</div>
<?php } else { ?>
<div class="empty-data">
您还没有添加课程!
</div>
<div class="empty-data">您还没有添加课程!</div>
<?php } ?>
\ No newline at end of file
......@@ -72,7 +72,5 @@ AppAsset::addScript($this, '@web/assets/my_income.js');
</div>
</div>
<?php } else { ?>
<div class="empty-data" style="margin-top:80px;">
您还没有卖出课程的记录!
</div>
<div class="empty-data" style="margin-top:80px;">您还没有卖出课程的记录!</div>
<?php } ?>
\ No newline at end of file
......@@ -62,7 +62,5 @@ $this->title = '我的会员';
</div>
</div>
<?php } else { ?>
<div class="empty-data" style="margin-top:80px;">
您还没有会员!
</div>
<div class="empty-data" style="margin-top:80px;">您还没有会员!</div>
<?php } ?>
\ No newline at end of file
......@@ -14,8 +14,8 @@ AppAsset::addScript($this, '@web/assets/teacher_manager.js');
<img src="<?=\common\models\User::getAvatarUrl($row['avatar'])?>">
<h3><?=$row['name']?></h3>
<p><?=$row['intro']?></p>
<a class="edit" href="<?=\yii\helpers\Url::to(['teacher-manager/edit', 'id'=>$row['id']])?>"><i class="icon-mode_edit"></i></a>
<a href="javascript:;" class="delete"><i class="icon-trash"></i></a>
<a class="edit" href="<?=\yii\helpers\Url::to(['teacher-manager/edit', 'id'=>$row['id']])?>" title="编辑讲师信息"><i class="icon-mode_edit"></i></a>
<a href="javascript:;" class="delete" title="删除该讲师"><i class="icon-trash"></i></a>
</div>
</div>
<?php } ?>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment