Commit 8762a5aa authored by 汪波's avatar 汪波

Merge remote-tracking branch 'origin/dev' into dev

parents 7bab12ea d00b25bc
...@@ -150,8 +150,15 @@ class QiniuTranscode ...@@ -150,8 +150,15 @@ class QiniuTranscode
$fopsMain .= '/r/'.$target['fps']; $fopsMain .= '/r/'.$target['fps'];
} }
//print_r($avInfo);
//opcache_invalidate(__FILE__);
//exit;
//视频采样率对比,七牛文档指出如果给出的码率大于原码率,则会使用原码率转换,但某些视频仍然会出现码率变大,所以此处加上判断 //视频采样率对比,七牛文档指出如果给出的码率大于原码率,则会使用原码率转换,但某些视频仍然会出现码率变大,所以此处加上判断
$fopsAddon .= '/vb/'.($video['bit_rate'] > $target['vb'] ? $target['vb'] : $video['bit_rate']); $bitRate = isset($video['bit_rate']) ? $video['bit_rate'] : (isset($avInfo['format']['bit_rate']) ? $avInfo['format']['bit_rate'] : 0);
if ($bitRate) {
$fopsAddon .= '/vb/' . ($bitRate > $target['vb'] ? $target['vb'] : $bitRate);
}
//编码对比 //编码对比
if ($video['codec_name'] != 'h264') { if ($video['codec_name'] != 'h264') {
......
...@@ -85,6 +85,20 @@ class Teacher extends ActiveRecord ...@@ -85,6 +85,20 @@ class Teacher extends ActiveRecord
]; ];
} }
/**
* 删除当前讲师所有数据
*/
public function deleteMe()
{
//删除头像
if ($this->avatar) {
UploadPools::deleteFile('public:'.$this->avatar);
}
CourseTeacher::deleteAll(['teacher_id'=>$this->id]);
self::deleteAll(['id'=>$this->id]);
}
/** /**
* 获取指定课堂下所有讲师的简单列表 * 获取指定课堂下所有讲师的简单列表
* *
...@@ -149,4 +163,18 @@ class Teacher extends ActiveRecord ...@@ -149,4 +163,18 @@ class Teacher extends ActiveRecord
return $data; return $data;
} }
/**
* 删除指定讲师所有数据
*
* @param int $teacherId
*/
public static function deleteTeacher($teacherId)
{
$teacher = self::findOne(['id'=>$teacherId]);
if ($teacher) {
$teacher->deleteMe();
}
}
} }
<?php
/**
* Created by PhpStorm.
* User: xiabin
* Date: 2016/10/27
* Time: 上午11:52
*/
namespace console\controllers;
use yii\console\Controller;
class TestController extends Controller
{
public function actionIndex(){
$t=mktime();
set_time_limit(1000);
$myFile="./insert.sql";
$fhandler=fopen($myFile,'wb');
if($fhandler){
$sql="268\t2\t'0,262,268,'\t0\t '2342'\t'423423'\t'123123'\t'23423423'\t'2012-01-09 09:55:43'\t'upload/product/20111205153432_53211.jpg'\t'upload/product/thumb_20111205153432_53211.jpg'\tNULL\tNULL\t38\t'件'\t''\t123\t123\t0";
$i=0;
while($i<10)//1,000,000
{
$i++;
fwrite($fhandler,$sql."\r\n");
}
echo"写入成功,耗时:",mktime()-$t;
}
}
}
\ No newline at end of file
...@@ -52,8 +52,14 @@ class ClassesFilter extends ActionFilter ...@@ -52,8 +52,14 @@ class ClassesFilter extends ActionFilter
} }
if ($this->_checkStatus && $class['status'] != Classes::STATUS_OK) { if ($this->_checkStatus && $class['status'] != Classes::STATUS_OK) {
switch ($class['status']) {
case Classes::STATUS_LOCKED:
Utils::showWarn('课堂被锁定无法访问!');
break;
default:
Utils::showWarn('您提交的课堂资料尚未通过审核,无法访问此页面!'); Utils::showWarn('您提交的课堂资料尚未通过审核,无法访问此页面!');
} }
}
if (property_exists(Yii::$app->controller, 'classStatus')) { if (property_exists(Yii::$app->controller, 'classStatus')) {
Yii::$app->controller->classStatus = $class; Yii::$app->controller->classStatus = $class;
......
<?php
/**
* Created by PhpStorm.
* User: pader
* Date: 2016/10/27
* Time: 11:43
*/
namespace frontend\components;
use common\libs\Utils;
use yii\base\ActionFilter;
class MobileFilter extends ActionFilter
{
protected $message;
public function setMessage($message)
{
$this->message = $message;
}
public function beforeAction($action)
{
if (\Yii::$app->deviceDetect->isMobile()) {
Utils::showWarn($this->message);
}
return parent::beforeAction($action);
}
}
\ No newline at end of file
...@@ -8,6 +8,7 @@ use common\models\CourseTeacher; ...@@ -8,6 +8,7 @@ use common\models\CourseTeacher;
use common\models\Courseware; use common\models\Courseware;
use common\models\UploadPools; use common\models\UploadPools;
use frontend\components\ClassesFilter; use frontend\components\ClassesFilter;
use frontend\components\MobileFilter;
use frontend\models\CoursePublishForm; use frontend\models\CoursePublishForm;
use Yii; use Yii;
use yii\filters\AccessControl; use yii\filters\AccessControl;
...@@ -38,10 +39,13 @@ class MyCourseController extends \yii\web\Controller ...@@ -38,10 +39,13 @@ class MyCourseController extends \yii\web\Controller
'roles' => ['@'] 'roles' => ['@']
] ]
] ]
], ], [
'classes' => [
'class' => ClassesFilter::className(), 'class' => ClassesFilter::className(),
'checkStatus' => true 'checkStatus' => true
], [
'class' => MobileFilter::className(),
'only' => ['publish', 'edit'],
'message' => '移动端暂不支持发布课程'
] ]
]; ];
} }
......
...@@ -4,6 +4,7 @@ namespace frontend\controllers; ...@@ -4,6 +4,7 @@ namespace frontend\controllers;
use common\components\Qiniu; use common\components\Qiniu;
use common\libs\Utils; use common\libs\Utils;
use common\models\CourseTeacher;
use common\models\Teacher; use common\models\Teacher;
use common\models\UploadPools; use common\models\UploadPools;
use common\models\User; use common\models\User;
...@@ -146,5 +147,29 @@ class TeacherManagerController extends \yii\web\Controller ...@@ -146,5 +147,29 @@ class TeacherManagerController extends \yii\web\Controller
return Teacher::fetchTeacherNames($classId); return Teacher::fetchTeacherNames($classId);
} }
/**
* 讲师管理
*
* @throws \yii\base\ExitException
*/
public function actionDelete()
{
$teacherId = Yii::$app->request->post('id', 0);
if (!$teacherId) {
Utils::ajaxResponse(false, '参数错误');
}
$teacher = Teacher::findOne(['id'=>$teacherId, 'class_id'=>$this->classStatus['id']]);
if (!$teacher) {
Utils::ajaxResponse(false, '该讲师不存在或无权操作!');
}
//删除讲师与课程的关系
$teacher->deleteMe();
Utils::ajaxResponse(true);
}
} }
<?php <?php
/* @var $this yii\web\View */ /* @var $this yii\web\View */
use frontend\assets\AppAsset;
$this->title = '讲师管理'; $this->title = '讲师管理';
AppAsset::addScript($this, '@web/assets/teacher_manager.js');
?> ?>
<div class="teacher-list"> <div class="teacher-list">
<?php foreach($data as $row) { ?> <?php foreach($data as $row) { ?>
<div class="col-md-3"> <div class="col-md-3 TEACHER_ROW" data-teacher-id="<?=$row['id']?>">
<div class="teacher-box"> <div class="teacher-box">
<img src="<?=\common\models\User::getAvatarUrl($row['avatar'])?>"> <img src="<?=\common\models\User::getAvatarUrl($row['avatar'])?>">
<h3><?=$row['name']?></h3> <h3><?=$row['name']?></h3>
<p><?=$row['intro']?></p> <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 class="edit" href="<?=\yii\helpers\Url::to(['teacher-manager/edit', 'id'=>$row['id']])?>"><i class="icon-mode_edit"></i></a>
<a href="#" class="delete"><i class="icon-trash"></i></a> <a href="javascript:;" class="delete"><i class="icon-trash"></i></a>
</div> </div>
</div> </div>
<?php } ?> <?php } ?>
......
...@@ -13,11 +13,13 @@ ...@@ -13,11 +13,13 @@
<a href="javascript:;" class="qzone post-icons bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a> <a href="javascript:;" class="qzone post-icons bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a>
</div> </div>
</div> </div>
<myvideo v-if="!coursewareInfo.isPreview" :preview-url="coursewareInfo.previewUrl" :video-url="coursewareInfo.videoUrl"></myvideo> <myvideo v-if="!coursewareInfo.isPreview" :preview-url="coursewareInfo.previewUrl"
:video-url="coursewareInfo.videoUrl"></myvideo>
<div v-else class="video-main"> <div v-else class="video-main">
<div class="video-empty" style="height:500px; width: 100%; background-color: #444; color: #fff; text-align: center;"> <div class="video-empty"
style="height:500px; width: 100%; background-color: #444; color: #fff; text-align: center;">
<i class="icon-clock"></i> <i class="icon-clock"></i>
<p>课程审核中,审核通过后大家才可以看到您的课程 <br /> <p>课程审核中,审核通过后大家才可以看到您的课程 <br/>
审核结果将以短信形式通知您</p> 审核结果将以短信形式通知您</p>
</div> </div>
</div> </div>
...@@ -55,7 +57,8 @@ ...@@ -55,7 +57,8 @@
data-toggle="modal" disabled="disabled">已购买 data-toggle="modal" disabled="disabled">已购买
</button> </button>
<template v-else> <template v-else>
<button v-if="isMobile === false && isWeixin === false" class="btn btn-danger m-l-20 mb-left" <button id="web-pay" v-if="isMobile === false && isWeixin === false"
class="btn btn-danger m-l-20 mb-left"
data-toggle="modal" data-toggle="modal"
data-target="#pay">购买 ¥{{coursewareInfo.price}} data-target="#pay">购买 ¥{{coursewareInfo.price}}
</button> </button>
...@@ -196,7 +199,7 @@ ...@@ -196,7 +199,7 @@
window.location.href = url; window.location.href = url;
}, },
login(){ login(){
var returnUrl = __BASE_URL__ + 'home/video?courseId=' + this.coursewareInfo.course_id; var returnUrl = __BASE_URL__ + 'home/video?courseId=' + this.coursewareInfo.course_id + '&pay=1';
var url = __BASE_URL__ + 'site/set-return-url?url=' + returnUrl; var url = __BASE_URL__ + 'site/set-return-url?url=' + returnUrl;
$.getJSON(url, function () { $.getJSON(url, function () {
window.location.href = __BASE_URL__ + 'site/login'; window.location.href = __BASE_URL__ + 'site/login';
...@@ -251,22 +254,37 @@ ...@@ -251,22 +254,37 @@
} }
}, },
components: { components: {
myvideo:myvideo myvideo: myvideo
}, },
ready(){ ready(){
var self = this; var self = this;
this.isMobile = this.coursewareInfo.isMobile; this.isMobile = this.coursewareInfo.isMobile;
this.isWeixin = Utils.isWeixin(); this.isWeixin = Utils.isWeixin();
//判断是否要显示支付信息
var pay = getQueryString('pay');
if (pay == 1 && !this.coursewareInfo.isShop) {
if(this.isMobile == false && this.isWeixin == false){
$('#web-pay').trigger('click');
}else if(this.isMobile == true && this.isWeixin == false){
this.mobileAliPay(this.coursewareInfo.course_id);
}else if(this.isWeixin === true){
this.weixinJsPay(this.coursewareInfo.course_id);
}
}
} }
} }
function getQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg); //获取url中"?"符后的字符串并正则匹配
var context = "";
if (r != null)
context = r[2];
reg = null;
r = null;
return context == null || context == "" || context == "undefined" ? "" : context;
}
</script> </script>
......
...@@ -47,11 +47,11 @@ ...@@ -47,11 +47,11 @@
"poster": self.previewUrl "poster": self.previewUrl
}).ready(function () { }).ready(function () {
$('#my-video-play').css('width', '100%'); $('#my-video-play').css('width', '100%');
var wVideo = $('.video-detail-info').width(); var wVideo = $('#my-video-play').width();
var hVideo = wVideo * rate; var hVideo = wVideo * rate;
$('#my-video-play').css('height', hVideo); $('#my-video-play').css('height', hVideo);
window.onresize = function () { window.onresize = function () {
var wVideo = $('.video-detail-info').width(); var wVideo = $('#my-video-play').width();
var hVideo = wVideo * rate; var hVideo = wVideo * rate;
$('#my-video-play').css('height', hVideo); $('#my-video-play').css('height', hVideo);
}; };
......
/**
* Created by pader on 2016/10/27.
*/
var layer = require("layer-js");
$(".TEACHER_ROW a.delete").click(function() {
var teacherId = $(this).closest(".TEACHER_ROW").data("teacherId");
layer.confirm("确定删除该讲师吗?", {
title: "删除讲师",
btn: ['确定','取消']
}, function() {
var idx = layer.msg("正在提交..", {icon:16, shade: [0.2,'#000'], time:0});
$.post("/teacher-manager/delete", {id:teacherId}, function(t) {
layer.close(idx);
if (t.status) {
layer.msg("已删除指定讲师!", {
time: 1500,
icon: 1,
end: function() {
location.reload();
},
shade: [0.2,'#000']
});
} else {
layer.alert(t.message, {icon:5, title:"提示"});
}
}, "json");
});
});
\ No newline at end of file
...@@ -25,6 +25,7 @@ var entry = { ...@@ -25,6 +25,7 @@ var entry = {
home_video: [js_dir + '/home/video.js'], home_video: [js_dir + '/home/video.js'],
course_publish: [js_dir + '/my-course/publish.js'], course_publish: [js_dir + '/my-course/publish.js'],
course_edit: [js_dir + '/my-course/edit.js'], course_edit: [js_dir + '/my-course/edit.js'],
teacher_manager: [js_dir + '/teacher-manager/index.js'],
teacher_form: [js_dir + '/teacher-manager/form.js'], teacher_form: [js_dir + '/teacher-manager/form.js'],
my_income: [js_dir + '/my-income/index.js'] my_income: [js_dir + '/my-income/index.js']
}; };
......
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