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

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

parents 7bab12ea d00b25bc
......@@ -150,8 +150,15 @@ class QiniuTranscode
$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') {
......
......@@ -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
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,7 +52,13 @@ class ClassesFilter extends ActionFilter
}
if ($this->_checkStatus && $class['status'] != Classes::STATUS_OK) {
Utils::showWarn('您提交的课堂资料尚未通过审核,无法访问此页面!');
switch ($class['status']) {
case Classes::STATUS_LOCKED:
Utils::showWarn('课堂被锁定无法访问!');
break;
default:
Utils::showWarn('您提交的课堂资料尚未通过审核,无法访问此页面!');
}
}
if (property_exists(Yii::$app->controller, 'classStatus')) {
......
<?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;
use common\models\Courseware;
use common\models\UploadPools;
use frontend\components\ClassesFilter;
use frontend\components\MobileFilter;
use frontend\models\CoursePublishForm;
use Yii;
use yii\filters\AccessControl;
......@@ -38,10 +39,13 @@ class MyCourseController extends \yii\web\Controller
'roles' => ['@']
]
]
],
'classes' => [
], [
'class' => ClassesFilter::className(),
'checkStatus' => true
], [
'class' => MobileFilter::className(),
'only' => ['publish', 'edit'],
'message' => '移动端暂不支持发布课程'
]
];
}
......
......@@ -4,6 +4,7 @@ namespace frontend\controllers;
use common\components\Qiniu;
use common\libs\Utils;
use common\models\CourseTeacher;
use common\models\Teacher;
use common\models\UploadPools;
use common\models\User;
......@@ -145,6 +146,30 @@ class TeacherManagerController extends \yii\web\Controller
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
/* @var $this yii\web\View */
use frontend\assets\AppAsset;
$this->title = '讲师管理';
AppAsset::addScript($this, '@web/assets/teacher_manager.js');
?>
<div class="teacher-list">
<?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">
<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="#" class="delete"><i class="icon-trash"></i></a>
<a href="javascript:;" class="delete"><i class="icon-trash"></i></a>
</div>
</div>
<?php } ?>
......
......@@ -13,11 +13,13 @@
<a href="javascript:;" class="qzone post-icons bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a>
</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 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>
<p>课程审核中,审核通过后大家才可以看到您的课程 <br />
<p>课程审核中,审核通过后大家才可以看到您的课程 <br/>
审核结果将以短信形式通知您</p>
</div>
</div>
......@@ -37,13 +39,13 @@
</p>
<p v-else class="mb-right">
<a href="javascript:;"><i class="icon-comment-empty"></i>{{coursewareInfo.comment_count}}</a>
<a href="javascript:;"><i
<a href="javascript:;"><i
:class="{'icon-fav-full':coursewareInfo.isFavorite,'icon-fav-empty':!coursewareInfo.isFavorite}"></i>{{coursewareInfo.favorite_count}}</a>
<a href="javascript:;"><i
<a href="javascript:;"><i
:class="{'icon-zan-full':coursewareInfo.isSupport,'icon-zan-empty':!coursewareInfo.isSupport}"></i>{{coursewareInfo.support_count}}</a>
</p>
<button v-if="coursewareInfo.isPreview" class="btn btn-danger m-l-20 mb-left">购买
<button v-if="coursewareInfo.isPreview" class="btn btn-danger m-l-20 mb-left">购买
¥{{coursewareInfo.price}}
</button>
<template v-else>
......@@ -55,7 +57,8 @@
data-toggle="modal" disabled="disabled">已购买
</button>
<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-target="#pay">购买 ¥{{coursewareInfo.price}}
</button>
......@@ -189,14 +192,14 @@
},
mobileAliPay(courseId){
var url = __BASE_URL__ + 'home/pay?courseId=' + courseId;
window.location.href = url;
window.location.href = url;
},
weixinJsPay(courseId){
var url = __BASE_URL__ + 'weixin-js-pay/index?courseId=' + courseId;
window.location.href = url;
},
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;
$.getJSON(url, function () {
window.location.href = __BASE_URL__ + 'site/login';
......@@ -251,22 +254,37 @@
}
},
components: {
myvideo:myvideo
myvideo: myvideo
},
ready(){
var self = this;
this.isMobile = this.coursewareInfo.isMobile;
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>
......
......@@ -47,11 +47,11 @@
"poster": self.previewUrl
}).ready(function () {
$('#my-video-play').css('width', '100%');
var wVideo = $('.video-detail-info').width();
var wVideo = $('#my-video-play').width();
var hVideo = wVideo * rate;
$('#my-video-play').css('height', hVideo);
window.onresize = function () {
var wVideo = $('.video-detail-info').width();
var wVideo = $('#my-video-play').width();
var hVideo = wVideo * rate;
$('#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 = {
home_video: [js_dir + '/home/video.js'],
course_publish: [js_dir + '/my-course/publish.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'],
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