Commit 579cbd38 authored by xiabin's avatar xiabin

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

parents 7b086552 068a27f5
...@@ -12,7 +12,7 @@ use Qiniu\Storage\UploadManager; ...@@ -12,7 +12,7 @@ use Qiniu\Storage\UploadManager;
use Yii; use Yii;
use yii\base\Model; use yii\base\Model;
class AttachUploadForm extends Model class AttachUpload extends Model
{ {
const SESS_PREFIX = 'attachpool_'; const SESS_PREFIX = 'attachpool_';
......
...@@ -169,7 +169,7 @@ class Course extends \yii\db\ActiveRecord ...@@ -169,7 +169,7 @@ class Course extends \yii\db\ActiveRecord
if ($count > 0) { if ($count > 0) {
$return['data'] = self::find() $return['data'] = self::find()
->select('id,user_id,price,name,intro,preview_pic,recommend,play_count,comment_count,favorite_count,created_at') ->select('id,user_id,price,name,intro,preview_pic,recommend,play_count,comment_count,favorite_count,created_at')
->where($cond)->limit($num)->offset($offset)->with('teachers')->asArray()->all(); ->where($cond)->orderBy(['id'=>SORT_DESC])->limit($num)->offset($offset)->with('teachers')->asArray()->all();
} }
return $return; return $return;
......
...@@ -31,4 +31,50 @@ class CourseTeacher extends \yii\db\ActiveRecord ...@@ -31,4 +31,50 @@ class CourseTeacher extends \yii\db\ActiveRecord
]; ];
} }
public static function getTeachersIdsByCourseId($courseId)
{
$list = self::find()->select('teacher_id')->where(['course_id'=>$courseId])->asArray()->all();
return array_column($list, 'teacher_id');
}
public static function removeRelations($courseId, $teacherIds)
{
self::deleteAll([
'and',
['course_id'=>$courseId],
['in', 'teacher_id', $teacherIds]
]);
//self::find()->where(['cousre_id'=>$courseId])->andWhere(['in', 'teacher_id', $teacherIds])
}
/**
* 自动处理新的讲师列表
*
* 对比并移除老的讲师与课程关系,添加新的关系
*
* @param int $courseId
* @param array $newTeacherIds
*/
public static function autoSaveRelations($courseId, $newTeacherIds)
{
$old = self::getTeachersIdsByCourseId($courseId);
$del = array_diff($old, $newTeacherIds);
$new = array_diff($newTeacherIds, $old);
$new && self::saveRelations($courseId, $new);
$del && self::removeRelations($courseId, $del);
}
public static function saveRelations($courseId, $teacherIds)
{
//保存讲师与课程关联数据
foreach ($teacherIds as $teacherId) {
$ct = new self();
$ct->course_id = $courseId;
$ct->teacher_id = $teacherId;
$ct->save();
}
}
} }
...@@ -16,7 +16,7 @@ use yii\db\ActiveRecord; ...@@ -16,7 +16,7 @@ use yii\db\ActiveRecord;
* @property string $name * @property string $name
* @property integer $status * @property integer $status
* @property string $size * @property string $size
* @property string $time * @property int $time
* @property string $format * @property string $format
* @property integer $created_at * @property integer $created_at
* @property integer $updated_at * @property integer $updated_at
......
...@@ -45,8 +45,10 @@ class Teacher extends ActiveRecord ...@@ -45,8 +45,10 @@ class Teacher extends ActiveRecord
[['name', 'class_id'], 'required'], [['name', 'class_id'], 'required'],
[['user_id', 'created_at', 'updated_at'], 'integer'], [['user_id', 'created_at', 'updated_at'], 'integer'],
[['intro'], 'string'], [['intro'], 'string'],
[['intro'], 'default', 'value'=>''],
[['name'], 'string', 'min'=>2, 'max' => 64], [['name'], 'string', 'min'=>2, 'max' => 64],
[['avatar'], 'string', 'max' => 100], [['avatar'], 'string', 'max' => 100],
[['avatar'], 'default', 'value' => ''],
]; ];
} }
......
...@@ -90,7 +90,7 @@ class ClassesInfoController extends \yii\web\Controller ...@@ -90,7 +90,7 @@ class ClassesInfoController extends \yii\web\Controller
if (!$agreement) { if (!$agreement) {
$model->addError('agreement', '必须同意使用协议'); $model->addError('agreement', '必须同意使用协议');
} elseif ($model->validate() && $model->save()) { } elseif ($model->validate() && $model->save()) {
return $this->redirect('/classes-info'); return $this->render('@app/views/site/success', ['message'=>'您已成功提交课堂申请,我们将尽快为您审核通过。']);
} }
} }
......
...@@ -73,7 +73,7 @@ class MyIncomeController extends \yii\web\Controller ...@@ -73,7 +73,7 @@ class MyIncomeController extends \yii\web\Controller
'uid' => Yii::$app->user->getId() 'uid' => Yii::$app->user->getId()
])); ]));
$url = Url::to(['my-income/weixin-bind-request', 'key'=>$key], true); $url = Url::to(['my-income/wxbind-request', 'key'=>$key], true);
//输出二维码图像 //输出二维码图像
$response = Yii::$app->response; $response = Yii::$app->response;
......
<?php
/**
* Created by PhpStorm.
* User: pader
* Date: 2016/10/21
* Time: 16:17
*/
namespace frontend\models;
use common\libs\Utils;
use common\models\Teacher;
use common\models\UploadPools;
use Qiniu\Storage\BucketManager;
use yii\base\Model;
/**
* 课件发布辅助表单类
*
* 这不是一个常规的Yii表单类,仅用于处理提交数据后缀的辅助验证等
*
* @property $id int
* @property $tmp string
* @property $class_id int
* @property $user_id int
* @property $preview string|array
* @property $vuid string|array
* @property $name string
* @property $price float
* @property $free_time int
* @property $intro string
* @property $recommend int
* @package frontend\models
*/
class CoursePublishForm extends Model
{
public $id;
public $tmp;
public $class_id;
public $user_id;
public $vuid;
public $preview;
public $name;
/**
* 选择的讲师ID数组
* @var array
*/
public $teacher;
public $price;
public $free_time;
public $intro;
public $recommend;
private $createMode;
public function __construct($create=false) {
parent::__construct();
$this->createMode = $create;
}
public function formName() {
return '';
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'tmp' => 'Tmp',
'user_id' => 'User ID',
'class_id' => 'Class ID',
'name' => '标题',
'teacher' => '讲师',
'price' => '价格',
'free_time' => '免费观看时间',
'intro' => '简介',
'vuid' => '视频',
'preview' => '预览图',
'recommend' => '推荐课程'
];
}
public function rules()
{
$requiredFields = ['tmp', 'class_id', 'user_id', 'name', 'price', 'free_time', 'preview'];
//创建模式下将验证视频文件
if ($this->createMode) {
$requiredFields[] = 'vuid';
}
$rules = [
[$requiredFields, 'required'],
[['id', 'class_id', 'user_id', 'free_time'], 'integer'],
[['tmp', 'name', 'preview', 'intro'], 'string'],
['tmp', 'match', 'pattern'=>'/^\w{20}$/i'],
['teacher', 'validateTeachers'],
['teacher', 'default', 'value'=>[]],
['free_time', 'integer', 'min' => 0, 'max' => 15],
['preview', 'validateUploadKey'],
['recommend', 'boolean']
];
if ($this->createMode) {
$rules[] = ['vuid', 'validateUploadKey'];
}
return $rules;
}
/**
* 检查上传七牛云文件是否可领取是否可领取
*
* @param string $attr
* @param $params
*/
public function validateUploadKey($attr, $params)
{
//值 @orig 代表保持原文件,不做验证和修改,此时将值改为false
if ($this->$attr == '@orig') {
$this->$attr = false;
return;
}
//验证成功后值将被修改为文件信息数组
$file = UploadPools::getFileInfo($this->$attr);
if ($file) {
$this->$attr = $file;
} else {
$labels = $this->attributeLabels();
$name = isset($labels[$attr]) ? $labels[$attr] : '';
$this->addError($attr, $name.'文件不存在');
}
}
/**
* 过滤已拥有的讲师列表
*
* @param string $attr
* @param $params
*/
public function validateTeachers($attr, $params)
{
$ids = is_array($this->$attr) ? $this->$attr : [];
$this->$attr = Teacher::filterOwnTeacherIds($this->class_id, $ids);
}
/**
* 获取已验证的视频文件信息
*
* @param array $poolFile 由 UploadPools::getFileInfo 返回的文件信息
* @return array ['file'=>文件stat信息, 'av'=>文件avInfo流媒体信息]
* @throws \yii\base\ExitException
*/
public static function getVerifyVideoInfo($poolFile)
{
/* @var $qiniu \common\components\Qiniu; */
$qiniu = \Yii::$app->qiniu;
$bucket = $qiniu->getStorageConfig($poolFile['storage'], 'bucket');
$auth = $qiniu->getAuthInstance();
$bucketMgr = new BucketManager($auth);
$return = [];
/* @var $err \Qiniu\Http\Error */
list($ret, $err) = $bucketMgr->stat($bucket, $poolFile['key']);
if ($err !== null) {
Utils::ajaxResponse(false, $err->message());
} else {
$return['file'] = $ret;
}
//读取视频信息
$avUrl = $auth->privateDownloadUrl($poolFile['url'].'?avinfo');
$response = (new \GuzzleHttp\Client())->get($avUrl);
$avInfo = $response->getBody();
if ($avInfo) {
$return['av'] = \GuzzleHttp\json_decode($avInfo, true);
} else {
Utils::ajaxResponse(false, '读取视频信息失败');
}
return $return;
}
}
\ No newline at end of file
<?php
/**
* @var $this yii\web\View
* @var $course \common\models\Course
* @var $lesson \common\models\Courseware
* @var $teacherIds [\common\models\CourseTeacher]
*/
use frontend\assets\AppAsset;
$this->title = '编辑课程信息';
AppAsset::addScript($this, '@web/assets/course_edit.js');
AppAsset::addCss($this, '@web/assets/css/course_publish.css');
?>
<div class="send-class" id="publishMain" xmlns:v-el="http://www.w3.org/1999/xhtml">
<div class="tit">编辑课程信息</div>
<form method="post" name="courseEdit">
<div class="cls-part">
<div class="tit">标题</div>
<input type="text" name="name" class="input-r-control" placeholder="请输入课程标题,20 个汉字以内..." value="<?=$course->name?>">
</div>
<div class="cls-part teacher-list">
<div class="tit">讲师</div>
<teachers init-teachers="<?=join(',', $teacherIds)?>"></teachers>
</div>
<div class="cls-part">
<div class="tit">规则设定</div>
<div class="clearfix">
<div class="checkbox rules-set fl">
<label class="clearfix">
<span>会员价</span> <input type="text" name="price" class="input-r-control text-center" value="<?=$course->price?>"> <span>元</span>
</label>
</div>
<div class="checkbox rules-set m-l-20 fl">
<label class="clearfix">
<span>免费试看</span> <input type="text" name="free_time" class="input-r-control text-center" value="<?=$course->free_time?>"> <span>分钟</span>
</label>
</div>
</div>
</div>
<div class="cls-part">
<div class="tit">课程介绍</div>
<div class="cls-intro-textarea">
<textarea name="intro" class="input-r-control" placeholder="请输入课程介绍..." id="introEditor" style="height:300px;"><?=\yii\helpers\Html::encode($course->intro)?></textarea>
</div>
</div>
<div class="cls-part">
<div class="tit">缩略图 <small>建议尺寸:900像素 * 500像素</small></div>
<thumb-upload uptoken="<?=$thumbToken?>" init-img="<?=\Yii::$app->qiniu->getUrl('public', $course->preview_pic)?>-m.preview"></thumb-upload>
</div>
<div class="cls-part p-b-20">
<div class="tit">课程属性</div>
<div class="checkbox">
<label>
<input type="checkbox" name="recommend" value="1"<?php if ($course->recommend) { ?> checked<?php } ?>>推荐课程
</label>
</div>
</div>
<input type="hidden" name="id" value="<?=$course->id?>" />
<input type="hidden" name="tmp" value="{{tmp}}" />
<input type="hidden" name="vuid" value="@orig" v-model="vuid" />
<input type="hidden" name="preview" value="@orig" v-model="previewKey" />
<div class="btn-box text-center" style="border-top: 1px solid #e7e7e7; margin-top: 10px; ">
<button type="button" class="btn btn-nobg">取消</button>
<button type="submit" class="btn btn-save m-l-10">保存</button>
</div>
</form>
</div>
\ No newline at end of file
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
* @var $list array * @var $list array
* @var $pagination yii\data\Pagination * @var $pagination yii\data\Pagination
*/ */
use common\models\Course;
use yii\helpers\Url; use yii\helpers\Url;
use yii\widgets\LinkPager; use yii\widgets\LinkPager;
...@@ -19,9 +20,9 @@ $qiniu = \Yii::$app->qiniu; ...@@ -19,9 +20,9 @@ $qiniu = \Yii::$app->qiniu;
<div class="col-md-4"> <div class="col-md-4">
<div class="cls-box-main"> <div class="cls-box-main">
<div class="video-img-box"> <div class="video-img-box">
<a href="<?=Url::to(['video/index', 'id'=>$course['id']])?>" target="_blank"><img src="<?=$qiniu->getUrl('public', $course['preview_pic'])?>-m.preview"></a> <a href="<?=Course::url($course['id'])?>" target="_blank"><img src="<?=$qiniu->getUrl('public', $course['preview_pic'])?>-m.preview"></a>
<div class="video-list-cnt"> <div class="video-list-cnt">
<div class="tit"><a href="<?=Url::to(['video/index', 'id'=>$course['id']])?>" target="_blank"><?=$course['name']?></a></div> <div class="tit"><a href="<?=Course::url($course['id'])?>" target="_blank"><?=$course['name']?></a></div>
<?php if ($course['teachers']) { ?> <?php if ($course['teachers']) { ?>
<div class="teacher">讲师:<?=join(', ', array_column($course['teachers'], 'name'))?></div> <div class="teacher">讲师:<?=join(', ', array_column($course['teachers'], 'name'))?></div>
<?php } ?> <?php } ?>
...@@ -30,7 +31,7 @@ $qiniu = \Yii::$app->qiniu; ...@@ -30,7 +31,7 @@ $qiniu = \Yii::$app->qiniu;
<div class="outline"> <div class="outline">
<span><?=$course['play_count']?> 次播放</span> · <span><?=$course['comment_count']?> 次评论</span> · <span><?=$course['favorite_count']?> 收藏</span> <span><?=$course['play_count']?> 次播放</span> · <span><?=$course['comment_count']?> 次评论</span> · <span><?=$course['favorite_count']?> 收藏</span>
</div> </div>
<!--<div class="edit"><a href="<?=Url::to(['my-course/publish', 'id'=>$course['id']])?>"><i class="icon-mode_edit"></i></a></div>--> <div class="edit"><a href="<?=Url::to(['my-course/edit', 'id'=>$course['id']])?>" title="编辑课程信息"><i class="icon-mode_edit"></i></a></div>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -24,17 +24,7 @@ AppAsset::addCss($this, '@web/assets/css/course_publish.css'); ...@@ -24,17 +24,7 @@ AppAsset::addCss($this, '@web/assets/css/course_publish.css');
<div class="cls-part teacher-list"> <div class="cls-part teacher-list">
<div class="tit">讲师</div> <div class="tit">讲师</div>
<div class="checkbox" v-cloak> <teachers></teachers>
<label v-for="(index, item) in teachers" :class="{'m-l-10':index!=0}">
<input name="teacher[]" type="checkbox" value="{{item.id}}" v-model="checkedTeachers">{{item.name}}
</label>
<div class="d-i-b" v-if="atState">
<input type="text" class="input-r-control reset-input" placeholder="请输入讲师名称" v-model="addTeacherName" v-el:tni>
<button type="button" class="btn btn-nobg" @click="addTeacher">保存</button>
</div>
<span class="m-l-10" v-if="!atState"><a href="javascript:;" @click="addTeacher">+ 添加讲师</a></span>
</div>
</div> </div>
<div class="cls-part"> <div class="cls-part">
......
...@@ -778,14 +778,14 @@ textarea.input-r-control { ...@@ -778,14 +778,14 @@ textarea.input-r-control {
.upload-video-screen { .upload-video-screen {
position: relative; position: relative;
height: 44px; height: 166px;
line-height: 44px; line-height: 166px;
width: 200px; width: 300px;
border-radius: 3px; border-radius: 3px;
border: 1px solid #e7e7e7;
margin-top: 10px; margin-top: 10px;
text-align: center; text-align: center;
color: #999; color: #999;
border: 1px solid #f3f3f3;
} }
.upload-video-screen i { .upload-video-screen i {
padding-right: 5px; padding-right: 5px;
...@@ -794,17 +794,36 @@ textarea.input-r-control { ...@@ -794,17 +794,36 @@ textarea.input-r-control {
position: absolute; position: absolute;
left: 0; left: 0;
top: 0; top: 0;
height: 44px; height: 166px;
width: 200px; width: 300px;
border-radius: 3px; border-radius: 3px;
opacity: 0; opacity: 0;
cursor: pointer; cursor: pointer;
z-index: 4;
} }
.upload-video-screen:hover { .upload-video-screen span {
border: 1px solid #4285f4; position: absolute;
color: #4285f4; left: 0;
top: 0;
display: inline-block;
height: 166px;
width: 300px;
color: #999;
border-radius: 3px;
z-index: 3;
}
.upload-video-screen img {
height: 166px;
width: 300px;
position: absolute;
left: 0;
top: 0;
border-radius: 3px;
}
.upload-video-screen:hover span {
background-color: rgba(0,0,0,.6);
color: #fff;
} }
......
<template xmlns:v-bind="http://www.w3.org/1999/xhtml"> <template xmlns:v-bind="http://www.w3.org/1999/xhtml">
<div class="upload-video-screen" v-bind:id="uploaderId"> <div class="upload-video-screen" v-bind:id="uploaderId">
<i class="icon-image"></i>{{text}} <!--<img src="img/avatar.jpg">-->
<span>
<i class="icon-image"></i>{{text}}
</span>
</div> </div>
</template> </template>
<style> <style>
.upload-video-screen {cursor:pointer; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; padding:0 10px;} .upload-video-screen {cursor:pointer; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; padding:0 10px;}
.upload-video-screen.uploaded span {color:#FFF; text-shadow:0 0 8px #555;}
</style> </style>
<script> <script>
import layer from "layer-js"; import layer from "layer-js";
...@@ -22,11 +26,18 @@ export default{ ...@@ -22,11 +26,18 @@ export default{
} }
}, },
props: { props: {
uptoken: String uptoken: String,
initImg: String
}, },
ready() { ready() {
this.text = defaultText; var container = $(this.$el);
if (this.initImg) {
container.addClass('uploaded').prepend('<img src="' + this.initImg + '">');
defaultText = "更换缩略图";
}
this.text = defaultText;
var self = this; var self = this;
var uploader = new qiniu.Uploader({ var uploader = new qiniu.Uploader({
...@@ -45,18 +56,20 @@ export default{ ...@@ -45,18 +56,20 @@ export default{
auto_start: true, auto_start: true,
init: { init: {
'FilesAdded': function(up, files) { 'FilesAdded': function(up, files) {
plupload.each(files, function(file) { // plupload.each(files, function(file) {
// self.videoSize = filesize(file.origSize, {fixed:2, spacer:' '}).human('si'); // self.videoSize = filesize(file.origSize, {fixed:2, spacer:' '}).human('si');
// self.videoName = file.name; // self.videoName = file.name;
}); // });
self.state = 'uploading';
up.start(); up.start();
self.state = 'uploading';
self.text = "上传中.."; self.text = "上传中..";
container.addClass('uploading');
}, },
//每个文件上传前 //每个文件上传前
'BeforeUpload': function(up, file) { // 'BeforeUpload': function(up, file) {
}, // },
'UploadProgress': function(up, file) { 'UploadProgress': function(up, file) {
self.text = "上传中.." + file.percent + "%"; self.text = "上传中.." + file.percent + "%";
}, },
...@@ -66,9 +79,13 @@ export default{ ...@@ -66,9 +79,13 @@ export default{
setTimeout(function() { setTimeout(function() {
self.text = file.name; self.text = file.name;
}, 1000); }, 700);
var response = $.parseJSON(info.response); var response = $.parseJSON(info.response);
container.addClass("uploaded").find("img").remove();
container.prepend('<img src="' + response.src + '-m.preview">');
self.$dispatch("thumb-uploaded", file.name, response); self.$dispatch("thumb-uploaded", file.name, response);
}, },
'Error': function(up, err) { 'Error': function(up, err) {
...@@ -85,6 +102,7 @@ export default{ ...@@ -85,6 +102,7 @@ export default{
//队列文件处理完毕后 //队列文件处理完毕后
'UploadComplete': function() { 'UploadComplete': function() {
self.state = 'completed'; self.state = 'completed';
container.removeClass('uploading');
} }
} }
}); });
......
...@@ -6,7 +6,14 @@ ...@@ -6,7 +6,14 @@
$.ajaxSetup({ $.ajaxSetup({
beforeSend: function () { beforeSend: function () {
if (this.type == "POST") { if (this.type == "POST") {
this.data += "&_csrf-frontend=" + encodeURIComponent($("meta[name='csrf-token']").attr("content")); var name = "_csrf-frontend";
var token = $("meta[name='csrf-token']").attr("content");
if (this.data instanceof FormData) {
this.data.append(name, token);
} else {
this.data += (this.data ? "&" : "") + name + "=" + encodeURIComponent(token);
}
} }
} }
}); });
\ No newline at end of file
<template xmlns:v-el="http://www.w3.org/1999/xhtml">
<div class="checkbox">
<label v-for="(index, item) in teachers" :class="{'m-l-10':index!=0}">
<input name="teacher[]" type="checkbox" value="{{item.id}}" v-model="checkedTeachers">{{item.name}}
</label>
<div class="d-i-b" v-if="addFormShow">
<input type="text" class="input-r-control reset-input" placeholder="请输入讲师名称" v-model="newName" v-el:nameInput>
<button type="button" class="btn btn-nobg" @click="addTeacher">保存</button>
</div>
<span class="m-l-10" v-else><a href="javascript:;" @click="showAddForm">+ 添加讲师</a></span>
</div>
</template>
<script>
import layer from 'layer-js';
export default{
data() {
return {
teachers: [],
checkedTeachers: [],
addFormShow: false,
newName: ""
}
},
props: {
initTeachers: String
},
methods: {
showAddForm() {
this.addFormShow = true;
this.$nextTick(function() {
this.$els.nameInput.focus();
});
},
addTeacher(e) {
if ($.trim(this.newName) == "") {
this.$els.nameInput.focus();
return;
}
var self = this;
//添加讲师
$.post("/teacher-manager/save", {
name: self.newName
}, function(t) {
if (!t.error) {
self.loadTeacherList();
self.newName = "";
self.addFormShow = false;
self.checkedTeachers.push(t.teacher_id.toString());
} else {
layer.alert("添加讲师失败!\n" + t.error, {icon:5, title:"上传失败"});
}
}, "json");
},
loadTeacherList() {
var self = this;
$.getJSON("/teacher-manager/simple-teacher-list", function(t) {
self.teachers = t;
});
}
},
watch: {
checkedTeachers(val) {
this.$dispatch("teacher-quick-list-checked", val);
}
},
ready() {
this.loadTeacherList();
if (this.initTeachers) {
this.checkedTeachers = this.initTeachers.split(",");
}
}
}
</script>
/**
* Created by pader on 16/10/21.
*/
var Vue = require('vue');
var thumbUpload = require('../components/uploader/thumb-upload.vue');
var teacherQuickList = require('./components/teacher-quick-list.vue');
var richText = require('./rich-text');
var layer = require("layer-js");
var str = require("../utils/string");
require('jquery-validation');
var form = document.forms["courseEdit"];
var vm = new Vue({
el: "#publishMain",
data: {
vuid: "",
previewKey: "",
tmp: str.rand(20)
},
components: {
thumbUpload: thumbUpload,
teachers: teacherQuickList
},
ready: function() {
var self = this;
this.$on("thumb-uploaded", function(name, data) {
self.previewKey = data.uuid;
});
var validator = $(form).validate({
//debug: true,
//errorClass: "",
//validClass: "",
ignore: "",
rules: {
name: {
required: true
},
preview: {
required: true
}
},
messages: {
name: {
required: "请填写标题"
},
preview: {
required: "必须上传缩略图"
}
},
errorPlacement: function(error, element) {
var text = error.text();
var org = element.get(0);
var to = null;
if (org == form.preview) {
to = $(".upload-video-screen").get(0);
} else {
to = org;
}
//绑定提示到元素上
if (text) {
if (to.tipIndex) {
layer.close(to.tipIndex);
}
to.tipIndex = layer.tips(text, to, {
tips: org == form.name ? 3 : 2,
time: 0,
tipsMore: true
});
} else if (to.tipIndex) {
layer.close(to.tipIndex);
to.tipIndex = null;
}
},
success: function() {}, //添加 success 后,当表单验证成功时才会触发 errorPlacement,否则验证成功不触发
submitHandler: function() {
var data = $(form).serialize();
var idx = layer.msg("正在提交..", {icon:16, shade: [0.2,'#000'], time:0});
$.post("/my-course/save", data, function(t) {
layer.close(idx);
if (t.status) {
layer.msg('成功修改课程信息。', {
time: 2000,
icon: 1,
end: function() {
location.href = "/my-course/";
},
shade:[0.2,'#000']
});
} else {
layer.alert(t.message, {icon:5, title:"提示"});
}
}, "json");
return false;
}
});
var doValidate = function() { validator.form(); };
this.$watch("vuid", doValidate);
this.$watch("previewKey", doValidate);
richText.createEditor($("#introEditor"), this.tmp);
}
});
\ No newline at end of file
...@@ -4,21 +4,13 @@ ...@@ -4,21 +4,13 @@
var Vue = require('vue'); var Vue = require('vue');
var videoUpload = require('../components/uploader/video-upload.vue'); var videoUpload = require('../components/uploader/video-upload.vue');
var thumbUpload = require('../components/uploader/thumb-upload.vue'); var thumbUpload = require('../components/uploader/thumb-upload.vue');
var teacherQuickList = require('./components/teacher-quick-list.vue');
var richText = require('./rich-text');
var layer = require("layer-js"); var layer = require("layer-js");
var Simditor = require("../utils/simditor");
var str = require("../utils/string"); var str = require("../utils/string");
require('jquery-validation'); require('jquery-validation');
//$.ajaxSetup({
// beforeSend: function() {
// if (this.type == "POST") {
// this.data += "&_csrf-frontend=" + encodeURIComponent($("meta[name='csrf-token']").attr("content"));
// }
// }
//});
var form = document.forms["coursePublish"]; var form = document.forms["coursePublish"];
var vm = new Vue({ var vm = new Vue({
...@@ -26,54 +18,15 @@ var vm = new Vue({ ...@@ -26,54 +18,15 @@ var vm = new Vue({
data: { data: {
vuid: "", vuid: "",
previewKey: "", previewKey: "",
teachers: [],
atState: 0,
addTeacherName: "",
checkedTeachers: [],
tmp: str.rand(20) tmp: str.rand(20)
}, },
components: { components: {
videoUpload: videoUpload, videoUpload: videoUpload,
thumbUpload: thumbUpload thumbUpload: thumbUpload,
}, teachers: teacherQuickList
methods: {
addTeacher: function(e) {
if (e.target.tagName.toLowerCase() == "a") {
this.atState = 1;
return;
}
if ($.trim(this.addTeacherName) == "") {
this.$els.tni.focus();
return;
}
var self = this;
//添加讲师
$.post("/teacher-manager/save", {
name: self.addTeacherName
}, function(t) {
if (!t.error) {
self.loadTeacherList();
self.addTeacherName = "";
self.atState = 0;
self.checkedTeachers.push(t.teacher_id.toString());
} else {
layer.alert("添加讲师失败!\n" + t.error, {icon:5, title:"上传失败"});
}
}, "json");
},
loadTeacherList: function() {
$.getJSON("/teacher-manager/simple-teacher-list", function(t) {
vm.teachers = t;
});
}
}, },
ready: function() { ready: function() {
var self = this; var self = this;
this.loadTeacherList();
this.$on("video-uploaded", function(name, data) { this.$on("video-uploaded", function(name, data) {
self.vuid = data.uuid; self.vuid = data.uuid;
...@@ -161,22 +114,6 @@ var vm = new Vue({ ...@@ -161,22 +114,6 @@ var vm = new Vue({
this.$watch("vuid", doValidate); this.$watch("vuid", doValidate);
this.$watch("previewKey", doValidate); this.$watch("previewKey", doValidate);
var editor = new Simditor({ richText.createEditor($("#introEditor"), this.tmp);
textarea: $("#introEditor"),
toolbarFloat: false,
defaultImage: "/assets/img/placeholder.jpg",
upload: {
url : '/my-course/upload', //文件上传的接口地址
params: {
"_csrf-frontend": $("meta[name='csrf-token']").attr("content"),
"tmp": self.tmp
},
fileKey: 'file', //服务器端获取文件数据的参数名
connectionCount: 3,
leaveConfirm: '正在上传文件'
}
});
editor;
} }
}); });
\ No newline at end of file
/**
* Created by pader on 2016/10/21.
*/
var Simditor = require("../utils/simditor");
module.exports = {
createEditor: function(container, tmp) {
return new Simditor({
textarea: container,
toolbarFloat: true,
toolbarFloatOffset: 60,
defaultImage: "/assets/img/placeholder.jpg",
upload: {
url : '/my-course/upload', //文件上传的接口地址
params: {
"_csrf-frontend": $("meta[name='csrf-token']").attr("content"),
"tmp": tmp
},
fileKey: 'file', //服务器端获取文件数据的参数名
connectionCount: 3,
leaveConfirm: '正在上传文件'
}
});
}
};
\ No newline at end of file
...@@ -24,6 +24,7 @@ var entry = { ...@@ -24,6 +24,7 @@ var entry = {
home_index: [js_dir + '/home/index.js'], home_index: [js_dir + '/home/index.js'],
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'],
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']
}; };
......
...@@ -36,16 +36,40 @@ a,a:hover,a:link { ...@@ -36,16 +36,40 @@ a,a:hover,a:link {
display: block; display: block;
} }
.avatar {
padding-right: 30px;
height: 60px;
}
.avatar a {
display: block;
margin-top: 15px;
}
.avatar a img {
height: 30px;
width: 30px;
border-radius: 100%;
}
.menu-btn {
padding-left: 255px;
height: 60px;
line-height: 60px;
font-size: 24px;
color: #999;
text-align: center;
}
.z-m-center { .z-m-center {
text-align: center; text-align: center;
margin-top: 40px;
} }
.z-m-center > p { .z-m-center > p {
font-size: 12px; font-size: 12px;
padding: 0 0 20px;
color: #999; color: #999;
} }
.v-geetest {
width: 300px;
margin: 20px auto;
}
.tab-a ul,li , .tab-a ul,li ,
...@@ -160,6 +184,19 @@ a,a:hover,a:link { ...@@ -160,6 +184,19 @@ a,a:hover,a:link {
color: #2a6496; color: #2a6496;
} }
.verify-code-box img {
position: absolute;
right: -10px;
bottom: 0;
}
.verify-code-box .form-group {
margin-bottom: 0!important;
}
.verify-code-box .form-group .control-label {
display: none!important;
}
.foot-reg-btn { .foot-reg-btn {
margin-top: 20px; margin-top: 20px;
} }
......
...@@ -7,14 +7,14 @@ a,a:hover,a:link { ...@@ -7,14 +7,14 @@ a,a:hover,a:link {
text-decoration: none; text-decoration: none;
} }
/*font*/ /*icomoon*/
@font-face { @font-face {
font-family: 'icomoon'; font-family: 'icomoon';
src: url('../fonts/icomoon.eot?uyryw3'); src: url('../fonts/icomoon.eot?lylu0j');
src: url('../fonts/icomoon.eot?uyryw3#iefix') format('embedded-opentype'), src: url('../fonts/icomoon.eot?lylu0j#iefix') format('embedded-opentype'),
url('../fonts/icomoon.ttf?uyryw3') format('truetype'), url('../fonts/icomoon.ttf?lylu0j') format('truetype'),
url('../fonts/icomoon.woff?uyryw3') format('woff'), url('../fonts/icomoon.woff?lylu0j') format('woff'),
url('../fonts/icomoon.svg?uyryw3#icomoon') format('svg'); url('../fonts/icomoon.svg?lylu0j#icomoon') format('svg');
font-weight: normal; font-weight: normal;
font-style: normal; font-style: normal;
} }
...@@ -34,6 +34,12 @@ a,a:hover,a:link { ...@@ -34,6 +34,12 @@ a,a:hover,a:link {
-moz-osx-font-smoothing: grayscale; -moz-osx-font-smoothing: grayscale;
} }
.icon-jian:before {
content: "\e906";
}
.icon-shen:before {
content: "\e907";
}
.icon-comment-empty:before { .icon-comment-empty:before {
content: "\e900"; content: "\e900";
} }
...@@ -52,6 +58,198 @@ a,a:hover,a:link { ...@@ -52,6 +58,198 @@ a,a:hover,a:link {
.icon-zan-full:before { .icon-zan-full:before {
content: "\e905"; content: "\e905";
} }
.icon-add:before {
content: "\e145";
}
.icon-arrow_drop_down:before {
content: "\e5c5";
}
.icon-arrow_drop_up:before {
content: "\e5c7";
}
.icon-chat:before {
content: "\e0b7";
}
.icon-chat_bubble:before {
content: "\e0ca";
}
.icon-chat_bubble_outline:before {
content: "\e0cb";
}
.icon-navigate_before:before {
content: "\e408";
}
.icon-navigate_next:before {
content: "\e409";
}
.icon-cloud_done:before {
content: "\e2bf";
}
.icon-cloud_download:before {
content: "\e2c0";
}
.icon-palette:before {
content: "\e40a";
}
.icon-mode_edit:before {
content: "\e254";
}
.icon-create_new_folder:before {
content: "\e2cc";
}
.icon-crop_original:before {
content: "\e3c4";
}
.icon-expand_less:before {
content: "\e5ce";
}
.icon-expand_more:before {
content: "\e5cf";
}
.icon-fingerprint:before {
content: "\e90d";
}
.icon-ondemand_video:before {
content: "\e63a";
}
.icon-person_pin:before {
content: "\e55a";
}
.icon-play_circle_outline:before {
content: "\e039";
}
.icon-power_settings_new:before {
content: "\e8ac";
}
.icon-visibility:before {
content: "\e8f4";
}
.icon-school:before {
content: "\e80c";
}
.icon-shop:before {
content: "\e8c9";
}
.icon-slideshow:before {
content: "\e41b";
}
.icon-textsms:before {
content: "\e0d8";
}
.icon-stars:before {
content: "\e8d0";
}
.icon-thumb_up:before {
content: "\e8dc";
}
.icon-verified_user:before {
content: "\e8e8";
}
.icon-eye:before {
content: "\e000";
}
.icon-paper-clip:before {
content: "\e001";
}
.icon-mail:before {
content: "\e002";
}
.icon-link:before {
content: "\e005";
}
.icon-bell:before {
content: "\e006";
}
.icon-lock:before {
content: "\e007";
}
.icon-unlock:before {
content: "\e008";
}
.icon-ribbon:before {
content: "\e009";
}
.icon-image:before {
content: "\e010";
}
.icon-signal:before {
content: "\e011";
}
.icon-clipboard:before {
content: "\e013";
}
.icon-clock:before {
content: "\e014";
}
.icon-camera:before {
content: "\e017";
}
.icon-video:before {
content: "\e018";
}
.icon-cog:before {
content: "\e023";
}
.icon-heart:before {
content: "\e024";
}
.icon-layers:before {
content: "\e031";
}
.icon-stack-2:before {
content: "\e033";
}
.icon-paper:before {
content: "\e034";
}
.icon-microphone:before {
content: "\e048";
}
.icon-play:before {
content: "\e052";
}
.icon-folder:before {
content: "\e059";
}
.icon-cloud-upload:before {
content: "\e066";
}
.icon-cloud-download:before {
content: "\e067";
}
.icon-upload:before {
content: "\e068";
}
.icon-location:before {
content: "\e070";
}
.icon-speech-bubble:before {
content: "\e076";
}
.icon-arrow-left:before {
content: "\e094";
}
.icon-arrow-right:before {
content: "\e095";
}
.icon-arrow-up:before {
content: "\e096";
}
.icon-arrow-down:before {
content: "\e097";
}
.icon-trash:before {
content: "\e109";
}
.icon-check:before {
content: "\e116";
}
.icon-cross:before {
content: "\e117";
}
.icon-menu:before {
content: "\e120";
}
.navbar-main { .navbar-main {
background-color: #fff; background-color: #fff;
...@@ -276,26 +474,26 @@ a,a:hover,a:link { ...@@ -276,26 +474,26 @@ a,a:hover,a:link {
top: 0; top: 0;
} }
.post-icons { .post-icons {
width: 25px; width: 25px!important;
height: 22px; height: 22px!important;
float: left; float: left!important;
margin-left: 16px; margin-left: 16px!important;
background: url(../img/share_tit.png) no-repeat; background: url(../img/share_tit.png) no-repeat!important;
} }
.weibo { .weibo {
background-position: -25px 0; background-position: -25px 0!important;
} }
.qzone { .qzone {
background-position: -50px 0; background-position: -50px 0!important;
} }
.weibo:hover { .weibo:hover {
background-position: -25px -22px; background-position: -25px -22px!important;
} }
.qzone:hover { .qzone:hover {
background-position: -50px -22px; background-position: -50px -22px!important;
} }
.wechat:hover { .wechat:hover {
background-position: 0 -22px; background-position: 0 -22px!important;
} }
.video-detail-info { .video-detail-info {
...@@ -332,12 +530,9 @@ a,a:hover,a:link { ...@@ -332,12 +530,9 @@ a,a:hover,a:link {
color: #999; color: #999;
} }
.video-sm-info { .video-sm-info {
position: absolute;
height: 80px; height: 80px;
line-height: 80px; line-height: 80px;
right: 15px; padding-right: 30px;
top: 0;
} }
.video-sm-info a { .video-sm-info a {
display: inline-block; display: inline-block;
...@@ -398,6 +593,7 @@ a,a:hover,a:link { ...@@ -398,6 +593,7 @@ a,a:hover,a:link {
text-align: center; text-align: center;
line-height: 100px; line-height: 100px;
border: 1px solid #e5e6e8; border: 1px solid #e5e6e8;
margin-bottom: 20px;
} }
.comment-box { .comment-box {
position: relative; position: relative;
...@@ -537,4 +733,60 @@ a,a:hover,a:link { ...@@ -537,4 +733,60 @@ a,a:hover,a:link {
.qrcode-img > p { .qrcode-img > p {
margin-top: 5px; margin-top: 5px;
color: #999; color: #999;
}
.qrcode-img span {
display: inline-block;
width: 100%;
height: 150px;
text-align: center;
line-height: 150px;
color: #666;
}
.avatar {
padding-right: 30px;
height: 60px;
}
.avatar a {
display: block;
margin-top: 15px;
}
.avatar a img {
height: 30px;
width: 30px;
border-radius: 100%;
}
.mb-right {
display: inline-block;
margin-bottom: 0
}
.xs-show-bg {
display: none;
}
@media (max-width: 767px) {
.mb-left{
position: fixed!important;
right: 10px!important;
bottom: 7px!important;
z-index: 11;
}
.mb-right {
position: fixed!important;
left: 10px!important;
bottom: -14px!important;
z-index: 11;
}
.xs-show-bg {
display: block;
height: 50px;
width: 100%;
position: fixed;
bottom: 0;
left: 0;
background-color: #fff;
border-top: 1px solid #f3f3f3;
z-index: 10
}
} }
\ No newline at end of file
...@@ -231,6 +231,12 @@ i, em { ...@@ -231,6 +231,12 @@ i, em {
-moz-osx-font-smoothing: grayscale; -moz-osx-font-smoothing: grayscale;
} }
.icon-jian:before {
content: "\e906";
}
.icon-shen:before {
content: "\e907";
}
.icon-comment-empty:before { .icon-comment-empty:before {
content: "\e900"; content: "\e900";
} }
...@@ -291,11 +297,11 @@ i, em { ...@@ -291,11 +297,11 @@ i, em {
.icon-crop_original:before { .icon-crop_original:before {
content: "\e3c4"; content: "\e3c4";
} }
.icon-favorite:before { .icon-expand_less:before {
content: "\e87d"; content: "\e5ce";
} }
.icon-favorite_border:before { .icon-expand_more:before {
content: "\e87e"; content: "\e5cf";
} }
.icon-fingerprint:before { .icon-fingerprint:before {
content: "\e90d"; content: "\e90d";
...@@ -303,12 +309,36 @@ i, em { ...@@ -303,12 +309,36 @@ i, em {
.icon-ondemand_video:before { .icon-ondemand_video:before {
content: "\e63a"; content: "\e63a";
} }
.icon-person_pin:before {
content: "\e55a";
}
.icon-play_circle_outline:before {
content: "\e039";
}
.icon-power_settings_new:before { .icon-power_settings_new:before {
content: "\e8ac"; content: "\e8ac";
} }
.icon-visibility:before {
content: "\e8f4";
}
.icon-school:before {
content: "\e80c";
}
.icon-shop:before {
content: "\e8c9";
}
.icon-slideshow:before { .icon-slideshow:before {
content: "\e41b"; content: "\e41b";
} }
.icon-textsms:before {
content: "\e0d8";
}
.icon-stars:before {
content: "\e8d0";
}
.icon-thumb_up:before {
content: "\e8dc";
}
.icon-verified_user:before { .icon-verified_user:before {
content: "\e8e8"; content: "\e8e8";
} }
...@@ -416,4 +446,4 @@ i, em { ...@@ -416,4 +446,4 @@ i, em {
} }
.icon-menu:before { .icon-menu:before {
content: "\e120"; content: "\e120";
} }
\ No newline at end of file
...@@ -111,7 +111,7 @@ html { ...@@ -111,7 +111,7 @@ html {
-----------------------------*/ -----------------------------*/
.submenu { .submenu {
width: 100%; width: 100%;
display: none; /*display: none;*/
font-size: 14px; font-size: 14px;
} }
...@@ -290,6 +290,8 @@ html { ...@@ -290,6 +290,8 @@ html {
} }
/*teacher list*/ /*teacher list*/
.teacher-box { .teacher-box {
position: relative; position: relative;
...@@ -298,6 +300,7 @@ html { ...@@ -298,6 +300,7 @@ html {
height: 300px; height: 300px;
margin: 0 10px 40px 10px; margin: 0 10px 40px 10px;
text-align: center; text-align: center;
overflow: hidden;
} }
.teacher-box > img { .teacher-box > img {
margin-top: 100px; margin-top: 100px;
...@@ -344,6 +347,7 @@ html { ...@@ -344,6 +347,7 @@ html {
-webkit-transition: all 0.4s ease; -webkit-transition: all 0.4s ease;
-o-transition: all 0.4s ease; -o-transition: all 0.4s ease;
transition: all 0.4s ease; transition: all 0.4s ease;
word-break:break-all;
} }
.teacher-box:hover > img { .teacher-box:hover > img {
margin-top: 50px; margin-top: 50px;
...@@ -774,14 +778,14 @@ textarea.input-r-control { ...@@ -774,14 +778,14 @@ textarea.input-r-control {
.upload-video-screen { .upload-video-screen {
position: relative; position: relative;
height: 44px; height: 166px;
line-height: 44px; line-height: 166px;
width: 200px; width: 300px;
border-radius: 3px; border-radius: 3px;
border: 1px solid #e7e7e7;
margin-top: 10px; margin-top: 10px;
text-align: center; text-align: center;
color: #999; color: #999;
border: 1px solid #f3f3f3;
} }
.upload-video-screen i { .upload-video-screen i {
padding-right: 5px; padding-right: 5px;
...@@ -790,17 +794,36 @@ textarea.input-r-control { ...@@ -790,17 +794,36 @@ textarea.input-r-control {
position: absolute; position: absolute;
left: 0; left: 0;
top: 0; top: 0;
height: 44px; height: 166px;
width: 200px; width: 300px;
border-radius: 3px; border-radius: 3px;
opacity: 0; opacity: 0;
cursor: pointer; cursor: pointer;
z-index: 4;
} }
.upload-video-screen:hover { .upload-video-screen span {
border: 1px solid #4285f4; position: absolute;
color: #4285f4; left: 0;
top: 0;
display: inline-block;
height: 166px;
width: 300px;
color: #999;
border-radius: 3px;
z-index: 3;
}
.upload-video-screen img {
height: 166px;
width: 300px;
position: absolute;
left: 0;
top: 0;
border-radius: 3px;
}
.upload-video-screen:hover span {
background-color: rgba(0,0,0,.6);
color: #fff;
} }
...@@ -1022,8 +1045,6 @@ textarea.input-r-control { ...@@ -1022,8 +1045,6 @@ textarea.input-r-control {
border-radius: 100%; border-radius: 100%;
margin-right: 10px; margin-right: 10px;
} }
.v-code-box { .v-code-box {
position: relative; position: relative;
} }
...@@ -1085,7 +1106,7 @@ textarea.input-r-control { ...@@ -1085,7 +1106,7 @@ textarea.input-r-control {
margin-left: 10px; margin-left: 10px;
} }
.sm-box { .sm-box {
height: 320px; height: 400px;
} }
.sm-box .price { .sm-box .price {
height: 40px; height: 40px;
...@@ -1150,4 +1171,23 @@ textarea.input-r-control { ...@@ -1150,4 +1171,23 @@ textarea.input-r-control {
.qrcode-img > p { .qrcode-img > p {
margin-top: 5px; margin-top: 5px;
color: #999; color: #999;
}
@media (max-width: 767px) {
.tp-sidebar {
left: -225px;
}
.auto-main {
padding-left: 0;
}
.menu-btn {
padding-left: 30px;
}
.foot p {
padding-left: 30px;
}
.add-box {
width: auto;
}
} }
\ No newline at end of file
...@@ -61,12 +61,12 @@ ...@@ -61,12 +61,12 @@
<div class="tit">发布课程</div> <div class="tit">发布课程</div>
<div class="cls-part"> <div class="cls-part">
<div class="tit">标题</div> <div class="tit">标题<span class="remind">请输入标题!</span></div>
<input type="text" class="input-r-control" placeholder="请输入课程标题,20 个汉字以内..."> <input type="text" class="input-r-control" placeholder="请输入课程标题,20 个汉字以内...">
</div> </div>
<div class="cls-part teacher-list"> <div class="cls-part teacher-list">
<div class="tit">讲师</div> <div class="tit">讲师<span class="remind">请选择讲师!</span></div>
<div class="checkbox"> <div class="checkbox">
<label> <label>
...@@ -96,7 +96,7 @@ ...@@ -96,7 +96,7 @@
</div> </div>
<div class="cls-part"> <div class="cls-part">
<div class="tit">上传视频</div> <div class="tit">上传视频<span class="remind">请上传视频!</span></div>
<div class="upload-video-btn hide"> <div class="upload-video-btn hide">
<input type="file"> <input type="file">
<i class="icon-play"></i> <i class="icon-play"></i>
...@@ -144,7 +144,13 @@ ...@@ -144,7 +144,13 @@
<div class="tit">缩略图 <small>建议尺寸:900像素 * 500像素</small></div> <div class="tit">缩略图 <small>建议尺寸:900像素 * 500像素</small></div>
<div class="upload-video-screen"> <div class="upload-video-screen">
<input type="file"> <input type="file">
<i class="icon-image"></i>上传缩略图
<img src="img/avatar.jpg">
<span>
<i class="icon-image"></i>上传缩略图
</span>
</div> </div>
</div> </div>
...@@ -176,7 +182,7 @@ ...@@ -176,7 +182,7 @@
<script src='http://codepen.io/assets/libs/fullpage/jquery.js'></script> <script src='http://codepen.io/assets/libs/fullpage/jquery.js'></script>
<script src="js/index.js"></script>
</body> </body>
</html> </html>
\ 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