Commit eacb556f authored by 夏彬's avatar 夏彬

修改推荐课程的自定义标签修改支持直播课程

parent 49e89f2b
...@@ -6,8 +6,12 @@ ...@@ -6,8 +6,12 @@
* Time: 11:46 AM * Time: 11:46 AM
*/ */
use internalApi\xue\CourseList;
require(__DIR__ . '/../extend/internalApi/autoload.php'); require(__DIR__ . '/../extend/internalApi/autoload.php');
require(__DIR__ . '/../config/config_ibanshou.php'); require(__DIR__ . '/../config/config_ibanshou.php');
\internalApi\base\Client::config($config['wxh.internal']['client']); \internalApi\base\Client::config($config['wxh.internal']['client']);
$num = isset($_GET['num']) ? $_GET['num'] : 3; $num = isset($_GET['num']) ? $_GET['num'] : 3;
echo json_encode(internalApi\bbs\Tcptuan::getGoods($num));
\ No newline at end of file
echo print_r(CourseList::getRecommendList(1));
\ No newline at end of file
...@@ -5,20 +5,20 @@ use internalApi\xue\CourseList; ...@@ -5,20 +5,20 @@ use internalApi\xue\CourseList;
function user_ibanshou($num) function user_ibanshou($num)
{ {
require __DIR__.'/../extend/internalApi/autoload.php'; require __DIR__ . '/../extend/internalApi/autoload.php';
require __DIR__.'/../config/config_ibanshou.php'; require __DIR__ . '/../config/config_ibanshou.php';
\internalApi\base\Client::config($config['wxh.internal']['client']); \internalApi\base\Client::config($config['wxh.internal']['client']);
$thread = Thread::getHotThreads($num); $thread = Thread::getHotThreads($num);
$list = CourseList::getRecommendList($num); $list = CourseList::getRecommendList($num);
$str = '<div clas=\"recommend-info\">'; $str = '<div clas=\"recommend-info\">';
foreach ($list as $val) { foreach ($list as $val) {
//自适应 http, https //自适应 http, https
$val['url'] = str_replace('http://', '//', $val['url']); $val['url'] = str_replace('http://', '//', $val['url']);
if($val['homework'] == 4 and $val['liveStatus'] == 0){ if ($val['homework'] == 4) {
$str .= <<<EOD if ($val['liveStatus'] == 0) {
$str .= <<<EOD
<div class="tuan-list"> <div class="tuan-list">
<a href="{$val['url']}"> <a href="{$val['url']}">
<img src="{$val['preview_pic']}-ym.preview\"> <img src="{$val['preview_pic']}-ym.preview\">
...@@ -30,8 +30,10 @@ function user_ibanshou($num) ...@@ -30,8 +30,10 @@ function user_ibanshou($num)
</a> </a>
</div> </div>
EOD; EOD;
}else if($val['homework'] == 4 and $val['liveStatus'] == 1){
$str .= <<<EOD } else {
$str .= <<<EOD
<div class="tuan-list"> <div class="tuan-list">
<a href="{$val['url']}"> <a href="{$val['url']}">
<img src="{$val['preview_pic']}-ym.preview\"> <img src="{$val['preview_pic']}-ym.preview\">
...@@ -43,7 +45,8 @@ EOD; ...@@ -43,7 +45,8 @@ EOD;
</a> </a>
</div> </div>
EOD; EOD;
}else{ }
} else {
$str .= <<<EOD $str .= <<<EOD
<div class=\"news-item portal-course\"> <div class=\"news-item portal-course\">
<a href=\"{$val['url']}\" class=\"content pb-none\"> <a href=\"{$val['url']}\" class=\"content pb-none\">
...@@ -64,11 +67,11 @@ EOD; ...@@ -64,11 +67,11 @@ EOD;
} }
foreach ($thread as $val) { foreach ($thread as $val) {
//自适应 http, https //自适应 http, https
$val['image'] = $val['image'] ? str_replace('http://', '//', $val['image']): '/skin/default/images/notimg.gif'; $val['image'] = $val['image'] ? str_replace('http://', '//', $val['image']) : '/skin/default/images/notimg.gif';
$val['url'] = str_replace('http://', '//', $val['url']); $val['url'] = str_replace('http://', '//', $val['url']);
$str .= <<<EOD $str .= <<<EOD
<div class=\"news-item has-pic one-picture\"> <div class=\"news-item has-pic one-picture\">
<a href=\"{$val['url']}\" class=\"content pb-none\" style=\"min-height: 80px;\"> <a href=\"{$val['url']}\" class=\"content pb-none\" style=\"min-height: 80px;\">
<div class=\"tit\">{$val['subject']}</div> <div class=\"tit\">{$val['subject']}</div>
...@@ -88,17 +91,21 @@ EOD; ...@@ -88,17 +91,21 @@ EOD;
echo $str . '</div>'; echo $str . '</div>';
} }
function user_ago($tm,$rcs = 0) { function user_ago($tm, $rcs = 0)
$cur_tm = time(); $dif = $cur_tm-$tm; {
$pds = array('秒','分钟','小时','天','周','个月','年'); $cur_tm = time();
$lngh = array(1,60,3600,86400,604800,2630880,31570560); $dif = $cur_tm - $tm;
for($v = sizeof($lngh)-1; ($v >= 0)&&(($no = $dif/$lngh[$v])<=1); $v--); if($v < 0) $v = 0; $_tm = $cur_tm-($dif%$lngh[$v]); $pds = array('秒', '分钟', '小时', '天', '周', '个月', '年');
$lngh = array(1, 60, 3600, 86400, 604800, 2630880, 31570560);
for ($v = sizeof($lngh) - 1; ($v >= 0) && (($no = $dif / $lngh[$v]) <= 1); $v--) ;
if ($v < 0) $v = 0;
$_tm = $cur_tm - ($dif % $lngh[$v]);
$no = floor($no); $no = floor($no);
//if($no <> 1) $pds[$v] .='s'; //+s //if($no <> 1) $pds[$v] .='s'; //+s
$x=sprintf("%d %s",$no,$pds[$v]); $x = sprintf("%d %s", $no, $pds[$v]);
if(($rcs == 1)&&($v >= 1)&&(($cur_tm-$_tm) > 0)) $x .= time_ago($_tm); if (($rcs == 1) && ($v >= 1) && (($cur_tm - $_tm) > 0)) $x .= time_ago($_tm);
return $x."前"; return $x . "前";
} }
?> ?>
\ No newline at end of file
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