Commit c00e6156 authored by xiabin's avatar xiabin

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/common/models/Course.php
#	src/frontend/views/user-center/info.php
parents 6cced394 78a2c50a
......@@ -16,12 +16,12 @@ class Qiniu extends Object
private $accessKey;
private $secretKey;
public $storages;
private $config;
//private $config;
public function __construct($config=[]) {
$this->config = $config;
parent::__construct($config);
}
//public function __construct($config=[]) {
// $this->config = $config;
// parent::__construct($config);
//}
public function setAccessKey($accessKey) {
$this->accessKey = $accessKey;
......@@ -31,8 +31,17 @@ class Qiniu extends Object
$this->secretKey = $secretKey;
}
public function urlsafeBase64Encode($str) {
return str_replace(['+', '/'], ['-', '_'], base64_encode($str));
public function getSkeyUrl($skey)
{
return call_user_func_array([$this, 'getUrl'], explode(':', $skey));
}
public function getUrl($storage, $key) {
if (!isset($this->storages[$storage])) {
return $key;
}
return $this->storages[$storage]['url'].$key;
}
/**
......@@ -67,7 +76,14 @@ class Qiniu extends Object
return \Yii::$app->security->generateRandomString($len);
}
public function generateRandomFilePath($ext='', $len=20)
/**
* 生成随机的文件路径
*
* @param string $ext 文件后缀,默认为原文件后缀,可以指定,包括符号点
* @param int $len 生成文件名(不包含后缀部分)的长度
* @return string
*/
public function generateRandomFilePath($ext='$(ext)', $len=20)
{
return $this->generateRandomDir().'/'.$this->generateRandomName($len).$ext;
}
......
......@@ -42,6 +42,42 @@ class Utils
];
}
/**
* 将 $model->errors 中的错误组织成一维数组返回
*
* @param array $errors
* @return array
*/
public static function fetchErrors($errors)
{
$msgs = [];
foreach ($errors as $k => $v) {
foreach ($v as $msg) {
$msgs[] = $msg;
}
}
return $msgs;
}
/**
* 返回 $model->errors 中的第一条错误
*
* @param array $errors
* @return string
*/
public static function fetchErrorFirst($errors)
{
foreach ($errors as $v) {
foreach ($v as $msg) {
return $msg;
}
}
return '';
}
/**
* 生成4-6位随机数
* @param int $length
......
<?php
/**
* Created by PhpStorm.
* User: pader
* Date: 16/10/11
* Time: 10:30
*/
namespace common\models;
use Qiniu\Storage\UploadManager;
use Yii;
use yii\base\Model;
class AttachUploadForm extends Model
{
const SESS_PREFIX = 'attachpool_';
/**
* @var \yii\web\UploadedFile
*/
public $file;
/**
* 用来保存已上传文件列表的session临时标记
* @var string
*/
public $tmp;
public function formName() {
return '';
}
public function rules()
{
$mb = pow(1024, 2);
return [
['file', 'image', 'skipOnEmpty' => false, 'extensions' => ['png', 'jpg', 'jpeg', 'gif'],
'maxSize'=>$mb * 5, 'minWidth'=>1, 'minHeight'=>1],
['tmp', 'required']
];
}
/**
* 暂存到本地
*
* @return bool|string 上传成功返回文件路径,失败返回 false
*/
public function uploadTmp()
{
if ($this->validate()) {
//'uploads/' . $this->file->baseName . '.' . $this->file->extension
$tmp = tempnam('yunya', 'attach').'.'.$this->file->extension;
return $this->file->saveAs($tmp) ? $tmp : false;
}
return false;
}
/**
* 上传到七牛云
*
* @param string $storage
* @param string $dir
* @return array|bool
* @throws \Exception
*/
public function uploadStorage($storage='public', $dir='content')
{
$result = $this->uploadTmp();
if ($result === false) {
return false;
}
//上传到七牛
/* @var \common\components\Qiniu $qiniu */
$qiniu = Yii::$app->qiniu;
$uploadMgr = new UploadManager();
$key = $dir.'/' . $qiniu->generateRandomFilePath('$(ext)');
$token = $qiniu->getUploadToken($storage, $key);
list($ret, $err) = $uploadMgr->putFile($token, null, $result);
unlink($result); //删除本地临时文件
if ($err !== null) {
$this->addError('file', $err->message());
return false;
} else {
//存储到 session 中记录
$session = Yii::$app->session;
$key = self::SESS_PREFIX.$this->tmp;
$pool = $session->get($key);
if ($pool === null) {
$pool = [];
}
$pool[] = $ret['uuid'];
$session->set($key, $pool);
return $ret;
}
}
/**
* 从临时标记中获取上传的附件uuid列表
*
* @param string $tmp
* @return array|null
*/
public static function getTmpAttachs($tmp)
{
$key = self::SESS_PREFIX.$tmp;
return Yii::$app->session->get($key);
}
public static function clearTmpAttachs($tmp)
{
$key = self::SESS_PREFIX.$tmp;
return Yii::$app->session->remove($key);
}
/**
* 认领并绑定指定内容下的所有附件
*
* @param string $tmp
* @param string $bind 绑定归属
* @return int 绑定附件数量
*/
public static function claimTmpAttachs($tmp, $bind)
{
$attachs = self::getTmpAttachs($tmp);
$count = self::claimAttachs($attachs, $bind);
$count > 0 && self::clearTmpAttachs($tmp);
return $count;
}
/**
* 认领并绑定传入的附件数据
*
* @param $attachData
* @return int
*/
protected static function claimAttachs($attachData, $bind)
{
$count = 0;
if ($attachData) {
foreach ($attachData as $uuid) {
$cl = UploadPools::claimFile($uuid);
if ($cl) {
Yii::$app->db->createCommand()->insert('upload_attachments', [
'bind' => $bind,
'key' => $cl['key'],
'filesize' => $cl['filesize'],
'w' => $cl['w'],
'h' => $cl['h']
])->execute();
++$count;
}
}
}
return $count;
}
}
\ No newline at end of file
......@@ -3,6 +3,8 @@
namespace common\models;
use Yii;
use yii\behaviors\TimestampBehavior;
use yii\db\ActiveRecord;
/**
* This is the model class for table "classes".
......@@ -13,12 +15,19 @@ use Yii;
* @property string $id_name
* @property string $name
* @property string $intro
* @property string $desc
* @property integer $status
* @property integer $created_at
* @property integer $updated_at
*/
class Classes extends \yii\db\ActiveRecord
class Classes extends ActiveRecord
{
const STATUS_UNCHECK = 0;
const STATUS_OK = 1;
const STATUS_FAILED = 2;
const STATUS_LOCKED = 3;
/**
* @inheritdoc
*/
......@@ -27,16 +36,36 @@ class Classes extends \yii\db\ActiveRecord
return 'classes';
}
/**
* @inheritdoc
*/
public function behaviors()
{
return [
[
'class' => TimestampBehavior::className(),
'attributes' => [
ActiveRecord::EVENT_BEFORE_INSERT => ['created_at', 'updated_at'],
ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at'],
]
]
];
}
public function formName() {
return '';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['user_id', 'id_number', 'id_name', 'name', 'intro', 'created_at', 'updated_at'], 'required'],
[['user_id', 'status', 'created_at', 'updated_at'], 'integer'],
[['intro'], 'string'],
[['id_number', 'id_name', 'name'], 'string', 'max' => 64],
[['user_id', 'name', 'intro'], 'required'],
[['user_id', 'status'], 'integer'],
[['intro', 'desc'], 'string'],
[['name'], 'string', 'max' => 30],
];
}
......@@ -50,11 +79,16 @@ class Classes extends \yii\db\ActiveRecord
'user_id' => 'User ID',
'id_number' => 'Id Number',
'id_name' => 'Id Name',
'name' => 'Name',
'intro' => 'Intro',
'status' => '0 未审核 1 审核通过 2 审核不通过 3 锁定 ',
'created_at' => 'Created At',
'updated_at' => 'Updated At',
'name' => '课堂名称',
'intro' => '课堂介绍',
'desc' => '案例资源',
'status' => '0 未审核 1 审核通过 2 审核不通过 3 锁定 '
];
}
public static function getUserClass($userId)
{
return self::find()->select('id, status')->where(['user_id'=>$userId])->asArray()->one();
}
}
......@@ -3,6 +3,8 @@
namespace common\models;
use Yii;
use yii\data\ActiveDataProvider;
use yii\db\ActiveRecord;
/**
* This is the model class for table "classes_teacher".
......@@ -44,7 +46,14 @@ class ClassesTeacher extends \yii\db\ActiveRecord
'teacher_id' => 'Teacher ID',
];
}
/**
* 添加课堂与讲师关联
*
* @param $classId
* @param $teacherId
* @return bool
*/
public static function makeRelation($classId, $teacherId)
{
$model = new self();
......@@ -59,8 +68,15 @@ class ClassesTeacher extends \yii\db\ActiveRecord
}
}
public static function getTeachers($classId)
/**
* 获取指定课堂下所有讲师的简单列表
*
* ID,头像,昵称
*
* @param $classId
* @return array
*/
public static function fetchTeacherNames($classId)
{
$obj = self::find();
$teacherTable = Teacher::tableName();
......@@ -68,5 +84,53 @@ class ClassesTeacher extends \yii\db\ActiveRecord
return $obj->select('t.id,t.user_id,t.name,t.avatar')->join('LEFT JOIN', $teacherTable.' t', 't.id=c.teacher_id')
->from(self::tableName().' c')->where(['c.class_id'=>$classId])->asArray()->all();
}
/**
* 过滤出课堂拥有的讲师ID列表
*
* @param int $classId
* @param array $teacherIds 讲师ID列表数组
* @return array 返回只有传入指定课堂ID拥有的讲师ID列表
*/
public static function filterOwnTeacherIds($classId, $teacherIds)
{
$query = self::find();
$result = $query->select('teacher_id')->where(['class_id'=>$classId, 'teacher_id'=>$teacherIds])->all();
$ids = [];
if ($result) {
foreach ($result as $row) {
$ids[] = $row->teacher_id;
}
}
return $ids;
}
/**
* @param $classId
* @param int $page
* @param int $pageSize
* @return array
*/
public static function fetchTeachers($classId, $page=0, $pageSize=10)
{
$query = Teacher::find()->alias('t')->select('t.id,t.user_id,t.name,t.avatar,t.intro')
->join('LEFT JOIN', self::tableName().' c', 't.id=c.teacher_id')
->where(['c.class_id'=>$classId])->orderBy(['c.teacher_id'=>SORT_DESC])->asArray();
$provider = new ActiveDataProvider([
'query' => $query,
'pagination' => [
'page' => $page,
'pageSize' => $pageSize
]
]);
$data = $provider->getModels();
return $data;
}
}
......@@ -4,6 +4,7 @@ namespace common\models;
use Yii;
use yii\behaviors\TimestampBehavior;
use yii\helpers\HtmlPurifier;
use yii\redis\ActiveRecord;
/**
......@@ -12,7 +13,6 @@ use yii\redis\ActiveRecord;
* @property integer $id
* @property integer $user_id
* @property integer $classed_id
* @property string $avatar
* @property string $name
* @property integer $price
* @property integer $free_time
......@@ -25,12 +25,29 @@ use yii\redis\ActiveRecord;
*/
class Course extends \yii\db\ActiveRecord
{
const STATUS_UNCHECK = 0;
const STATUS_OK = 1;
const STATUS_FAILED = 2;
const STATUS_LOCKED = 3;
public function formName() {
return '';
}
/**
* @inheritdoc
*/
public static function tableName()
public function beforeSave($insert)
{
return 'course';
if (!parent::beforeSave($insert)) {
return false;
}
$this->name = strip_tags($this->name);
$this->intro = HtmlPurifier::process($this->intro);
return true;
}
/**
......@@ -44,10 +61,9 @@ class Course extends \yii\db\ActiveRecord
'attributes' => [
ActiveRecord::EVENT_BEFORE_INSERT => ['created_at', 'updated_at'],
ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at'],
],
// if you're using datetime instead of UNIX timestamp:
// 'value' => new Expression('NOW()'),
],];
]
]
];
}
/**
......@@ -56,11 +72,15 @@ class Course extends \yii\db\ActiveRecord
public function rules()
{
return [
[['user_id', 'classed_id', 'avatar', 'name', 'price', 'free_time', 'intro', 'preview_pic'], 'required'],
[['user_id', 'classed_id', 'price', 'free_time', 'recommend', 'status', 'created_at', 'updated_at'], 'integer'],
[['intro'], 'string'],
[['avatar', 'preview_pic'], 'string', 'max' => 255],
[['name'], 'string', 'max' => 32],
[['name', 'preview_pic'], 'required'],
['name', 'string', 'length'=>[1,60]],
[['user_id', 'class_id'], 'integer'],
['intro', 'string'],
['price', 'integer', 'min'=>0, 'max'=>9999],
['free_time', 'integer', 'min'=>0, 'max'=>15],
['recommend', 'boolean'],
['recommend', 'default', 'value'=>0],
['status', 'in', 'range'=>[0, 1, 2, 3]]
];
}
......@@ -70,19 +90,12 @@ class Course extends \yii\db\ActiveRecord
public function attributeLabels()
{
return [
'id' => 'ID',
'user_id' => 'User ID',
'classed_id' => 'Classed ID',
'avatar' => 'Avatar',
'name' => 'Name',
'price' => 'Price',
'free_time' => 'Free Time',
'intro' => 'Intro',
'preview_pic' => 'Preview Pic',
'recommend' => '0 表示推荐 1推荐',
'status' => '0 未审核 1 审核通过 2 审核不通过 3 锁定 ',
'created_at' => 'Created At',
'updated_at' => 'Updated At',
'teacher' => '讲师',
'name' => '标题',
'price' => '价格',
'free_time' => '免费试看',
'intro' => '课程介绍',
'preview_pic' => '预览图'
];
}
......@@ -97,26 +110,11 @@ class Course extends \yii\db\ActiveRecord
return $result === NULL ? FALSE : TRUE;
}
/**
* 根据课程id获取课程信息
* @param $courseId
* @return array|null|\yii\db\ActiveRecord
*/
public static function findByCourseId($courseId)
public static function getBasicData($id)
{
$tableA = self::tableName();
$tableB = Courseware::tableName();
return self::find()->select("$tableA.id,$tableA.classed_id,$tableA.avatar,$tableA.name,$tableA.price,$tableA.free_time,$tableA.intro,$tableA.preview_pic,$tableA.status,$tableA.created_at,$tableB.name,$tableB.size,$tableB.format")->where("$tableA.id=:id", ['id' => $courseId])->join('left join', $tableB, "$tableA.id=$tableB.course_id")->asArray()->one();
$query = self::find();
return $query->select('id,user_id,class_id,name,price,preview_pic,recommend,status,created_at,updated_at')
->where(['id'=>$id])->asArray()->one();
}
/**
* 获取课程的基本信息
* @param $courseId
* @return array|null|\yii\db\ActiveRecord
*/
public static function findBaseInfoByCourseId($courseId)
{
return self::find()->select("user_id,price,name")->where("id=:id", ['id' => $courseId])->asArray()->one();
}
}
<?php
namespace common\models;
use Yii;
/**
* This is the model class for table "course_teacher".
*
* @property integer $course_id
* @property integer $teacher_id
*/
class CourseTeacher extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'course_teacher';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['course_id', 'teacher_id'], 'required'],
[['course_id', 'teacher_id'], 'integer'],
];
}
}
......@@ -3,6 +3,8 @@
namespace common\models;
use Yii;
use yii\behaviors\TimestampBehavior;
use yii\db\ActiveRecord;
/**
* This is the model class for table "courseware".
......@@ -19,7 +21,7 @@ use Yii;
* @property integer $created_at
* @property integer $updated_at
*/
class Courseware extends \yii\db\ActiveRecord
class Courseware extends ActiveRecord
{
/**
* @inheritdoc
......@@ -28,6 +30,10 @@ class Courseware extends \yii\db\ActiveRecord
{
return 'courseware';
}
public function formName() {
return '';
}
/**
* @inheritdoc
......@@ -35,11 +41,10 @@ class Courseware extends \yii\db\ActiveRecord
public function rules()
{
return [
[['user_id', 'course_id', 'name', 'size', 'time', 'format', 'created_at', 'updated_at'], 'required'],
[['user_id', 'course_id', 'type', 'status', 'created_at', 'updated_at'], 'integer'],
[['user_id', 'course_id', 'name', 'size', 'time', 'format'], 'required'],
[['user_id', 'course_id', 'type', 'status', 'size', 'time'], 'integer'],
[['name'], 'string', 'max' => 128],
[['size', 'time'], 'string', 'max' => 32],
[['format'], 'string', 'max' => 16],
[['format'], 'string', 'max' => 16]
];
}
......@@ -63,6 +68,22 @@ class Courseware extends \yii\db\ActiveRecord
];
}
/**
* @inheritdoc
*/
public function behaviors()
{
return [
[
'class' => TimestampBehavior::className(),
'attributes' => [
ActiveRecord::EVENT_BEFORE_INSERT => ['created_at', 'updated_at'],
ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at'],
]
]
];
}
/**
* 根据id判断数据是否存在
* @param $id
......
......@@ -3,6 +3,8 @@
namespace common\models;
use Yii;
use yii\behaviors\TimestampBehavior;
use yii\db\ActiveRecord;
/**
* This is the model class for table "teacher".
......@@ -15,7 +17,7 @@ use Yii;
* @property integer $created_at
* @property integer $updated_at
*/
class Teacher extends \yii\db\ActiveRecord
class Teacher extends ActiveRecord
{
public static $lastErrors;
......@@ -34,11 +36,29 @@ class Teacher extends \yii\db\ActiveRecord
public function rules()
{
return [
[['user_id', 'name', 'avatar', 'intro', 'created_at', 'updated_at'], 'required'],
[['user_id', 'name', 'avatar', 'intro'], 'required'],
[['user_id', 'created_at', 'updated_at'], 'integer'],
[['intro'], 'string'],
[['name'], 'string', 'min'=>2, 'max' => 64],
[['avatar'], 'string', 'max' => 255],
[['avatar'], 'string', 'max' => 100],
];
}
/**
* @inheritdoc
*/
public function behaviors()
{
return [
[
'class' => TimestampBehavior::className(),
'attributes' => [
ActiveRecord::EVENT_BEFORE_INSERT => ['created_at', 'updated_at'],
ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at'],
]
// if you're using datetime instead of UNIX timestamp:
// 'value' => new Expression('NOW()'),
]
];
}
......@@ -50,9 +70,9 @@ class Teacher extends \yii\db\ActiveRecord
return [
'id' => 'ID',
'user_id' => 'User ID',
'name' => 'Name',
'avatar' => 'Avatar',
'intro' => 'Intro',
'name' => '讲师名称',
'avatar' => '头像',
'intro' => '讲师介绍',
'created_at' => 'Created At',
'updated_at' => 'Updated At',
];
......@@ -63,10 +83,8 @@ class Teacher extends \yii\db\ActiveRecord
$model = new self();
$model->user_id = 0;
$model->name = $name;
$model->avatar = 'avatar/f6/98/c6/_tjy7DgC0641.jpg';
//$model->avatar = 'avatar/f6/98/c6/_tjy7DgC0641.jpg';
$model->intro = '这个家伙很懒,什么也没有写。';
$model->created_at = time();
$model->updated_at = time();
if ($model->save()) {
return $model->toArray();
......
......@@ -47,7 +47,7 @@ class UploadPools extends ActiveRecord
public function validateSkey($attr, $params)
{
if (!preg_match('/^\w+:[\w\.\/]+$/', $this->$attr)) {
if (!preg_match('#^[\w\-]+\:[\w\-\./]+$#i', $this->$attr)) {
$this->addError($attr, "$attr format is not a validate skey.");
}
}
......@@ -56,11 +56,14 @@ class UploadPools extends ActiveRecord
* 获取上传池中的文件
*
* @param string $uuid
* @param false $uuid 只获取未使用的文件
* @return array
*/
public static function getFileInfo($uuid)
public static function getFileInfo($uuid, $unused=true)
{
$file = self::findOne(['uuid'=>$uuid]);
$where = ['uuid'=>$uuid];
$unused && $where['status'] = self::STATUS_UNUSE;
$file = self::findOne($where);
if ($file) {
$file = $file->toArray();
......@@ -137,10 +140,15 @@ class UploadPools extends ActiveRecord
*/
protected static function claimFileConfirm($file)
{
if ($file && $file->status == self::STATUS_UNUSE) {
$file->status = self::STATUS_USED;
$file->save();
return $file->toArray();
$arr = $file->toArray();
list($arr['storage'], $arr['key']) = explode(':', $arr['skey']);
return $arr;
}
return false;
......
......@@ -175,6 +175,24 @@ class User extends ActiveRecord implements IdentityInterface
return $timestamp + $expire >= time();
}
/**
* 获取用户头像 URL
*
* @param string $avatar
* @param string $size 头像尺寸,目前仅支持 m,留空返回原图
* @return string
*/
public static function getAvatarUrl($avatar, $size='m')
{
if (!$avatar) {
return \frontend\assets\AppAsset::getStaticUrl('img/avatarMax.png') ;
}
$url = Yii::$app->qiniu->getUrl('public', $avatar);
return $size ? $url."-{$size}.avatar" : $url;
}
/**
* @inheritdoc
*/
......
<?php
use yii\db\Migration;
class m161010_075253_upload_attachments_init extends Migration
{
public $table = 'upload_attachments';
public function up()
{
$this->createTable($this->table, [
'`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT',
'bind' => $this->string(50)->notNull()->comment('绑定归属'),
'key' => $this->string(255)->notNull()->comment('文件key,如"content/fc/abc.jpg"'),
'filesize' => $this->integer(10)->unsigned()->notNull(),
'w' => $this->smallInteger(5)->unsigned()->defaultValue(0)->comment('图片宽'),
'h' => $this->smallInteger(5)->unsigned()->defaultValue(0)->comment('图片高'),
'upload_time' => $this->integer(10)->unsigned()->notNull()->comment('上传时间'),
'PRIMARY KEY (`id`)',
'KEY `bind` (`bind`)',
], 'ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT=\'上传文件状态标记表\'');
}
public function down()
{
$this->dropTable($this->table);
}
/*
// Use safeUp/safeDown to run migration code within a transaction
public function safeUp()
{
}
public function safeDown()
{
}
*/
}
<?php
/**
* Created by PhpStorm.
* User: pader
* Date: 16/10/13
* Time: 14:47
*/
namespace frontend\components;
use common\models\Classes;
use Yii;
use yii\base\ActionFilter;
use yii\base\Behavior;
/**
* 课堂过滤器,检查是否创建了课堂或者课堂是否通过审核
*
* @package frontend\components
*/
class ClassesFilter extends ActionFilter
{
public $_checkStatus = true;
/**
* @return boolean
*/
public function isCheckStatus() {
return $this->_checkStatus;
}
/**
* @param boolean $checkStatus
*/
public function setCheckStatus($checkStatus) {
$this->_checkStatus = $checkStatus;
}
public function beforeAction($action) {
$uid = Yii::$app->user->getId();
$class = Classes::getUserClass($uid);
if (!$class) {
$this->showAlert(0);
return false;
}
if ($this->_checkStatus && $class['status'] != Classes::STATUS_OK) {
$this->showAlert(1);
return false;
}
if (property_exists(Yii::$app->controller, 'classStatus')) {
Yii::$app->controller->classStatus = $class;
}
return parent::beforeAction($action);
}
public function showAlert($exists)
{
Yii::$app->response->data = Yii::$app->view->renderFile('@app/views/site/error.php', [
'name' => '提示消息',
'message' => $exists ? '您提交的课堂资料尚未通过审核,无法访问此页面!' : '您还没有创建课堂,无法访问此页面!'
]);
}
}
\ No newline at end of file
......@@ -2,11 +2,77 @@
namespace frontend\controllers;
use common\models\Classes;
use frontend\components\ClassesFilter;
use Yii;
use yii\filters\AccessControl;
class ClassesInfoController extends \yii\web\Controller
{
public $layout = 'classCenter';
/**
* @inheritdoc
*/
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => TRUE,
'roles' => ['@'],
]
],
],
'classes' => [
'class' => ClassesFilter::className(),
'checkStatus' => true,
'except' => ['apply']
]
];
}
public function actionIndex()
{
return $this->render('index');
}
/**
* 申请课堂
*
* @return string|\yii\web\Response
*/
public function actionApply()
{
$this->layout = 'userCenter';
$uid = Yii::$app->user->getId();
$model = Classes::findOne(['user_id'=>$uid]);
if (!$model) {
$model = new Classes();
$agreement = 0;
} else {
$agreement = 1;
}
echo $model->status;
if (Yii::$app->request->getIsPost()) {
$model->load(Yii::$app->request->post());
$model->user_id = Yii::$app->user->getId();
$agreement = Yii::$app->request->post('agreement');
if (!$agreement) {
$model->addError('agreement', '必须同意使用协议');
} elseif ($model->validate() && $model->save()) {
return $this->redirect('/classes-info');
}
}
return $this->render('apply', compact('model', 'agreement'));
}
}
<?php
namespace frontend\controllers;
use frontend\models\CoursePublishForm;
use \Yii;
use common\libs\Utils;
use common\models\AttachUploadForm;
use common\models\ClassesTeacher;
use common\models\Course;
use common\models\CourseTeacher;
use common\models\Courseware;
use common\models\UploadPools;
use frontend\components\ClassesFilter;
use Qiniu\Storage\BucketManager;
use Yii;
use yii\filters\AccessControl;
use yii\web\Response;
use yii\web\UploadedFile;
class MyCourseController extends \yii\web\Controller
{
public $classStatus;
public $layout = 'classCenter';
/**
* @inheritdoc
*/
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
//'only' => ['index', 'publish', 'submit'],
'rules' => [
[
'allow' => true,
'roles' => ['@']
]
]
],
'classes' => [
'class' => ClassesFilter::className(),
'checkStatus' => true
]
];
}
public function actionIndex()
{
return $this->render('index');
//return $this->render('index');
}
/**
* 发布课程
*
* @return string
*/
public function actionPublish()
{
/* @var \common\components\Qiniu $qiniu */
......@@ -24,16 +64,216 @@ class MyCourseController extends \yii\web\Controller
//图片上传Token
//$imgName = 'preview/'.$qiniu->genRandomDir().'/'.Yii::$app->security->generateRandomString(20);
$imgPath = 'preview/' . $qiniu->generateRandomFilePath('$(min)$(sec)$(ext)', 8);
$imgPath = 'preview/' . $qiniu->generateRandomFilePath('$(min)$(sec)$(ext)', 12);
$thumbToken = $qiniu->getUploadToken('public', $imgPath);
//视频上传Token
//$videoName = 'source/'.$qiniu->genRandomDir().'/'.Yii::$app->security->generateRandomString(20);
$videoName = 'source/' . $qiniu->generateRandomFilePath('$(ext)');
$videoToken = $qiniu->getUploadToken('video', $videoName, 86400);
return $this->render('publish', compact('thumbToken', 'videoToken'));
}
/**
* 提交并保存课程
*/
public function actionSubmit()
{
$request = Yii::$app->request;
$userId = Yii::$app->user->identity->getId();
$classId = 1;
//验证临时ID
$tmpId = $request->post('tmp');
if (!$tmpId || !preg_match('/^\w{20}$/i', $tmpId)) {
Utils::ajaxResponse(false, '参数错误');
return;
}
//课程数据
$courseData = [
'user_id' => $userId,
'classed_id' => $classId
];
foreach (['name', 'teacher', 'price', 'free_time', 'intro', 'preview'=>'preview_pic', 'recommend'] as $postKey => $key) {
is_int($postKey) && $postKey = $key;
$courseData[$key] = $request->post($postKey);
}
$course = new Course();
$course->load($courseData);
//检查预览图是否存在
$previewFile = UploadPools::getFileInfo($courseData['preview_pic']);
if ($previewFile) {
$course->preview_pic = $previewFile['key'];
} else {
Utils::ajaxResponse(false, '预览图不存在');
return;
}
//验证课程数据
if (!$course->validate()) {
Utils::ajaxResponse(false, join('<br>', Utils::fetchErrors($course->errors)));
return;
}
//过滤已拥有的讲师列表
$teacherIds = $request->post('teacher', []);
$teacherIds = ClassesTeacher::filterOwnTeacherIds($classId, $teacherIds);
//课件数据
$vuid = $request->post('vuid');
$cwData = [
'user_id' => $userId,
'course_id' => 0,
'name' => $vuid, //视频的 uuid
'size' => 0,
'time' => 0,
'format' => ''
];
//处理视频信息
$videoFile = UploadPools::getFileInfo($vuid);
if ($videoFile) {
$qiniu = Yii::$app->qiniu;
$bucket = $qiniu->getStorageConfig($videoFile['storage'], 'bucket');
$auth = $qiniu->getAuthInstance();
$bucketMgr = new BucketManager($auth);
list($ret, $err) = $bucketMgr->stat($bucket, $videoFile['key']);
if ($err !== null) {
Utils::ajaxResponse(false, $err->message());
return;
} else {
$cwData['size'] = $ret['fsize'];
}
//读取视频信息
$avUrl = $videoFile['url'].'?avinfo';
$response = (new \GuzzleHttp\Client())->get($avUrl);
$avInfo = $response->getBody();
if ($avInfo) {
$avInfo = \GuzzleHttp\json_decode($avInfo, true);
} else {
Utils::ajaxResponse(false, '读取视频信息失败');
return;
}
$model = new CoursePublishForm();
return $this->render('publish', compact('model', 'thumbToken', 'videoToken'));
//list($video, $audio) = $avInfo['streams'];
//$format = $avInfo['format'];
$cwData['name'] = $videoFile['key'];
$cwData['time'] = round($avInfo['format']['duration']);
$cwData['format'] = pathinfo($videoFile['key'], PATHINFO_EXTENSION);
} else {
Utils::ajaxResponse(false, '视频文件不存在');
return;
}
//验证课件数据
$courseware = new Courseware();
$courseware->load($cwData);
if (!$courseware->validate()) {
Utils::ajaxResponse(false, join('<br>', Utils::fetchErrors($courseware->errors)));
return;
}
//保存课程数据
if (!$course->save()) {
Utils::ajaxResponse(false, '课程保存失败');
return;
}
//保存课件数据
$courseware->course_id = $course->id;
if (!$courseware->save()) {
Utils::ajaxResponse(false, '课件保存失败');
return;
}
//保存讲师与课程关联数据
foreach ($teacherIds as $teacherId) {
$ct = new CourseTeacher();
$ct->course_id = $course->id;
$ct->teacher_id = $teacherId;
$ct->save();
}
//认领文件
UploadPools::claimFile($vuid);
UploadPools::claimFile($courseData['preview_pic']);
//保存附件关联
AttachUploadForm::claimTmpAttachs($tmpId, 'course:'.$course->id);
Utils::ajaxResponse(true, '', ['course_id'=>$course->id]);
}
public function actionResult()
{
$id = Yii::$app->request->get('id');
$action = Yii::$app->request->get('action');
$userId = Yii::$app->user->identity->getId();
$course = Course::getBasicData($id);
if (!$course) {
throw new \yii\web\NotFoundHttpException;
}
if ($course['user_id'] != $userId) {
throw new \yii\web\ForbiddenHttpException;
}
if ($course['status'] != Course::STATUS_UNCHECK) {
return $this->redirect('home/'.$course['id']);
}
return $this->render('result', compact('course', 'action'));
}
/**
* 上传介绍附件
*
* @throws \Exception
*/
public function actionUpload()
{
$response = Yii::$app->response;
$response->format = Response::FORMAT_JSON;
//暂存到本地
$model = new AttachUploadForm();
//if (!Yii::$app->request->isPost) {
// return ['success'=>false, 'msg'=>'请求方式错误'];
//}
$model->file = UploadedFile::getInstance($model, 'file');
$model->tmp = Yii::$app->request->post('tmp');
$result = $model->uploadStorage();
if ($result === false) {
return ['success'=>false, 'msg'=>Utils::fetchErrorFirst($model->errors)];
}
return ['success'=>true, 'msg'=>'', 'file_path'=>$result['src'], 'key'=>$result['key'], 'uuid'=>$result['uuid']];
}
public function actionTest()
{
print_r(UploadPools::claimFile('2ade5751-8fae-11e6-a1b1-1242ac110005'));
}
}
......@@ -2,27 +2,89 @@
namespace frontend\controllers;
use common\components\Qiniu;
use common\models\Teacher;
use common\models\ClassesTeacher;
use frontend\components\ClassesFilter;
use Yii;
use yii\filters\AccessControl;
use yii\helpers\Html;
class TeacherManagerController extends \yii\web\Controller
{
public $layout = 'user-center';
public $layout = 'classCenter';
public $classStatus;
/**
* @inheritdoc
*/
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => TRUE,
'roles' => ['@'],
]
]
],
'classes' => ClassesFilter::className()
];
}
/**
* 讲师列表
*
* @return string
*/
public function actionIndex()
{
return $this->render('index');
$data = ClassesTeacher::fetchTeachers($this->classStatus['id']);
return $this->render('index', compact('data'));
}
/**
* 添加讲师
*
* @return string
*/
public function actionAdd()
{
$model = new Teacher();
if (Yii::$app->request->getIsPost()) {
$model->load(Yii::$app->request->post());
if ($model->validate()) {
} else {
}
}
/**
* @var $qiniu Qiniu
*/
$qiniu = Yii::$app->qiniu;
$path = 'avatar/'.$qiniu->generateRandomFilePath();
$avatarUploadToken = $qiniu->getUploadToken("public", $path);
return $this->render('add', compact('model', 'avatarUploadToken'));
}
public function actionSimpleTeacherList()
{
//Todo: 假设数据
$classId = 1;
$classId = $this->classStatus['id'];
$response = \Yii::$app->response;
$response->format = \yii\web\Response::FORMAT_JSON;
return ClassesTeacher::getTeachers($classId);
return ClassesTeacher::fetchTeacherNames($classId);
}
/**
......@@ -31,13 +93,13 @@ class TeacherManagerController extends \yii\web\Controller
public function actionAddTeacher()
{
//Todo: 假设数据
$uid = 18;
$classId = 1;
$uid = Yii::$app->user->identity->getId();;
$classId = $this->classStatus['id'];
$response = \Yii::$app->response;
$response = Yii::$app->response;
$response->format = \yii\web\Response::FORMAT_JSON;
$name = strip_tags(\Yii::$app->request->post('name'));
$name = Html::encode(Yii::$app->request->post('name'));
$teacher = Teacher::simpleAddTeacher($name);
if ($teacher) {
......
<?php
/**
* Created by PhpStorm.
* User: pader
* Date: 16/9/28
* Time: 17:43
*/
namespace frontend\models;
class CoursePublishForm extends \yii\base\Model
{
public $name;
public $teacher;
public $video;
public $price;
public $free_time;
public $intro;
public $preview;
public $recommend;
public function rules()
{
return [
];
}
}
\ No newline at end of file
<?php
namespace frontend\models;
use yii\widgets\ActiveForm;
class MyActiveForm extends ActiveForm
{
public $fieldConfig = [
'options' => ['class' => 'cls-part'],
'labelOptions' => ['class' => 'tit', 'style'=>'margin-bottom:0;'],
'inputOptions' => ['class' => 'input-r-control']
];
//public $fieldClass = 'frontend\models\MyActiveField';
}
\ No newline at end of file
<?php
/**
* @var \common\models\Classes $model
* @var int $agreement
*/
use frontend\models\MyActiveForm;
use yii\helpers\Html;
$this->title = '申请课堂';
?>
<div class="send-class apply-class-box">
<div class="tit">申请课堂</div>
<?php if ($model->id) {
if ($model->status == \common\models\Classes::STATUS_UNCHECK) {?>
<p class="bg-info" style="padding:10px;margin-top:10px;">您提交的资料正在等待审核</p>
<?php } elseif ($model->status == \common\models\Classes::STATUS_FAILED) {?>
<p class="bg-danger" style="padding:10px;margin-top:10px;">您提交的课堂资料未通过审核!</p>
<?php } } ?>
<?php $form = MyActiveForm::begin(['id'=>'applyForm', 'options'=>['name'=>'applyClass']]); ?>
<?=$form->field($model, 'name', ['inputOptions'=>['placeholder'=>'请输入课堂名称']])?>
<?=$form->field($model, 'intro')->textInput(['placeholder'=>'示例:面向谁?服务是什么?优势是什么?'])?>
<?=$form->field($model, 'desc', [
'template' => "{label}\n<div class=\"cls-intro-textarea\">{input}</div>\n{hint}\n{error}"
])->textarea(['placeholder'=>'填写分享或培训的案例链接…'])?>
<div class="cls-part">
<div class="checkbox">
<label>
<?=Html::checkbox('agreement', $agreement==1)?>
同意 <a href="#">云涯使用协议</a>及 <a href="#">版权声明</a>
</label>
</div>
<?=$model->getFirstError('agreement')?>
</div>
<div class="btn-box text-center" style="margin-top: 10px; ">
<button type="submit" class="btn btn-save m-l-10">保存</button>
</div>
<?php MyActiveForm::end(); ?>
</div>
<?php
/* @var $this yii\web\View */
/**
* @var $this yii\web\View
* @var \common\models\Classes $model
* @var int $agreement
*/
$this->title = '我的课堂';
?>
<h1>classes-info/index</h1>
<p>
You may change the content of this page by modifying
the file <code><?= __FILE__; ?></code>.
</p>
<div class="class-name">为课堂起个响亮的名字吧</div>
<div class="class-intro">
<div class="col-md-4">
<h3>课程总数</h3>
<p>10<small>讲</small></p>
<a href="#">发布课程</a>
<i class="icon-play"></i>
</div>
<div class="col-md-4">
<h3>今日收益</h3>
<p>192.00<small>元</small></p>
<a href="#">查看账单</a>
<i class="icon-clipboard"></i>
</div>
<div class="col-md-4">
<h3>今日发言</h3>
<p>891<small>条</small></p>
<i class="icon-speech-bubble"></i>
</div>
</div>
\ No newline at end of file
......@@ -47,6 +47,7 @@ $(function() {
JS;
$this->registerJs($js, View::POS_END);
$this->registerCss('[v-cloak] {display:none;}');
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
......
......@@ -6,62 +6,10 @@ use frontend\assets\AppAsset;
/* @var $this \yii\web\View */
/* @var $content string */
AppAsset::register($this);
AppAsset::addCss($this, '@web/assets/css/style.css');
//$assetsUrl = Yii::$app->assetManager->baseUrl.'/assets';
//
//$js = <<<JS
//var global = (function () {
// this.static_url = "$assetsUrl";
//})();
//JS;
//
//$this->registerJs($js, View::POS_HEAD);
$js = <<<JS
$(function() {
var Accordion = function(el, multiple) {
this.el = el || {};
this.multiple = multiple || false;
// Variables privadas
var links = this.el.find(".link");
// Evento
links.on("click", {el: this.el, multiple: this.multiple}, this.dropdown)
};
Accordion.prototype.dropdown = function(e) {
var el = e.data.el, self = $(this), next = self.next();
next.slideToggle();
self.parent().toggleClass("open");
if (!e.data.multiple) {
el.find(".submenu").not(next).slideUp().parent().removeClass("open");
}
};
new Accordion($("#accordion"), false);
});
JS;
$this->registerJs($js, View::POS_END);
$this->beginPage();
$this->beginBody();
$this->beginContent('@app/views/layouts/center.php');
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= \Yii::$app->language ?>">
<head>
<meta charset="<?= Yii::$app->charset ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title><?= $this->title ? Html::encode($this->title) . '-' : '' ?>最课堂</title>
<?= Html::csrfMetaTags() ?>
<?php $this->head() ?>
</head>
<body>
<?php $this->beginBody(); ?>
<?php $this->beginContent('@app/views/layouts/center.php'); ?>
<div class="tp-sidebar">
<div class="logo"><a href="/"><img src="<?= Yii::$app->assetManager->baseUrl ?>/img/logo.png"></a></div>
......@@ -72,13 +20,13 @@ $this->registerJs($js, View::POS_END);
<div class="link"><i class="icon-palette"></i>我的课堂<i class="icon-navigate_next"></i></div>
<ul class="submenu">
<li class="active"><a href="#">课堂概况</a></li>
<li><a href="#">讲师管理</a></li>
<li><a href="/teacher-manager">讲师管理</a></li>
</ul>
</li>
<li>
<div class="link"><i class="icon-ondemand_video"></i>我的课程<i class="icon-navigate_next"></i></div>
<ul class="submenu">
<li><a href="#">发布课程</a></li>
<li><a href="/my-course/publish">发布课程</a></li>
<li><a href="#">课程列表</a></li>
</ul>
</li>
......@@ -107,15 +55,7 @@ $this->registerJs($js, View::POS_END);
</div>
</div>
</div>
<?php $this->endContent(); ?>
<div class="foot navbar-fixed-bottom">
<p><a href="#">隐私权政策</a> - <a href="#">服务条款</a> - <a href="#">地图条款</a></p>
<p>©2016 Zuiketang.com</p>
</div>
<?php $this->endBody(); ?>
</body>
</html>
<?php $this->endPage(); ?>
<?php
$this->endContent();
$this->endBody();
$this->endPage();
......@@ -5,66 +5,12 @@ use frontend\assets\AppAsset;
/* @var $this \yii\web\View */
/* @var $content string */
$this->title = '基本本息';
AppAsset::register($this);
AppAsset::addCss($this, '@web/assets/css/style.css');
$baseUrl = \yii\helpers\Url::base();
//$assetsUrl = Yii::$app->assetManager->baseUrl.'/assets';
//
//$js = <<<JS
//var global = (function () {
// this.static_url = "$assetsUrl";
//})();
//JS;
//
//$this->registerJs($js, View::POS_HEAD);
$js = <<<JS
$(function() {
var Accordion = function(el, multiple) {
this.el = el || {};
this.multiple = multiple || false;
// Variables privadas
var links = this.el.find(".link");
// Evento
links.on("click", {el: this.el, multiple: this.multiple}, this.dropdown)
};
Accordion.prototype.dropdown = function(e) {
var el = e.data.el, self = $(this), next = self.next();
next.slideToggle();
self.parent().toggleClass("open");
if (!e.data.multiple) {
el.find(".submenu").not(next).slideUp().parent().removeClass("open");
}
};
new Accordion($("#accordion"), false);
});
JS;
$this->registerJs($js, View::POS_END);
$this->beginPage();
$this->beginBody();
$this->beginContent('@app/views/layouts/center.php');
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= \Yii::$app->language ?>">
<head>
<meta charset="<?= Yii::$app->charset ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title><?= $this->title ? Html::encode($this->title) . '-' : '' ?>最课堂</title>
<?= Html::csrfMetaTags() ?>
<?php $this->head() ?>
</head>
<body>
<?php $this->beginBody(); ?>
<?php $this->beginContent('@app/views/layouts/center.php'); ?>
<div class="tp-sidebar">
<div class="logo"><a href="<?= \yii\helpers\Url::base() ?>"><img
......@@ -91,7 +37,7 @@ $this->registerJs($js, View::POS_END);
</ul>
<div class="apply-class">
<button class="btn btn-danger">申请课堂</button>
<button class="btn btn-danger" onclick="location.href='/classes-info/apply';">申请课堂</button>
</div>
</div>
......@@ -104,15 +50,7 @@ $this->registerJs($js, View::POS_END);
</div>
</div>
</div>
<?php $this->endContent(); ?>
<div class="foot navbar-fixed-bottom">
<p><a href="#">隐私权政策</a> - <a href="#">服务条款</a> - <a href="#">地图条款</a></p>
<p>©2016 Zuiketang.com</p>
</div>
<?php $this->endBody(); ?>
</body>
</html>
<?php $this->endPage(); ?>
<?php
$this->endContent();
$this->endBody();
$this->endPage();
\ No newline at end of file
......@@ -11,7 +11,7 @@ $this->title = '发布课程';
//AppAsset::addScript($this, '@web/assets/single-lib/plupload/plupload.full.min.js');
AppAsset::addScript($this, '@web/assets/course_publish.js');
$this->registerCss('[v-cloak] {display:none;}');
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>
......@@ -58,15 +58,12 @@ $this->registerCss('[v-cloak] {display:none;}');
</label>
</div>
</div>
</div>
<input type="hidden" name="vuid" value="{{vuid}}" />
<input type="hidden" name="preview_pic" value="{{previewKey}}" />
<div class="cls-part">
<div class="tit">课程介绍</div>
<div class="cls-intro-textarea">
<textarea name="intro" class="input-r-control" placeholder="请输入课程介绍..."></textarea>
<textarea name="intro" class="input-r-control" placeholder="请输入课程介绍..." id="introEditor"></textarea>
</div>
</div>
......@@ -79,14 +76,18 @@ $this->registerCss('[v-cloak] {display:none;}');
<div class="tit">课程属性</div>
<div class="checkbox">
<label>
<input type="checkbox">推荐课程
<input type="checkbox" name="recommend" value="1">推荐课程
</label>
</div>
</div>
<input type="hidden" name="tmp" value="{{tmp}}" />
<input type="hidden" name="vuid" value="{{vuid}}" />
<input type="hidden" name="preview" value="{{previewKey}}" />
<div class="btn-box text-center" style="border-top: 1px solid #e7e7e7; margin-top: 10px; ">
<button class="btn btn-nobg">取消</button>
<button class="btn btn-save m-l-10">保存</button>
<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
<?php
/**
* Created by PhpStorm.
* User: pader
* Date: 16/10/12
* Time: 16:34
*/
$this->title = '课程状态';
?>
<div class="examine-box text-center">
<div class="ico">
<i class="icon-image"></i>
<span>审核中</span>
</div>
<b>您的课程《<?=$course['name']?>》已提交审核,通过后将收到邮件通知</b>
<p>12小时内审核完毕</p>
<a href="/my-course/publish?continue=1&last_id=<?=$course['id']?>" class="btn btn-save">继续发布</a>
</div>
<?php
/**
* @var \common\models\Teacher $model
*/
use frontend\assets\AppAsset;
$this->title = '添加讲师';
AppAsset::addScript($this, '@web/assets/teacher_add.js');
?>
<div class="add-box">
<div class="add-box-main">
<div class="tit">添加讲师</div>
<form method="post" name="teacher" id="teacherForm">
<avatar-upload uptoken="<?=$avatarUploadToken?>"></avatar-upload>
<div class="type-name">
<input type="text" name="name" placeholder="请输入讲师名称...">
</div>
<div class="teacher-info">
<textarea name="intro" placeholder="请输入讲师介绍..."></textarea>
<p class="text-number">20 / 500</p>
</div>
<input type="hidden" name="avatar" value="{{avatar}}">
<div class="btn-box">
<button class="btn btn-nobg">取消</button>
<button class="btn btn-save m-l-10">保存</button>
</div>
</form>
</div>
</div>
\ No newline at end of file
<?php
/* @var $this yii\web\View */
?>
<h1>teacher-manager/index</h1>
<p>
You may change the content of this page by modifying
the file <code><?= __FILE__; ?></code>.
</p>
$this->title = '讲师管理';
?>
<div class="teacher-list">
<?php foreach($data as $row) { ?>
<div class="col-md-3">
<div class="teacher-box">
<img src="<?=\common\models\User::getAvatarUrl($row['avatar'])?>">
<h3><?=$row['name']?></h3>
<p><?=$row['intro']?></p>
<a href="#"><i class="icon-mode_edit"></i></a>
</div>
</div>
<?php } ?>
<div class="col-md-3">
<div class="teacher-box">
<div class="add-teacher">
<a href="/teacher-manager/add">
<i class="icon-add"></i>
<b>添加讲师</b>
</a>
</div>
</div>
</div>
</div>
\ No newline at end of file
......@@ -48,7 +48,7 @@ $url = Yii::$app->qiniu->storages['public']['url'];
<div class="upload-avatar">
<img id="avatar-uploader"
src="<?php echo \yii\bootstrap\Html::encode(Yii::$app->user->identity->avatar === '' ? \frontend\assets\AppAsset::getStaticUrl('img/avatar.jpg') : $url . Yii::$app->user->identity->avatar . '-m.avatar') ?>">
src="<?=\common\models\User::getAvatarUrl(Yii::$app->user->identity->avatar)?>">
</div>
<div class="type-name m-b-20"><?= \yii\bootstrap\Html::encode(Yii::$app->user->identity->username) ?></div>
......
......@@ -181,7 +181,6 @@ ul,
ol,
li {
list-style: none;
float: left;
}
i, em {
......
<template>
<div class="upload-avatar" :id="uploaderId">
<i class="icon-image"></i>
<p>{{text}}</p>
</div>
</template>
<script>
import layer from "layer-js";
import str from "../../utils/string";
import qiniu from "../../utils/qiniu";
var defaultText = "上传头像";
export default {
data() {
return {
uploaderId: "avatarUploader" + str.rand(10),
state: "ready",
text: ""
}
},
props: {
uptoken: String
},
ready() {
this.text = defaultText;
var uploader = new qiniu.Uploader({
browse_button: self.uploaderId,
drop_element: self.uploaderId,
upload_token: self.uptoken,
filters: {
max_file_size: '5mb',
mime_types: [
{title: "图片文件", extensions:"jpg,jpeg,gif,png"}
]
},
flash_swf_url: __CDN_URL__ + 'assets/plupload/Moxie.swf',
dragdrop: true,
multi_selection: false,
auto_start: true,
init: {
'FilesAdded': function(up, files) {
plupload.each(files, function(file) {
// self.videoSize = filesize(file.origSize, {fixed:2, spacer:' '}).human('si');
// self.videoName = file.name;
});
self.state = 'uploading';
up.start();
self.text = "上传中..";
},
//每个文件上传前
'BeforeUpload': function(up, file) {
},
'UploadProgress': function(up, file) {
self.text = "上传中.." + file.percent + "%";
},
//每个文件上传成功后
'FileUploaded': function(up, file, info) {
self.text = "上传完成";
setTimeout(function() {
self.text = file.name;
}, 1000);
var response = $.parseJSON(info.response);
self.$dispatch("thumb-uploaded", file.name, response);
},
'Error': function(up, err) {
var msg = "";
if (err.response) {
var data = $.parseJSON(err.response);
msg += "<br>" + data.error;
}
layer.alert("图片 " + err.file.name + " 上传失败!" + msg, {icon:5, title:"上传失败"});
self.state = "error";
},
//队列文件处理完毕后
'UploadComplete': function() {
self.state = 'completed';
}
}
});
}
}
</script>
......@@ -9,6 +9,7 @@
<script>
import layer from "layer-js";
import str from "../../utils/string";
import qiniu from "../../utils/qiniu";
var defaultText = "上传缩略图";
......@@ -28,82 +29,78 @@ export default{
var self = this;
require.ensure(["../../utils/qiniu"], function() {
var qiniu = require("../../utils/qiniu");
var uploader = new qiniu.Uploader({
browse_button: self.uploaderId,
drop_element: self.uploaderId,
upload_token: self.uptoken,
filters: {
max_file_size: '5mb',
mime_types: [
{title: "图片文件", extensions:"jpg,jpeg,gif,png"}
]
},
flash_swf_url: __CDN_URL__ + 'assets/plupload/Moxie.swf',
dragdrop: true,
multi_selection: false,
auto_start: true,
init: {
'FilesAdded': function(up, files) {
plupload.each(files, function(file) {
var uploader = new qiniu.Uploader({
browse_button: self.uploaderId,
drop_element: self.uploaderId,
upload_token: self.uptoken,
filters: {
max_file_size: '5mb',
mime_types: [
{title: "图片文件", extensions:"jpg,jpeg,gif,png"}
]
},
flash_swf_url: __CDN_URL__ + 'assets/plupload/Moxie.swf',
dragdrop: true,
multi_selection: false,
auto_start: true,
init: {
'FilesAdded': function(up, files) {
plupload.each(files, function(file) {
// self.videoSize = filesize(file.origSize, {fixed:2, spacer:' '}).human('si');
// self.videoName = file.name;
});
self.state = 'uploading';
up.start();
self.text = "上传中..";
},
//每个文件上传前
'BeforeUpload': function(up, file) {
},
'UploadProgress': function(up, file) {
self.text = "上传中.." + file.percent + "%";
},
//每个文件上传成功后
'FileUploaded': function(up, file, info) {
self.text = "上传完成";
});
setTimeout(function() {
self.text = file.name;
}, 1000);
self.state = 'uploading';
up.start();
self.text = "上传中..";
},
//每个文件上传前
'BeforeUpload': function(up, file) {
},
'UploadProgress': function(up, file) {
self.text = "上传中.." + file.percent + "%";
},
//每个文件上传成功后
'FileUploaded': function(up, file, info) {
self.text = "上传完成";
var response = $.parseJSON(info.response);
self.$dispatch("thumb-uploaded", file.name, response);
},
'Error': function(up, err) {
var msg = "";
setTimeout(function() {
self.text = file.name;
}, 1000);
if (err.response) {
var data = $.parseJSON(err.response);
msg += "<br>" + data.error;
}
var response = $.parseJSON(info.response);
self.$dispatch("thumb-uploaded", file.name, response);
},
'Error': function(up, err) {
var msg = "";
layer.alert("图片 " + err.file.name + " 上传失败!" + msg, {icon:5, title:"上传失败"});
self.state = "error";
},
//队列文件处理完毕后
'UploadComplete': function() {
self.state = 'completed';
if (err.response) {
var data = $.parseJSON(err.response);
msg += "<br>" + data.error;
}
}
});
//上传中禁止重选文件
self.$watch("state", function(val, old) {
if (val == "uploading") {
uploader.disableBrowse();
} else {
uploader.disableBrowse(false);
layer.alert("图片 " + err.file.name + " 上传失败!" + msg, {icon:5, title:"上传失败"});
self.state = "error";
},
//队列文件处理完毕后
'UploadComplete': function() {
self.state = 'completed';
}
}
});
self.$dispatch("thumb-upload-state-change", val, old);
});
//上传中禁止重选文件
self.$watch("state", function(val, old) {
if (val == "uploading") {
uploader.disableBrowse();
} else {
uploader.disableBrowse(false);
}
uploader.init();
self.$dispatch("thumb-upload-state-change", val, old);
});
uploader.init();
}
}
</script>
......@@ -28,6 +28,7 @@
import filesize from "file-size";
import layer from "layer-js";
import str from "../../utils/string";
import qiniu from "../../utils/qiniu";
export default {
data() {
......@@ -52,8 +53,7 @@ export default {
var self = this,
startTime;
require.ensure(["../../utils/qiniu", "moment"], function() {
var qiniu = require("../../utils/qiniu");
require.ensure(["moment"], function() {
var moment = require("moment");
moment.locale('zh-cn', {
......
......@@ -5,8 +5,11 @@ var Vue = require('vue');
var videoUpload = require('../components/uploader/video-upload.vue');
var thumbUpload = require('../components/uploader/thumb-upload.vue');
var form = document.forms["coursePublish"];
var layer = require("layer-js");
var Simditor = require("../utils/simditor");
var str = require("../utils/string");
require('jquery-validation');
//$.ajaxSetup({
// beforeSend: function() {
......@@ -16,6 +19,8 @@ var layer = require("layer-js");
// }
//});
var form = document.forms["coursePublish"];
var vm = new Vue({
el: "#publishMain",
data: {
......@@ -24,7 +29,8 @@ var vm = new Vue({
teachers: [],
atState: 0,
addTeacherName: "",
checkedTeachers: []
checkedTeachers: [],
tmp: str.rand(20)
},
components: {
videoUpload: videoUpload,
......@@ -74,23 +80,101 @@ var vm = new Vue({
});
this.$on("thumb-uploaded", function(name, data) {
self.previewKey = data.key;
self.previewKey = data.uuid;
});
}
});
require.ensure("jquery-validation", function() {
require('jquery-validation');
var validator = $(form).validate({
//debug: true,
//errorClass: "",
//validClass: "",
ignore: "",
rules: {
name: {
required: true
},
preview: {
required: true
},
vuid: {
required: true
}
},
messages: {
name: {
required: "请填写标题"
},
preview: {
required: "必须上传缩略图"
},
vuid: {
required: "您还没有上传视频"
}
},
errorPlacement: function(error, element) {
var text = error.text();
var org = element.get(0);
var to = null;
if (org == form.vuid) {
to = $(".upload-video-btn").get(0);
} else 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/submit", data, function(t) {
layer.close(idx);
if (t.status) {
location.replace("/my-course/result?id=" + t.data.course_id + "&action=publish");
} else {
alert(t.message);
}
}, "json");
$(form).validate({
debug: true,
rules: {
name: {
required: true
return false;
}
},
submitHandler: function() {
return false;
}
});
});
});
var doValidate = function() { validator.form(); };
this.$watch("vuid", doValidate);
this.$watch("previewKey", doValidate);
var editor = new Simditor({
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: '正在上传文件'
}
});
}
});
\ No newline at end of file
/**
* Created by pader on 16/10/13.
*/
var Vue = require('vue');
var avatarUploader = require('../components/uploader/avatar-upload.vue');
var vm = new Vue({
el: "#teacherForm",
data: {
avatar: ""
},
components: {
"avatar-upload": avatarUploader
},
ready: function() {
var form = document.forms["teacher"];
$(form).submit(function() {
var name = $.trim(form.name.value);
var intro = $.trim(form.intro.value);
if (name == "") {
form.name.focus();
return false;
}
return false;
});
}
});
\ No newline at end of file
/**
* Created by pader on 16/9/30.
*
* 文件相关辅助函数
* 文件、路径、文件名称、文件大小等与文件相关的能用辅助函数
*/
module.exports = {
/**
* 根据输入的字节数显示可读形式的文件大小
*
* @param {int} bytes
* @returns {string}
*/
readableSize: function(bytes) {
var filesizeUnits = ['Bytes','KB','MB','GB','TB','PB','EB','ZB','YB'];
var base = 1024;
if (bytes) {
var i = 0;
if (bytes >= base) {
var a = bytes;
while(1) { a /= base; i++; if(a < base) break; }
}
return parseFloat((bytes/Math.pow(base,i)).toFixed(2)) + ' ' + filesizeUnits[i];
} else return '0 Byte';
}
};
\ No newline at end of file
/**
* Created by pader on 16/10/10.
*/
require("../../node_modules/simditor/styles/simditor.css");
module.exports = require("simditor");
\ No newline at end of file
......@@ -43,6 +43,7 @@
"jquery": "~2.2.2",
"jquery-validation": "^1.15.1",
"moment": "^2.13.0",
"simditor": "^2.3.6",
"video.js": "^5.11.7",
"vue": "^1.0.8"
}
......
......@@ -21,7 +21,8 @@ var entry = {
user_center_browse_record: [js_dir + '/user-center/browse_record.js'],
user_center_purchased_course: [js_dir + '/user-center/purchased_course.js'],
home_index: [js_dir + '/home/index.js'],
course_publish: [js_dir + '/my-course/publish.js']
course_publish: [js_dir + '/my-course/publish.js'],
teacher_add: [js_dir + '/teacher-manager/add.js']
};
var config = {
......@@ -44,7 +45,7 @@ var config = {
loader: 'vue'
},
{
test: /\.(ttf|eot|svg|woff(2)?)(\?[a-z0-9=&.]+)?$/,
test: /\.(ttf|eot|svg|woff(2)?)(\?[\w\-_#=&.]+)?$/,
loader: 'file-loader'
},
{test: require.resolve("jquery"), loader: "expose?$!expose?jQuery"}
......
......@@ -58,6 +58,15 @@
<glyph unicode="&#xe5c5;" glyph-name="arrow_drop_down" d="M298 512.667h428l-214-214z" />
<glyph unicode="&#xe5c7;" glyph-name="arrow_drop_up" d="M298 340.667l214 214 214-214h-428z" />
<glyph unicode="&#xe63a;" glyph-name="ondemand_video" d="M682 468.667l-298-170v342zM896 212.667v512h-768v-512h768zM896 810.667c46 0 86-38 86-86l-2-512c0-46-38-84-84-84h-214v-86h-340v86h-214c-48 0-86 38-86 84v512c0 48 38 86 86 86h768z" />
<glyph unicode="&#xe87d;" glyph-name="favorite" d="M512 28.667l-62 56c-220 200-364 330-364 492 0 132 102 234 234 234 74 0 146-36 192-90 46 54 118 90 192 90 132 0 234-102 234-234 0-162-144-294-364-494z" />
<glyph unicode="&#xe87e;" glyph-name="favorite_border" d="M516 146.667c204 184 338 306 338 430 0 86-64 148-150 148-66 0-130-42-152-100h-80c-22 58-86 100-152 100-86 0-150-62-150-148 0-124 134-246 338-430l4-4zM704 810.667c132 0 234-102 234-234 0-162-144-292-364-492l-62-56-62 54c-220 200-364 332-364 494 0 132 102 234 234 234 74 0 146-36 192-90 46 54 118 90 192 90z" />
<glyph unicode="&#xe8ac;" glyph-name="power_settings_new" d="M760 718.667c82-70 136-176 136-292 0-212-172-384-384-384s-384 172-384 384c0 116 54 222 136 292l60-60c-66-54-110-138-110-232 0-166 132-298 298-298s298 132 298 298c0 94-42 176-110 230zM554 810.667v-426h-84v426h84z" />
<glyph unicode="&#xe8e8;" glyph-name="verified_user" d="M426 212.667l342 342-60 60-282-280-110 110-60-60zM512 896.667l384-172v-256c0-236-164-458-384-512-220 54-384 276-384 512v256z" />
<glyph unicode="&#xe900;" glyph-name="comment-empty" d="M507.81 156.612c-23.569 0-46.531 2.128-68.877 5.822l-161.413-97.942v163.047c-84.166 59.097-138.174 149.705-138.174 251.474 0 178.059 164.968 322.402 368.464 322.402 203.483 0 368.46-144.347 368.46-322.402 0-178.077-164.98-322.402-368.46-322.402v0zM507.81 755.361c-178.063 0-322.406-123.735-322.406-276.348 0-93.646 54.477-176.269 137.602-226.246l-1.452-106.824 108.407 65.174c24.973-5.327 50.947-8.458 77.85-8.458 178.068 0 322.402 123.713 322.402 276.353-0.001 152.614-144.335 276.348-322.403 276.348v0z" />
<glyph unicode="&#xe901;" glyph-name="comment-full" d="M511.998 895.156c-264.907 0-479.664-158.78-479.664-390.665 0-132.522 70.304-250.515 179.871-327.46l-49.468-198.586 259.61 113.772c29.065-4.817 58.982-7.583 89.645-7.583 264.907 0 479.674 187.959 479.674 419.853-0.004 231.887-214.781 390.668-479.668 390.668v0z" />
<glyph unicode="&#xe902;" glyph-name="fav-empty" d="M509.607 816.886c9.083 0 17.328-4.84 20.996-12.332l97.262-197.442c5.614-11.404 16.664-19.359 29.438-21.216l223.739-32.552c8.421-1.216 15.604-6.851 18.233-14.255 2.52-7.184 0.596-15.062-5.085-20.587l-163.938-160.114c-8.95-8.751-12.995-21.171-10.917-33.37l38.012-222.061c1.325-7.737-2.165-15.426-8.906-19.978-4.088-2.741-8.862-4.156-13.813-4.156-4.023 0-7.999 0.972-11.425 2.74l-195.055 102.765c-5.768 3.006-12.156 4.553-18.542 4.553-6.365 0-12.728-1.547-18.519-4.553l-194.833-102.678c-3.559-1.855-7.602-2.828-11.669-2.828-4.862 0-9.723 1.459-13.547 4.023-6.962 4.685-10.476 12.42-9.128 20.155l38.012 222.017c2.078 12.199-1.988 24.62-10.939 33.37l-163.96 160.17c-5.635 5.492-7.558 13.348-5.061 20.454 2.631 7.481 9.812 13.117 18.299 14.332l223.674 32.552c12.839 1.857 23.868 9.814 29.481 21.216l97.195 197.397c3.714 7.525 11.979 12.377 20.995 12.377zM509.607 855.096c-24.044 0-45.923-13.226-56.177-33.956l-97.24-197.442-223.674-32.542c-22.983-3.304-42.101-18.718-49.482-39.659-7.381-21.048-1.812-44.232 14.432-60.033l163.916-160.126-38.012-222.017c-3.868-22.408 6.032-44.82 25.459-57.947 10.697-7.116 23.204-10.785 35.757-10.785 10.299 0 20.664 2.475 30.056 7.337l194.988 102.721 195.033-102.719c9.369-4.862 19.713-7.337 29.99-7.337 12.575 0 25.082 3.669 35.779 10.785 19.426 13.127 29.305 35.538 25.461 57.947l-38.013 222.017 163.938 160.126c16.221 15.812 21.811 38.985 14.408 60.033-7.403 20.941-26.519 36.354-49.503 39.659l-223.674 32.541-97.241 197.442c-10.187 20.729-32.111 33.956-56.2 33.956v0z" />
<glyph unicode="&#xe903;" glyph-name="fav-full" d="M507.612 890.572c-11.287 0-20.219-3.343-26.677-10.176-6.577-6.687-11.667-14.873-15.132-24.178l-102.462-236.562-275.021-24.689c-6.458-1.237-12.406-4.097-17.739-8.794-5.339-4.726-8.698-11.169-9.812-19.481-1.236-8.186 0.755-16.26 5.718-24.201 5.091-7.924 11.16-15.12 18.222-21.711l9.812-8.312 22.705-19.479c9.304-7.922 19.598-16.741 31.255-26.411l35.104-29.531c27.913-23.551 59.289-50.346 94.4-80.363l-30.262-123.563c-4.214-15.869-8.19-31.375-12.031-46.764-3.839-15.262-7.33-29.263-10.299-41.936-2.979-12.649-5.583-23.429-7.933-32.611l-4.468-17.248c-1.25-5.213-0.618-10.419 1.733-15.384 2.36-4.968 6.078-9.306 11.169-12.771 4.965-3.609 10.659-5.718 16.861-6.71 1.381-0.195 2.75-0.268 4.116-0.268 4.775 0 9.492 1.163 14.129 3.367 2.979 1.259 8.809 4.213 17.371 8.818 8.677 4.7 18.849 10.662 30.759 17.733 11.787 7.077 25.069 14.635 39.583 22.946 14.507 8.187 29.264 16.499 44.021 24.689 34.5 19.355 72.701 41.43 114.884 66.115l232.342-134.1 12.916-4.822c5.575-2.107 9.909-3.1 12.889-3.1 8.941 0 16.873 1.986 24.071 5.693 7.061 3.85 9.805 11.65 7.935 23.452-0.619 2.353-1.731 8.064-3.467 17.248l-6.71 32.972c-2.728 13.039-5.572 27.43-8.43 43.3-2.979 15.89-6.322 31.761-9.802 47.63-7.814 37.723-16.62 79.786-26.783 126.154l184.337 164.126c7.689 8.94 14.016 16.381 19.103 22.581s7.57 13.399 7.57 21.589c0 8.794-2.359 15.263-7.077 19.478-4.844 4.098-13.152 7.558-24.931 10.542l-275.142 25.559-99.63 236.561c-1.236 2.352-2.847 5.208-4.956 8.794-2.106 3.465-4.588 7.077-7.572 10.541-2.978 3.607-6.686 6.707-11.032 9.301-4.476 2.618-9.686 3.976-15.637 3.976z" />
<glyph unicode="&#xe904;" glyph-name="zan-empty" d="M684.937 22.109c-158.554 0-297.911 0-351.748 0-10.176-8.954-23.491-14.429-38.115-14.429h-173.274c-31.899 0-57.757 25.84-57.757 57.713v432.851c0 31.874 25.859 57.713 57.757 57.713h173.275c16.772 0 31.827-7.188 42.379-18.596 35.875 29.206 130.893 120.127 130.893 263.878 0 86.12 86.635 86.57 86.635 86.57s187.713 26.604 187.713-201.998c0-49.597-28.88-129.854-28.88-129.854h43.319c0 0 202.152 33.816 202.152-216.425-0.001-250.243-70.842-317.424-274.349-317.424zM295.074 469.388c0 15.938-12.932 28.857-28.88 28.857h-115.516c-15.949 0-28.88-12.919-28.88-28.857v-375.137c0-15.937 12.932-28.857 28.88-28.857h115.515c15.949 0 28.88 12.92 28.88 28.857v375.137zM771.575 498.245h-173.275c0 0 86.637 85.217 86.637 201.997s-82.574 129.858-115.515 129.858c-32.94 0-43.319-10.371-43.319-28.858 0-215.975-173.272-331.853-173.272-331.853v-389.566c0 0 190.869 0 346.545 0s202.152 52.752 202.152 245.282c0 192.528-129.953 173.14-129.953 173.14z" />
<glyph unicode="&#xe905;" glyph-name="zan-full" horiz-adv-x="1025" d="M43.040 558.32c-23.728 0.048-43-19.152-43.040-42.88 0-0.136 0-0.264 0-0.4v-520c-0.048-23.632 19.008-42.864 42.64-43.040 1.040 0 1.92 0.56 2.96 0.56h120.4v605.68h-121.2c-0.64-0.24-1.2 0.080-1.76 0.080zM1022.4 466.56c1.616 25.912-4.72 51.704-18.16 73.92-21.704 35.392-59.56 57.696-101.040 59.52-2.6 0.832-5.28 1.392-8 1.68h-238.16c16.696 48.112 25.216 98.68 25.2 149.6-0.080 33.288-3.752 66.464-10.96 98.96h-0.72c-14.392 66.776-80.192 109.232-146.968 94.832-57.808-12.456-98.704-64.104-97.592-123.232 0-2.16 0.56-4.24 0.64-6.4-0.616-111.104-72.096-209.408-177.6-244.24v-618.72h561.92c23.968-0.136 47.456 6.704 67.6 19.68 18.096 12.032 32.744 28.576 42.48 48 0.8 1.040 1.36 2.16 2.080 3.28s0.4 0.56 0.56 0.88v0c2.568 3.672 4.536 7.72 5.84 12l92.080 412.48c0.856 4.128 1.104 8.36 0.72 12.56 0 0.56 0 1.12 0 1.68s0.24 2.32 0.080 3.52z" />
<glyph unicode="&#xe90d;" glyph-name="fingerprint" d="M636 0.667h-6c-68 18-112 44-158 90-60 60-92 138-92 222 0 70 58 126 130 126s132-56 132-126c0-46 38-82 88-82s90 36 90 82c0 160-140 292-310 292-122 0-232-68-282-172-16-34-24-76-24-120 0-34 2-86 28-154 9.157-27.471-30.939-36.654-40-14-20 56-32 110-32 168 0 52 10 98 30 138 56 120 182 198 320 198 194 0 352-152 352-336 0-70-60-124-132-124s-130 54-130 124c0 46-40 84-90 84s-88-38-88-84c0-72 28-140 80-192 40-40 80-62 140-78 12-2 16-14 14-26-2-10-12-16-20-16zM530 312.667c0-97.515 80.578-182 192-182 19.928 0 65.546 14.722 70-12 2-12-6-24-18-26-24-4-46-4-52-4-50 0-96 12-132 38-64 44-102 112-102 186 0 12 10 22 22 22s20-10 20-22zM416 8.667c-6 0-10 2-14 6-38 38-58 62-86 114-30 52-46 116-46 184 0 126 108 230 242 230s242-104 242-230c0-12-10-20-22-20s-22 8-22 20c0 104-88 188-198 188s-198-84-198-188c0-62 12-118 38-164 28-50 48-70 80-104 8-8 8-22 0-30-4-4-10-6-16-6zM150 524.667c-17.624 0-27.785 15.691-18 32 42 60 96 108 160 140 134 70 306 70 440 0 64-32 118-78 160-138 6-10 4-24-6-30s-24-4-30 6c-38 54-86 94-144 124-122 62-278 64-400 0-58-30-108-72-146-126-4-6-10-8-16-8zM760 748.667c-4 0-8 0-10 2-82 42-154 60-238 60s-166-20-238-60c-23.381-14.029-43.278 24.033-20 38 80 44 166 64 258 64 90 0 170-20 258-64 18.211-10.927 10.406-40-10-40z" />
</font></defs></svg>
\ No newline at end of file
......@@ -21,10 +21,7 @@ a,a:hover,a:link {
.yun-login-btn li a {
color: #333;
}
.yun-login-btn li:last-child a{
background-color: #34bf49;
color: #fff;
}
.z-m-center {
......
@charset "utf-8";
body {
font-family: "Microsoft YaHei","Helvitica Neue", Helvitica, Arial, "Hiragino Sans GB", "Arial Regular", "Microsoft JhengHei", sans-serif;
background-color: #fafafa;
}
a,a:hover,a:link {
text-decoration: none;
}
/*font*/
@font-face {
font-family: 'icomoon';
src: url('fonts/icomoon.eot?uyryw3');
src: url('fonts/icomoon.eot?uyryw3#iefix') format('embedded-opentype'),
url('fonts/icomoon.ttf?uyryw3') format('truetype'),
url('fonts/icomoon.woff?uyryw3') format('woff'),
url('fonts/icomoon.svg?uyryw3#icomoon') format('svg');
font-weight: normal;
font-style: normal;
}
[class^="icon-"], [class*=" icon-"] {
/* use !important to prevent issues with browser extensions that change fonts */
font-family: 'icomoon' !important;
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
/* Better Font Rendering =========== */
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.icon-comment-empty:before {
content: "\e900";
}
.icon-comment-full:before {
content: "\e901";
}
.icon-fav-empty:before {
content: "\e902";
}
.icon-fav-full:before {
content: "\e903";
}
.icon-zan-empty:before {
content: "\e904";
}
.icon-zan-full:before {
content: "\e905";
}
.navbar-main {
background-color: #fff;
box-shadow: 0 0 30px rgba(0,0,0,.05);
}
.logo {
line-height: 60px;
margin-left: 30px;
font-size: 16px;
}
.logo a {
color: #333;
}
.yun-login-btn {
margin-right: 30px;
margin-bottom: 0;
}
.yun-login-btn,.yun-login-btn li {
list-style: none;
}
.yun-login-btn li {
display: inline-block;
height: 60px;
line-height: 60px;
padding: 0 10px;
}
.yun-login-btn li a {
color: #333;
display: block;
}
.c-menu-item {
margin-bottom: 0;
margin-left: 20px;
}
.c-menu-item li {
display: inline-block;
height: 60px;
line-height: 60px;
margin: 0 10px 0;
padding: 0;
}
.c-menu-item li a {
display: block;
height: 60px;
color: #333;
}
.c-menu-item li.active a {
display: block;
border-bottom: 4px solid #ef2f11;
}
/* Swiper幻灯 */
.swiper-container {
width: 100%;
height: 500px;
}
.swiper-slide {
text-align: center;
font-size: 18px;
background: #fff;
/* Center slide text vertically */
display: -webkit-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-box-pack: center;
-ms-flex-pack: center;
-webkit-justify-content: center;
justify-content: center;
-webkit-box-align: center;
-ms-flex-align: center;
-webkit-align-items: center;
align-items: center;
}
/*视频列表*/
.v-list {
margin-top: 20px;
}
.v-main-box {
background-color: #fff;
height: 300px;
margin-bottom: 20px;
-webkit-transition: all 0.4s ease;
-o-transition: all 0.4s ease;
transition: all 0.4s ease;
}
.v-screen {
position: relative;
width: 100%;
height: 200px;
overflow: hidden;
}
.v-screen a {
position: relative;
display: block;
}
.v-screen > span {
position: absolute;
display: inline-block;
width: 30px;
height: 30px;
left: 10px;
top:10px;
}
.v-screen > span > img {
width: 30px;
height: 30px;
border-radius: 100%;
}
.v-tit,
.v-price,
.v-foot {
padding: 0 10px;
}
.v-tit {
height: 40px;
line-height: 40px;
font-size: 14px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.v-tit a {
color: #333333;
}
.v-price {
color: #ef2f11;
padding-bottom: 10px;
}
.v-foot {
position: relative;
font-size: 12px;
color: #999;
}
.v-detail {
position: absolute;
right: 10px;
bottom: 0;
color: #bbbbbb;
}
.v-detail span {
padding-left: 10px;
}
.v-main-box:hover {
cursor: pointer;
box-shadow: 0 0 20px rgba(0,0,0,.12);
}
.v-main-box:hover .play-mask {
display: inline-block;
line-height: 200px;
}
.play-mask {
display: none;
position: absolute;
background-color: rgba(0,0,0,.3);
width: 100%;
height: 200px;
left: 0;
top: 0;
text-align: center;
line-height: 200px;
font-size: 64px;
color: #fff;
-webkit-transition: all 0.4s ease;
-o-transition: all 0.4s ease;
transition: all 0.4s ease;
}
.col-md-3 {
padding-right: 10px;
padding-left: 10px;
}
.get-more {
margin: 0 auto;
width: 30%;
text-align: center;
font-size: 12px;
}
.get-more a {
display: block;
height: 45px;
line-height: 45px;
background-color: #fff;
color: #999;
}
.copyright {
height: 40px;
line-height: 40px;
background-color: #fff;
text-align: center;
color: #999;
font-size: 12px;
border-top: 1px solid #f3f3f3;
}
.m-t-20 {
margin-top: 20px;
}
/*视频内容页面*/
.cnt-tit {
position: relative;
height: 22px;
font-size: 22px;
margin: 30px 0;
}
.tit-share {
position: absolute;
display: inline-block;
height: 22px;
right: 0;
top: 0;
}
.post-icons {
width: 25px;
height: 22px;
float: left;
margin-left: 16px;
background: url(../img/share_tit.png) no-repeat;
}
.weibo {
background-position: -25px 0;
}
.qzone {
background-position: -50px 0;
}
.weibo:hover {
background-position: -25px -22px;
}
.qzone:hover {
background-position: -50px -22px;
}
.wechat:hover {
background-position: 0 -22px;
}
.video-detail-info {
position: relative;
height: 80px;
background-color: #fff;
border: 1px solid #f3f3f3;
border-top: none;
}
.video-teacher {
padding: 15px;
}
.video-teacher a {
color: #333;
}
.video-teacher img{
float: left;
width: 50px;
height: 50px;
border-radius: 100%;
margin-right: 10px;
}
.video-teacher p {
font-size: 16px;
margin: 5px 0 0;
}
.video-teacher span {
font-size: 12px;
color: #999;
}
.video-sm-info {
position: absolute;
height: 80px;
line-height: 80px;
right: 15px;
top: 0;
}
.video-sm-info a {
display: inline-block;
position: relative;
margin-right: 15px;
vertical-align: middle;
font-size: 12px;
color: #999;
padding-left: 35px;
height: 30px;
line-height: 30px;
}
.video-sm-info a i {
position: absolute;
width: 30px;
height: 30px;
text-align: center;
line-height: 30px;
top: 0;
left: 0;
font-size: 30px;
}
/*video detail*/
.warp-box {
background-color: #fff;
margin-top: 40px;
padding: 20px 0;
border-top: 1px solid #f3f3f3;
}
.video-description .title {
font-size: 16px;
color: #333;
padding-bottom: 10px;
}
.video-description .text {
color: #999;
}
.video-comment {
margin-top: 30px;
}
.video-comment .title {
font-size: 16px;
color: #333;
padding-bottom: 10px;
}
.video-comment .title small {
font-size: 12px;
color: #999;
padding-left: 10px;
}
.comment-login {
display: block;
width: 100%;
height: 100px;
text-align: center;
line-height: 100px;
border: 1px solid #e5e6e8;
}
.comment-box {
position: relative;
padding-left: 60px;
margin-top: 20px;
}
.comment-head img {
width: 50px;
height: 50px;
border-radius: 100%;
}
.comment-head {
position: absolute;
left: 0;
top: 0;
padding-right: 10px;
}
.comment-input {
display: block;
}
.comment-input textarea {
height: 50px;
}
.m-t-10 {
margin-top: 10px;
}
.user-h {
padding-right: 10px;
}
.user-h img {
height: 50px;
width: 50px;
border-radius: 100%;
}
.user-i span,
.user-i span small {
font-size: 14px;
color: #999;
}
.user-i span small {
padding-left: 5px;
}
.user-i p {
padding-top: 5px;
}
.comment-main-list {
margin-bottom: 40px;
}
.teacher-info {
margin: 40px auto;
}
.teacher-info img {
width: 100px;
height: 100px;
border-radius: 100%;
}
.teacher-info h3 {
font-size: 18px;
}
.teacher-info p {
max-width: 500px;
margin: 0 auto;
color: #666;
}
\ No newline at end of file
......@@ -232,6 +232,24 @@ i, em {
-moz-osx-font-smoothing: grayscale;
}
.icon-comment-empty:before {
content: "\e900";
}
.icon-comment-full:before {
content: "\e901";
}
.icon-fav-empty:before {
content: "\e902";
}
.icon-fav-full:before {
content: "\e903";
}
.icon-zan-empty:before {
content: "\e904";
}
.icon-zan-full:before {
content: "\e905";
}
.icon-add:before {
content: "\e145";
}
......@@ -274,12 +292,21 @@ i, em {
.icon-crop_original:before {
content: "\e3c4";
}
.icon-favorite:before {
content: "\e87d";
}
.icon-favorite_border:before {
content: "\e87e";
}
.icon-fingerprint:before {
content: "\e90d";
}
.icon-ondemand_video:before {
content: "\e63a";
}
.icon-power_settings_new:before {
content: "\e8ac";
}
.icon-slideshow:before {
content: "\e41b";
}
......@@ -391,4 +418,3 @@ i, em {
.icon-menu:before {
content: "\e120";
}
This diff is collapsed.
This diff is collapsed.
<!DOCTYPE html>
<html>
<head lang="zh-CN">
<title>草根学院首页</title>
<meta charset="UTF-8">
<meta name="description" content="">
<meta name="keywords" content="">
<!-- Use latest IE randering angine and switch on chrome Frame if available -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<link rel="shortcut icon" href="/favicon.ico">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/main.css">
</head>
<body>
<div class="navbar-main navbar-static-top clearfix">
<div class="logo pull-left">草根学院</div>
<!--<ul class="c-menu-item pull-left">
<li class="active"><a href="#">首页</a></li>
<li><a href="#">宠物志</a></li>
</ul>-->
<ul class="yun-login-btn pull-right">
<li><a href="#">登录</a></li>
<li><a href="#">注册</a></li>
</ul>
</div>
<div class="container">
<div class="cnt-tit">
<h3>为什么身体会做出不由自主的行为?</h3>
<div class="tit-share hidden-xs">
<a href="javascript:;" class="wechat post-icons"></a>
<a href="javascript:;" class="weibo post-icons"></a>
<a href="javascript:;" class="qzone post-icons"></a>
</div>
</div>
<div class="video-main">
<embed src='http://player.youku.com/player.php/sid/XMTc1NDM3MjUyNA==/v.swf' allowFullScreen='true' quality='high' width='100%' height='630' align='middle' allowScriptAccess='always' type='application/x-shockwave-flash'></embed>
</div>
<div class="video-detail-info">
<div class="video-teacher">
<a href="#"><img src="img/avatar2.jpg"></a>
<p><a href="#">乔布斯</a></p>
<span>2016-10-08</span>
</div>
<div class="video-sm-info">
<a href="#"><i class="icon-comment-empty"></i>543</a>
<a href="#"><i class="icon-fav-empty"></i>31</a>
<a href="#"><i class="icon-zan-empty"></i>97</a>
</div>
</div>
</div>
<!--视频介绍-->
<div class="warp-box">
<div class="container">
<div class="video-description">
<div class="title">视频介绍</div>
<div class="text">
四川水煮鱼,重庆串串香,新疆羊肉串,西北烤全羊,江西酒糟鱼,湖北小龙虾,汕头牛肉丸……虽然一直信奉着“胃有多大,世界就有多大”的至理名言,奈何却被一口烂牙阻挡了前进的脚步。快来看看今天的视频,保护好你的牙齿吧!
</div>
</div>
<div class="video-comment">
<div class="title">评论 <small>607次</small></div>
</div>
<div class="comment-login">
需要 <a href="#">登录</a> 才能评论
</div>
<div class="comment-box">
<div class="comment-head">
<img src="img/avatar2.jpg">
</div>
<div class="comment-input clearfix">
<textarea name="" id="" cols="30" rows="10" class="form-control" placeholder="说几句吧,亲..."></textarea>
<button class="btn btn-default pull-right m-t-10">发表评论</button>
</div>
</div>
<div class="comment-main-list clearfix">
<div class="user-h pull-left"><img src="img/avatar2.jpg"></div>
<div class="user-i">
<span>Frank <small>10分钟前</small></span>
<p>呵呵。。。不知为什么我听了你这么说话特牙疼</p>
</div>
</div>
<div class="comment-main-list clearfix">
<div class="user-h pull-left"><img src="img/avatar2.jpg"></div>
<div class="user-i">
<span>Frank <small>10分钟前</small></span>
<p>呵呵。。。不知为什么我听了你这么说话特牙疼</p>
</div>
</div>
<div class="comment-main-list clearfix">
<div class="user-h pull-left"><img src="img/avatarMax.png"></div>
<div class="user-i">
<span>Frank <small>10分钟前</small></span>
<p>呵呵。。。不知为什么我听了你这么说话特牙疼</p>
</div>
</div>
<div class="comment-main-list clearfix">
<div class="user-h pull-left"><img src="img/avatar2.jpg"></div>
<div class="user-i">
<span>Frank <small>10分钟前</small></span>
<p>呵呵。。。不知为什么我听了你这么说话特牙疼</p>
</div>
</div>
<div class="comment-main-list clearfix">
<div class="user-h pull-left"><img src="img/avatarMax.png"></div>
<div class="user-i">
<span>Frank <small>10分钟前</small></span>
<p>呵呵。。。不知为什么我听了你这么说话特牙疼</p>
</div>
</div>
</div>
</div>
<div class="copyright">© 2016 c.pp.cc 皖ICP备13046642号</div>
<script type="text/javascript" src="js/jquery-1.11.3.min.js"></script>
<script type='text/javascript' src="js/bootstrap.min.js"></script>
<script type='text/javascript' src="js/swiper.min.js"></script>
<!-- Initialize Swiper -->
<script>
var swiper = new Swiper('.swiper-container', {
pagination: '.swiper-pagination',
nextButton: '.swiper-button-next',
prevButton: '.swiper-button-prev',
paginationClickable: true,
spaceBetween: 30,
centeredSlides: true,
autoplay: 2500,
autoplayDisableOnInteraction: false
});
</script>
</body>
</html>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
<!DOCTYPE html>
<html>
<head lang="zh-CN">
<title>申请课堂</title>
<meta charset="UTF-8">
<meta name="description" content="">
<meta name="keywords" content="">
<!-- Use latest IE randering angine and switch on chrome Frame if available -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<link rel="shortcut icon" href="/favicon.ico">
<link rel="stylesheet" href="css/reset.css">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="tp-sidebar">
<div class="logo"><a href="#"><img src="img/logo.png"></a></div>
<div class="side-menu">
<ul class="simple-menu">
<li><a href="#"><i class="glyphicon glyphicon-th-list"></i>基本信息</a></li>
<li><a href="#"><i class="glyphicon glyphicon-ok"></i>已购课程</a></li>
<li><a href="#"><i class="glyphicon glyphicon-star"></i>收藏纪录</a></li>
<li><a href="#"><i class="glyphicon glyphicon-eye-open"></i>浏览记录</a></li>
<li><a href="#"><i class="glyphicon glyphicon-play-circle"></i>我的课堂</a></li>
<li><a href="#"><i class="glyphicon glyphicon-off"></i>退出登录</a></li>
</ul>
<div class="apply-class">
<button class="btn btn-danger">申请课堂</button>
</div>
</div>
</div>
<div class="auto-main">
<div class="tp-head navbar-fixed-top clearfix">
<div class="menu-btn fl"><a href="#"><i class="icon-menu"></i></a></div>
<div class="avatar fr"><a href="#"><img src="img/avatar.jpg"></a></div>
</div>
<div class="tp-main">
<div class="container">
<div class="send-class apply-class-box">
<div class="tit">申请课堂</div>
<div class="cls-part">
<div class="tit">课堂名称</div>
<input type="text" class="input-r-control" placeholder="请输入课堂名称">
</div>
<div class="cls-part">
<div class="tit">课堂介绍</div>
<input type="text" class="input-r-control" placeholder="示例:面向谁?服务是什么?优势是什么?">
</div>
<div class="cls-part">
<div class="tit">案例资源</div>
<div class="cls-intro-textarea">
<textarea name="" id="" class="input-r-control" placeholder="填写分享或培训的案例链接……"></textarea>
</div>
</div>
<div class="cls-part teacher-list">
<div class="checkbox">
<label>
<input type="checkbox">同意 <a href="#">云涯使用协议</a>及 <a href="#">版权声明</a>
</label>
</div>
</div>
<div class="btn-box text-center" style="margin-top: 10px; ">
<button class="btn btn-save m-l-10">保存</button>
</div>
</div>
</div>
</div>
</div>
<div class="foot navbar-fixed-bottom">
<p><a href="#">隐私权政策</a> - <a href="#">服务条款</a> - <a href="#">地图条款</a></p>
<p>©2016 Zuiketang.com</p>
</div>
<script src='http://codepen.io/assets/libs/fullpage/jquery.js'></script>
<script src="js/index.js"></script>
</body>
</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