Commit fd00ac46 authored by 汪波's avatar 汪波
parents ccc16fe4 554655ba
<?php
/**
* Created by PhpStorm.
* User: pader
* Date: 16/9/29
* Time: 16:05
*/
namespace common\components;
use yii\base\Object;
use yii\helpers\Url;
use Qiniu\Auth;
class Qiniu extends Object
{
private $accessKey;
private $secretKey;
public $storages;
private $config;
public function __construct($config=[]) {
$this->config = $config;
parent::__construct($config);
}
public function setAccessKey($accessKey) {
$this->accessKey = $accessKey;
}
public function setSecretKey($secretKey) {
$this->secretKey = $secretKey;
}
public function urlsafeBase64Encode($str) {
return str_replace(['+', '/'], ['-', '_'], base64_encode($str));
}
/**
* 获取七牛鉴权实例
*
* @return Auth
*/
public function getAuthInstance()
{
static $auth = null;
if ($auth === null) {
$auth = new Auth($this->accessKey, $this->secretKey);
}
return $auth;
}
/**
* 生成随机目录层级
*
* @return string
*/
public function generateRandomDir()
{
$key = md5(\Yii::$app->security->generateRandomKey());
return substr($key, 0, 2).'/'.substr($key, 2, 2).'/'.substr($key, 4, 2);
}
public function generateRandomName($len=20)
{
return \Yii::$app->security->generateRandomString($len);
}
public function generateRandomFilePath($ext='', $len=20)
{
return $this->generateRandomDir().'/'.$this->generateRandomName($len).$ext;
}
/**
* 获取七牛上传 Token
*
* @param string $storage 要存储的空间名称
* @param string $filename 要存储的目标文件路径
* @param string $returnBody 返回的数据格式
* @param int $deadSeconds 生成的Token有效期
* @return string
*/
public function getUploadToken($storage, $filename, $returnBody, $deadSeconds=3600)
{
if (!isset($this->storages[$storage])) {
exit('Unknow storage: '.$storage."\n");
}
$config = $this->storages[$storage];
$callbackUrl = Url::to(['qiniu-callback/rem-upload'], true);
$policy = [
'returnBody' => $returnBody,
'saveKey' => $filename,
'fsizeLimit' => $config['fsizeLimit'],
'mimeLimit' => $config['mimeLimit'],
'callbackUrl' => 'http://t.pp.cc/tmp/qiniu_callback.php',
'callbackBody' => 'key=$(key)&fsize=$(fsize)&time=$(year)-$(mon)-$(day) $(hour)%3A$(min)%3A$(sec)'
];
$auth = $this->getAuthInstance();
return $auth->uploadToken($config['bucket'], null, $deadSeconds, $policy);
}
public function decodeUploadToken($token)
{
$arr = explode(':', $token);
if (count($arr) != 3) {
return null;
}
list($accessKey, $sign, $data) = $arr;
$dataJson = \Qiniu\base64_urlSafeDecode($data);
$dataArr = json_decode($dataJson, true);
if (!isset($dataArr['scope'])) {
return null;
}
//寻找配置
$config = null;
foreach ($this->storages as $storage => $cfg) {
if ($cfg['bucket'] == $dataArr['scope']) {
$config = $cfg;
break;
}
}
if ($config === null) {
return null;
}
//验证 Token 是否一致
$auth = $this->getAuthInstance();
$reToken = $auth->signWithData($dataJson);
if ($token != $reToken) {
return null;
}
return $dataArr;
}
}
\ No newline at end of file
......@@ -48,5 +48,24 @@ return [
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
],
],
'qiniu' => [
'class' => 'common\components\Qiniu',
'accessKey' => 'n85SCPB9uO2v32az-3TRFsZCXwJu7YddyzLRYXg-',
'secretKey' => 'KDl3b7aLpj7n9YZ07lHGivVY4c_Q-0QSM0TZ_-XS',
'storages' => [
'public' => [
'bucket' => 'pp-classroom',
'fsizeLimit' => pow(1024, 2) * 5, //5MB
'mimeLimit' => 'image/jpeg;image/png;image/gif',
'url' => 'http://dev.qdn.pp.cc/'
],
'video' => [
'bucket' => 'pp-classroom-video',
'fsizeLimit' => pow(1024, 3) * 2, //2GB
'mimeLimit' => 'video/*;flv-application/octet-stream',
'url' => 'http://oe8x9mpvz.bkt.clouddn.com/'
]
]
]
],
];
......@@ -3,6 +3,8 @@
namespace common\models;
use Yii;
use yii\behaviors\TimestampBehavior;
use yii\redis\ActiveRecord;
/**
* This is the model class for table "browse_record".
......@@ -22,13 +24,29 @@ class BrowseRecord extends \yii\db\ActiveRecord
return 'browse_record';
}
/**
* @inheritdoc
*/
public function behaviors()
{
return [
[
'class' => TimestampBehavior::className(),
'attributes' => [
ActiveRecord::EVENT_BEFORE_INSERT => ['time'],
],
// if you're using datetime instead of UNIX timestamp:
// 'value' => new Expression('NOW()'),
],];
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['user_id', 'course_id', 'time'], 'required'],
[['user_id', 'course_id',], 'required'],
[['user_id', 'course_id', 'time'], 'integer'],
];
}
......@@ -45,4 +63,20 @@ class BrowseRecord extends \yii\db\ActiveRecord
'time' => 'Time',
];
}
/**
* 获取浏览记录
* @param $userId
* @return mixed
*/
public static function getByUserId($userId)
{
$tableA = self::tableName();
$tableB = Course::tableName();
return self::find()
->select("course_id,time,$tableB.name,$tableB.avatar,$tableB.price,$tableB.free_time,$tableB.intro,$tableB.preview_pic,$tableB.created_at")
->where("$tableA.user_id = :user_id", [
':user_id' => $userId
])->join('left join', $tableB, "$tableA.user_id=$tableB.id")->asArray()->all();
}
}
<?php
namespace common\models;
use Yii;
use yii\behaviors\TimestampBehavior;
use yii\redis\ActiveRecord;
/**
* This is the model class for table "course".
*
* @property integer $id
* @property integer $user_id
* @property integer $classed_id
* @property string $avatar
* @property string $name
* @property integer $price
* @property integer $free_time
* @property string $intro
* @property string $preview_pic
* @property integer $recommend
* @property integer $status
* @property integer $created_at
* @property integer $updated_at
*/
class Course extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'course';
}
/**
* @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()'),
],];
}
/**
* @inheritdoc
*/
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],
];
}
/**
* @inheritdoc
*/
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',
];
}
}
......@@ -3,6 +3,8 @@
namespace common\models;
use Yii;
use yii\behaviors\TimestampBehavior;
use yii\db\ActiveRecord;
/**
* This is the model class for table "favorite".
......@@ -22,13 +24,30 @@ class Favorite extends \yii\db\ActiveRecord
return 'favorite';
}
/**
* @inheritdoc
*/
public function behaviors()
{
return [
[
'class' => TimestampBehavior::className(),
'attributes' => [
ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'],
],
// if you're using datetime instead of UNIX timestamp:
// 'value' => new Expression('NOW()'),
],];
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['user_id', 'course_id', 'created_at'], 'required'],
[['user_id', 'course_id',], 'required'],
[['user_id', 'course_id', 'created_at'], 'integer'],
];
}
......@@ -45,4 +64,19 @@ class Favorite extends \yii\db\ActiveRecord
'created_at' => 'Created At',
];
}
/**
* @param $userId
* @return array|null|ActiveRecord
*/
public static function getByUserId($userId)
{
$tableA = self::tableName();
$tableB = Course::tableName();
return self::find()
->select("course_id,$tableA.created_at as time ,$tableB.name,$tableB.avatar,$tableB.price,$tableB.free_time,$tableB.intro,$tableB.preview_pic,$tableB.created_at")
->where("$tableA.user_id = :user_id", [
':user_id' => $userId
])->join('left join', $tableB, "$tableA.user_id=$tableB.id")->asArray()->all();
}
}
......@@ -3,6 +3,8 @@
namespace common\models;
use Yii;
use yii\behaviors\TimestampBehavior;
use yii\redis\ActiveRecord;
/**
* This is the model class for table "income".
......@@ -24,13 +26,30 @@ class Income extends \yii\db\ActiveRecord
return 'income';
}
/**
* @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()'),
],];
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['user_id', 'orders_id', 'created_at', 'updated_at'], 'required'],
[['user_id', 'orders_id'], 'required'],
[['user_id', 'orders_id', 'status', 'created_at', 'updated_at'], 'integer'],
];
}
......
......@@ -3,6 +3,8 @@
namespace common\models;
use Yii;
use yii\behaviors\TimestampBehavior;
use yii\redis\ActiveRecord;
/**
* This is the model class for table "orders".
......@@ -27,13 +29,30 @@ class Orders extends \yii\db\ActiveRecord
return 'orders';
}
/**
* @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()'),
],];
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['user_id', 'course_id', 'number', 'credit', 'pay_order', 'created_at', 'updated_at'], 'required'],
[['user_id', 'course_id', 'number', 'credit', 'pay_order'], 'required'],
[['user_id', 'course_id', 'status', 'created_at', 'updated_at'], 'integer'],
[['number', 'credit'], 'string', 'max' => 32],
[['pay_order'], 'string', 'max' => 64],
......@@ -57,4 +76,21 @@ class Orders extends \yii\db\ActiveRecord
'updated_at' => 'Updated At',
];
}
/**
* 获取购买记录
* @param $userId
* @return array|\yii\db\ActiveRecord[]
*/
public static function getPurchasedCourseByUserId($userId)
{
$tableA = self::tableName();
$tableB = Course::tableName();
return self::find()->select("$tableA.course_id,$tableA.created_at as purchased_time,$tableB.name,$tableB.avatar,$tableB.price,$tableB.free_time,$tableB.intro,$tableB.preview_pic,$tableB.created_at")
->where("$tableA.user_id=:user_id and $tableA.status = 1", [
':user_id' => $userId
])->join('left join ', $tableB, "$tableA.course_id = $tableB.id")->asArray()->all();
}
}
......@@ -139,12 +139,6 @@ class User extends ActiveRecord implements IdentityInterface
return static::findOne(['telephone' => $telephone, 'status' => self::STATUS_ACTIVE]);
}
public static function findByTelephone2($telephone)
{
// return static::findOne(['telephone' => $telephone, 'status' => self::STATUS_ACTIVE]);
return static::find()->select('id,username')->where(['telephone' => $telephone, 'status' => self::STATUS_ACTIVE])
->one();
}
/**
* Finds user by password reset token
......
......@@ -14,7 +14,8 @@
"yiisoft/yii2-bootstrap": "*",
"yiisoft/yii2-swiftmailer": "*",
"yiisoft/yii2-redis": "^2.0",
"guzzlehttp/guzzle": "^6.2"
"guzzlehttp/guzzle": "^6.2",
"qiniu/php-sdk": "^7.0"
},
"require-dev": {
"yiisoft/yii2-codeception": "*",
......
......@@ -4,8 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "bdf4a20720b1c71520c40efab351ceb5",
"content-hash": "97de8c5fe3587d7d90b4efc2a281a190",
"hash": "58c51098f2b70fd0b7cacfcb4527cb2f",
"content-hash": "ed7bd775092a2dda1558bb321d31c8c4",
"packages": [
{
"name": "bower-asset/bootstrap",
......@@ -520,6 +520,57 @@
],
"time": "2016-08-06 14:39:51"
},
{
"name": "qiniu/php-sdk",
"version": "v7.0.8",
"source": {
"type": "git",
"url": "https://github.com/qiniu/php-sdk.git",
"reference": "d1bca450b56d85beb7ba21f374a47bfeb59c288b"
},
"dist": {
"type": "zip",
"url": "https://packagist.phpcomposer.com/files/qiniu/php-sdk/d1bca450b56d85beb7ba21f374a47bfeb59c288b.zip",
"reference": "d1bca450b56d85beb7ba21f374a47bfeb59c288b",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
"squizlabs/php_codesniffer": "~2.3"
},
"type": "library",
"autoload": {
"psr-4": {
"Qiniu\\": "src/Qiniu"
},
"files": [
"src/Qiniu/functions.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Qiniu",
"email": "sdk@qiniu.com",
"homepage": "http://www.qiniu.com"
}
],
"description": "Qiniu Resource (Cloud) Storage SDK for PHP",
"homepage": "http://developer.qiniu.com/",
"keywords": [
"cloud",
"qiniu",
"sdk",
"storage"
],
"time": "2016-07-19 06:18:08"
},
{
"name": "swiftmailer/swiftmailer",
"version": "v5.4.3",
......
......@@ -27,6 +27,7 @@ class m160927_122231_orders_init extends Migration
], $tableOptions);
$this->addCommentOnTable($this->table, '用户订单表');
$this->createIndex('index-user_id', $this->table, 'user_id');
$this->createIndex('index-user_id-status', $this->table, ['user_id', 'status']);
}
......
<?php
namespace frontend\assets;
use yii\web\AssetBundle;
use yii\web\View;
use Yii;
use \Yii;
/**
* Main frontend application asset bundle.
*/
......@@ -12,15 +12,17 @@ class AppAsset extends AssetBundle
{
public $basePath = '@webroot/assets';
public $baseUrl = '@web/assets';
public $css = [
'css/site.css',
'css/style.css'
];
public $js = [
['common/common.js', 'position' => View::POS_BEGIN]
['common/common.js', 'position' => View::POS_HEAD],
];
public $depends = [
// 'yii\web\YiiAsset',
// 'yii\bootstrap\BootstrapAsset',
'yii\bootstrap\BootstrapAsset'
];
//定义按需加载JS方法,注意加载顺序在最后
......@@ -38,13 +40,30 @@ class AppAsset extends AssetBundle
}
/**
* $path 为相对baseUrl 的相对路径
*
* 生成带时间戳的图片地址
* @param $path
* @return string
*/
public static function getStaticUrl($path)
{
$path = '@web/assets/' . $path;
$path = self::appendTimestamp($path);
return Yii::getAlias($path);
}
public static function appendTimestamp($url)
{
if (Yii::$app->assetManager->appendTimestamp && strncmp($url, '@web/', 5) === 0) {
$fileToCacheBust = Yii::getAlias(str_replace('@web', '@webroot', $url));
if (($timestamp = @filemtime("$fileToCacheBust")) > 0)
if (($timestamp = filemtime("$fileToCacheBust")) > 0)
$url .= "?v={$timestamp}";
}
return $url;
}
}
......@@ -17,7 +17,11 @@ return [
'csrfParam' => '_csrf-frontend',
],
'assetManager' => [
'appendTimestamp' => TRUE
'appendTimestamp' => TRUE,
//'baseUrl' => 'http://www.baidu.com/',
'bundles' => [
'yii\web\JqueryAsset' => false,
]
],
'session' => [
'timeout' => 3600,
......
<?php
namespace frontend\controllers;
use frontend\models\CoursePublishForm;
use \Yii;
class MyCourseController extends \yii\web\Controller
{
public $layout = 'user-center';
public function actionIndex()
{
return $this->render('index');
}
public function actionPublish()
{
/* @var \common\components\Qiniu $qiniu */
$qiniu = Yii::$app->qiniu;
//$auth = Yii::$app->qiniu->getAuthInstance();
$returnBody = '{"uuid":$(uuid), "key": "$(key)", "size": $(fsize), "w":$(imageInfo.width), "h":$(imageInfo.height)}';
//图片上传Token
//$imgName = 'preview/'.$qiniu->genRandomDir().'/'.Yii::$app->security->generateRandomString(20);
$imgPath = 'preview/'.$qiniu->generateRandomFilePath('$(min)$(sec)$(ext)', 8);
$thumbToken = $qiniu->getUploadToken('public', $imgPath, $returnBody, 3600, true);
//视频上传Token
//$videoName = 'source/'.$qiniu->genRandomDir().'/'.Yii::$app->security->generateRandomString(20);
$videoName = 'source/'.$qiniu->generateRandomFilePath('$(ext)');
$videoToken = $qiniu->getUploadToken('video', $videoName, $returnBody, 86400);
$model = new CoursePublishForm();
return $this->render('publish', compact('model', 'thumbToken', 'videoToken'));
}
}
<?php
/**
* Created by PhpStorm.
* User: pader
* Date: 16/10/8
* Time: 20:14
*/
namespace frontend\controllers;
use yii\helpers\Url;
class QiniuCallbackController extends \yii\web\Controller {
/**
* 上传回调 - 记录上传的文件
*
* 记录文件关关联处理以防止生成垃圾文件浪费空间
*/
public function actionRemUpload()
{
/* @var \Qiniu\Auth $auth */
$auth = \Yii::$app->qiniu->getAuthInstance();
//验证回调请求
$requestBody = file_get_contents('php://input');
$authorization = isset($_SERVER['HTTP_AUTHORIZATION']) ? $_SERVER['HTTP_AUTHORIZATION'] : '';
$currentUrl = \Yii::$app->request->hostInfo.\Yii::$app->request->getUrl();
if ($auth->verifyCallback($_SERVER['CONTENT_TYPE'], $authorization, $currentUrl, $requestBody)) {
echo 'ok';
} else {
echo 'no';
}
}
}
\ No newline at end of file
......@@ -9,13 +9,17 @@
namespace frontend\controllers;
use common\libs\Message;
use common\libs\Test;
use common\libs\Utils;
use common\models\BrowseRecord;
use common\models\Favorite;
use common\models\Orders;
use common\models\User;
use yii\base\ErrorException;
use yii\base\Exception;
use yii\filters\AccessControl;
use yii\web\Controller;
use Yii;
use yii\helpers\HtmlPurifier;
class UserCenterController extends Controller
{
......@@ -53,22 +57,68 @@ class UserCenterController extends Controller
*/
public function actionInfo()
{
// echo $th
return $this->render('info');
$qiniu = Yii::$app->qiniu;
$returnBody = '{"key":"$(key)"}';
//图片上传Token
//$imgName = 'preview/'.$qiniu->genRandomDir().'/'.Yii::$app->security->generateRandomString(20);
$imgPath = 'avatar/' . $qiniu->generateRandomFilePath('$(ext)', 10);
$publicToken = $qiniu->getUploadToken('public', $imgPath, $returnBody);
return $this->render('info', compact('publicToken'));
}
public function actionCourse()
/**
* 购买记录
* @return string
*/
public function actionPurchasedCourse()
{
return $this->render('course');
$purchasedCourse = Orders::getPurchasedCourseByUserId(Yii::$app->user->getId());
var_dump($purchasedCourse);
return $this->render('purchased_course');
}
/**
* 收藏记录
* @return string
*/
public function actionFavorite()
{
$favorite = Favorite::getByUserId(Yii::$app->user->getId());
var_dump($favorite);
return $this->render('favorite');
}
/**
* 浏览记录
* @return string
*/
public function actionBrowseRecord()
{
$browseRecord = BrowseRecord::getByUserId(Yii::$app->user->getId());
var_dump($browseRecord);
return $this->render('browse_record');
}
//fe7e7ff7-ef6d-45da-a6f5-ec93792101b4
/**
* 设置头像信息
* @param $key
* @throws \yii\web\ForbiddenHttpException
*/
public function actionSetVatarInfo($key)
{
if (Yii::$app->request->isAjax) {
$user = Yii::$app->user->identity;
$user->avatar = $key;
$user->save();
Utils::ajaxResponse();
} else {
throw new \yii\web\ForbiddenHttpException('非法请求');
}
}
......
<?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
......@@ -12,7 +12,7 @@ use common\models\User;
class LoginForm extends Model
{
const MAX_LOGIN_NUM = 5;
const LOGIN_CYCLE = 15 * 60;//second
const LOGIN_CYCLE = 900; //second
const REDIS_KEY_PREFIX = 'login_ip';
public $telephone;
public $password;
......
<?php
/* @var $this yii\web\View */
\frontend\assets\AppAsset::addScript($this, '@web/assets/home_index.js');
\frontend\assets\AppAsset::addCss($this, '@web/assets/css/home_index.css');
?>
<h1>home/index</h1>
<p>
<video id="example_video_1" class="video-js vjs-default-skin vjs-big-play-centered"
controls preload="auto" width="640" height="264"
poster="http://dev.qdn.pp.cc/object/test-thumb1.jpg"
data-setup='{"example_option":true,"autoplay":false,"language":"zh-CN"}'>
<source src="http://dev.qdn.pp.cc/object/test-3.mp4" type="video/mp4"/>
</video>
</p>
<p>
You may change the content of this page by modifying
the file <code><?= __FILE__; ?></code>.
......
......@@ -11,6 +11,7 @@ use frontend\assets\AppAsset;
use common\widgets\Alert;
AppAsset::register($this);
AppAsset::addCss($this, '@web/assets/css/site.css');
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
......
<?php
use yii\helpers\Html;
use yii\web\View;
use frontend\assets\AppAsset;
/* @var $this \yii\web\View */
/* @var $content string */
AppAsset::register($this);
$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);
?>
<?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(); ?>
<div class="tp-sidebar">
<div class="logo"><a href="/"><img src="<?=Yii::$app->assetManager->baseUrl?>/img/logo.png"></a></div>
<div class="side-menu">
<!-- Contenedor -->
<ul id="accordion" class="accordion">
<li>
<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>
</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="#">课程列表</a></li>
</ul>
</li>
<li>
<div class="link"><i class="icon-fingerprint"></i>我的会员<i class="icon-navigate_next"></i></div>
<ul class="submenu">
<li><a href="#">会员列表</a></li>
</ul>
</li>
<li><div class="link"><i class="icon-bell"></i>知识有价<i class="icon-navigate_next"></i></div>
<ul class="submenu">
<li><a href="#">购买记录</a></li>
</ul>
</li>
</ul>
</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="<?=Yii::$app->assetManager->baseUrl?>/img/avatar.jpg"></a></div>
</div>
<div class="tp-main">
<div class="container">
<?=$content?>
</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>
<?php $this->endBody(); ?>
</body>
</html>
<?php $this->endPage(); ?>
<?php
use frontend\assets\AppAsset;
/*
* @var $this yii\web\View
* @var $form yii\widgets\ActiveForm
* @var $model frontend\models\CoursePublishForm
*/
$this->title = '发布课程';
//AppAsset::addScript($this, '@web/assets/single-lib/plupload/plupload.full.min.js');
AppAsset::addScript($this, '@web/assets/course_publish.js');
?>
<div class="send-class" id="publishMain">
<div class="tit">发布课程</div>
<form method="post" name="coursePublish">
<div class="cls-part">
<div class="tit">标题</div>
<input type="text" name="name" class="input-r-control" placeholder="请输入课程标题,20 个汉字以内...">
</div>
<div class="cls-part teacher-list">
<div class="tit">讲师</div>
<div class="checkbox">
<label>
<input name="teacher[]" type="checkbox">杨佩佩
</label>
<label class="m-l-10">
<input name="teacher[]" type="checkbox">马骏
</label>
<label class="m-l-10">
<input name="teacher[]" type="checkbox">花木兰
</label>
<label class="m-l-10">
<input name="teacher[]" type="checkbox">张海
</label>
<span class="m-l-10"><a href="#">+ 添加讲师</a></span>
</div>
</div>
<div class="cls-part">
<div class="tit">上传视频</div>
<video-upload uptoken="<?=$videoToken?>"></video-upload>
</div>
<div class="cls-part">
<div class="tit">规则设定</div>
<div class="clearfix">
<div class="checkbox rules-set fl">
<label class="clearfix">
<input name="vip_price" type="checkbox" class="fl" value="1"><span>会员价</span> <input type="text" value="price" class="input-r-control"> <span>元</span>
</label>
</div>
<div class="checkbox rules-set m-l-20 fl">
<label class="clearfix">
<input name="free_time" type="checkbox" class="fl"><span>免费试看</span> <input type="text" class="input-r-control"> <span>分钟</span>
</label>
</div>
</div>
</div>
<input type="hidden" name="vkey" value="{{videoKey}}" />
<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>
</div>
</div>
<div class="cls-part">
<div class="tit">缩略图 <small>建议尺寸:900像素 * 500像素</small></div>
<thumb-upload uptoken="<?=$thumbToken?>"></thumb-upload>
</div>
<div class="cls-part p-b-20">
<div class="tit">课程属性</div>
<div class="checkbox">
<label>
<input type="checkbox">推荐课程
</label>
</div>
</div>
<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>
</div>
</form>
</div>
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: xiabin
* Date: 2016/9/29
* Time: 上午9:59
*/
\frontend\assets\AppAsset::addScript($this, '@web/assets/user_center_browse_record.js')
?>
<h1>user-center/browse_record</h1>
<p>
You may change the content of this page by modifying
the file <code><?= __FILE__; ?></code>.
</p>
<?php
/**
* Created by PhpStorm.
* User: xiabin
* Date: 2016/9/27
* Time: 下午4:16
*/
\frontend\assets\AppAsset::addScript($this,'@web/assets/user_favorite.js')
?>
<h1>user-center/favorite</h1>
<p>
You may change the content of this page by modifying
the file <code><?= __FILE__; ?></code>.
</p>
\ No newline at end of file
......@@ -5,5 +5,17 @@
* Date: 2016/9/27
* Time: 下午4:16
*/
\frontend\assets\AppAsset::addScript($this, '@web/assets/user_center_info.js');
$url = Yii::$app->qiniu->storages['public']['url'];
?>
info
<h1>user-center/info</h1>
<div id="avatar-uploader-container"><img id="avatar-uploader" token="<?= $publicToken ?>"
src="<?php echo Yii::$app->user->identity->avatar === '' ? \frontend\assets\AppAsset::getStaticUrl('img/avatar.jpg') : $url . Yii::$app->user->identity->avatar ?>">
</div>
<p>
You may change the content of this page by modifying
the file <code><?= __FILE__; ?></code>.
</p>
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: xiabin
* Date: 2016/9/29
* Time: 上午9:59
*/
\frontend\assets\AppAsset::addScript($this, '@web/assets/user_center_purchased_course.js')
?>
<h1>user-center/purchased_course</h1>
<p>
You may change the content of this page by modifying
the file <code><?= __FILE__; ?></code>.
</p>
This diff is collapsed.
@charset "utf-8";
/*! normalize.css v2.1.3 | MIT License | git.io/normalize */
/* Html5 */
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
main,
nav,
section,
summary {
display: block;
}
audio,
canvas,
video {
display: inline-block;
}
audio:not([controls]) {
display: none;
height: 0;
}
/* Base */
html, body {
font: 12px/22px "微软雅黑", "\5b8b\4f53", Arial, sans-serif;
background-color: #e3e4e7;
}
html, body {
width: 100%;
}
html {
color: #666;
-ms-text-size-adjust: 100%;
-webkit-text-size-adjust: 100%;
}
* {
margin: 0;
padding: 0;
}
a {
text-decoration: none;
background: transparent;
outline: none;
blr: expression(this.onFocus=this.blur());
}
a:focus {
outline: 0;
}
a:active,
a:hover {
outline: 0;
text-decoration: none;
}
img {
border: 0;
vertical-align: middle;
-ms-interpolation-mode: bicubic;
transition: transform 1s;
}
img.hover {
transform: scale(1.15);
}
fieldset {
border: 1px solid #c0c0c0;
margin: 0 2px;
padding: 0.35em 0.625em 0.75em;
}
/*margin padding*/
.m-l-10 {
margin-left: 10px;
}
.m-l-20 {
margin-left: 20px;
}
.p-b-20 {
padding-bottom: 20px;
}
/* legend */
button,
input,
select,
textarea {
font-family: inherit;
font-size: 100%;
margin: 0;
outline: none;
}
button,
input {
line-height: normal;
}
button,
select {
text-transform: none;
}
button,
html input[type="button"],
input[type="reset"],
input[type="submit"] {
-webkit-appearance: button;
cursor: pointer;
}
button[disabled],
html input[disabled] {
cursor: default;
}
input[type="checkbox"],
input[type="radio"] {
box-sizing: border-box;
padding: 0;
}
input[type="search"] {
-webkit-appearance: textfield;
-moz-box-sizing: content-box;
-webkit-box-sizing: content-box;
box-sizing: content-box;
}
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-decoration {
-webkit-appearance: none;
}
button::-moz-focus-inner,
input::-moz-focus-inner {
border: 0;
padding: 0;
}
input.submit {
cursor: pointer;
}
input.radio {
width: 13px;
height: 13px;
}
input[type="text"],
input[type="number"] {
-webkit-appearance: none;
}
textarea {
overflow: auto;
vertical-align: top;
resize: none;
-webkit-appearance: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
ul,
ol,
li {
list-style: none;
float: left;
}
i, em {
font-style: normal;
}
/* clear */
.fl {
float: left;
}
.fr {
float: right;
}
.clearfix:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden
}
/*icomoon*/
@font-face {
font-family: 'icomoon';
src: url('fonts/icomoon.eot?lylu0j');
src: url('fonts/icomoon.eot?lylu0j#iefix') format('embedded-opentype'),
url('fonts/icomoon.ttf?lylu0j') format('truetype'),
url('fonts/icomoon.woff?lylu0j') format('woff'),
url('fonts/icomoon.svg?lylu0j#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-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-fingerprint:before {
content: "\e90d";
}
.icon-ondemand_video:before {
content: "\e63a";
}
.icon-slideshow:before {
content: "\e41b";
}
.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";
}
This diff is collapsed.
<template xmlns:v-bind="http://www.w3.org/1999/xhtml">
<div class="upload-video-screen" v-bind:id="uploaderId">
<i class="icon-image"></i>{{text}}
</div>
</template>
<style>
.upload-video-screen {cursor:pointer; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; padding:0 10px;}
</style>
<script>
import layer from "layer-js";
import str from "../../utils/string";
var defaultText = "上传缩略图";
export default{
data() {
return {
uploaderId: "thumbUploader" + str.rand(10),
state: "ready",
text: ""
}
},
props: {
uptoken: String
},
ready() {
this.text = defaultText;
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) {
// 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';
}
}
});
//上传中禁止重选文件
self.$watch("state", function(val, old) {
if (val == "uploading") {
uploader.disableBrowse();
} else {
uploader.disableBrowse(false);
}
self.$dispatch("thumb-upload-state-change", val, old);
});
uploader.init();
});
}
}
</script>
<template xmlns:v-bind="http://www.w3.org/1999/xhtml">
<div>
<div class="upload-video-btn" v-bind:id="uploaderId" v-show="state=='ready' || state=='error'">
<i class="icon-play"></i>
<b>上传视频</b>
</div>
<div class="upload-ready" v-else>
<h3>{{videoName}}</h3>
<div class="video-detail">
视频大小:{{videoSize}}
速度:{{speed}}
</div>
<div class="video-loading-text clearfix">
<div class="upload pull-left">已上传 {{progress}}%</div>
<div class="time pull-right">大约还剩 <span class="upload-info-remain">{{remain}}</span></div>
</div>
<i class="upload-progress" v-bind:style="{width:progress + '%'}"></i>
</div>
</div>
</template>
<style>
.upload-video-btn {cursor:pointer;}
.upload-ready {position:relative; z-index:2;}
.upload-ready h3 {overflow:hidden; white-space:nowrap; text-overflow:ellipsis;}
</style>
<script>
import filesize from "file-size";
import layer from "layer-js";
import str from "../../utils/string";
export default {
data() {
return {
state: "ready",
videoName: "",
videoSize: "",
progress: 0,
speed: "",
uploaderId: "videoUploader" + str.rand(10)
}
},
props: {
uptoken: String
},
ready() {
var container = $(this.$el),
btn = container.find(".upload-video-btn"),
ready = container.find(".upload-ready");
var infoRemain = ready.find(".upload-info-remain");
var self = this,
startTime;
require.ensure(["../../utils/qiniu", "moment"], function() {
var qiniu = require("../../utils/qiniu");
var moment = require("moment");
moment.locale('zh-cn', {
relativeTime : {
future: "in %s",
past: "%s ago",
s: "%d 秒",
m: "%d 分钟",
mm: "%d 分钟",
h: "%d 小时",
hh: "%d 小时",
d: "%d 天",
dd: "%d 天",
M: "%d 月",
MM: "%d 月",
y: "d% 年",
yy: "%d 年"
}
});
var uploader = new qiniu.Uploader({
browse_button: self.uploaderId,
drop_element: self.uploaderId,
upload_token: self.uptoken,
filters: {
max_file_size: '2gb',
mime_types: [
{title: "视频文件", extensions:"3gp,flv,rm,rmvb,divx,mpg,mpeg,mp4,m4v,mov,mkv,vob,qt,avi,asf,asx,wmv,webm"}
]
},
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;
});
// container.find(".upload-video-btn").hide();
// ready.show();
self.state = 'uploading';
up.start();
startTime = (new Date()).getTime();
},
//每个文件上传前
'BeforeUpload': function(up, file) {
},
'UploadProgress': function(up, file) {
self.progress = file.percent;
self.speed = filesize(up.total.bytesPerSec).human('si');
// var avgSpeed = file.loaded / (((new Date()).getTime() - startTime) / 1000);
var sizeRemain = file.origSize - file.loaded;
var leftSeconds = sizeRemain / up.total.bytesPerSec;
var toDate = new Date();
toDate.setTime((new Date()).getTime() + leftSeconds * 1000);
infoRemain.text(moment(toDate).toNow(true));
// infoProgress.text(file.percent);
// $("#" + file.id + " .attachup-list-element-status").html("上传中 - " + file.percent + "%");
},
//每个文件上传成功后
'FileUploaded': function(up, file, info) {
infoRemain.parent().text("上传完成");
self.speed = "-/";
var response = $.parseJSON(info.response);
self.$dispatch("video-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';
}
}
});
//状态变化时禁用或启用上传按钮
self.$watch("state", function(val, old) {
if (val == "ready" || val == "error") {
uploader.disableBrowse(false);
} else {
uploader.disableBrowse();
}
self.$dispatch("video-upload-state-change", val, old);
});
uploader.init();
});
}
}
</script>
\ No newline at end of file
/**
* Created by xiabin on 2016/9/29.
*/
require('expose?videojs!../libs/videojs/video.js');
require('../libs/videojs/video-js.css');
require('../libs/videojs/lang/zh-CN.js');
// console.log(videojs);
// layer.msg('home/index');
videojs.options.flash.swf = __CDN_URL__ + 'assets/videojs/video-js.swf';
window.VIDEOJS_NO_BASE_THEME = true;
videojs("example_video_1").ready(function () {
var myPlayer = this;
// EXAMPLE: Start playing the video.
myPlayer.play();
});
\ No newline at end of file
// English (en)
plupload.addI18n({"Stop Upload":"Stop Upload","Upload URL might be wrong or doesn't exist.":"Upload URL might be wrong or doesn't exist.","tb":"tb","Size":"Size","Close":"Close","You must specify either browse_button or drop_element.":"You must specify either browse_button or drop_element.","Init error.":"Init error.","Add files to the upload queue and click the start button.":"Add files to the upload queue and click the start button.","List":"List","Filename":"Filename","%s specified, but cannot be found.":"%s specified, but cannot be found.","Image format either wrong or not supported.":"Image format either wrong or not supported.","Status":"Status","HTTP Error.":"HTTP Error.","Start Upload":"Start Upload","Error: File too large:":"Error: File too large:","kb":"kb","Duplicate file error.":"Duplicate file error.","File size error.":"File size error.","N/A":"N/A","gb":"gb","Error: Invalid file extension:":"Error: Invalid file extension:","Select files":"Select files","%s already present in the queue.":"%s already present in the queue.","Resoultion out of boundaries! <b>%s</b> runtime supports images only up to %wx%hpx.":"Resoultion out of boundaries! <b>%s</b> runtime supports images only up to %wx%hpx.","File: %s":"File: %s","b":"b","Uploaded %d/%d files":"Uploaded %d/%d files","Upload element accepts only %d file(s) at a time. Extra files were stripped.":"Upload element accepts only %d file(s) at a time. Extra files were stripped.","%d files queued":"%d files queued","File: %s, size: %d, max file size: %d":"File: %s, size: %d, max file size: %d","Thumbnails":"Thumbnails","Drag files here.":"Drag files here.","Runtime ran out of available memory.":"Runtime ran out of available memory.","File count error.":"File count error.","File extension error.":"File extension error.","mb":"mb","Add Files":"Add Files"});
\ No newline at end of file
// Chinese (China) (zh_CN)
plupload.addI18n({"Stop Upload":"停止上传","Upload URL might be wrong or doesn't exist.":"上传的URL可能是错误的或不存在。","tb":"tb","Size":"大小","Close":"关闭","You must specify either browse_button or drop_element.":"您必须指定 browse_button 或者 drop_element。","Init error.":"初始化错误。","Add files to the upload queue and click the start button.":"将文件添加到上传队列,然后点击”开始上传“按钮。","List":"列表","Filename":"文件名","%s specified, but cannot be found.":"%s 已指定,但是没有找到。","Image format either wrong or not supported.":"图片格式错误或者不支持。","Status":"状态","HTTP Error.":"HTTP 错误。","Start Upload":"开始上传","Error: File too large:":"错误: 文件太大:","kb":"kb","Duplicate file error.":"重复文件错误。","File size error.":"文件大小错误。","N/A":"N/A","gb":"gb","Error: Invalid file extension:":"错误:无效的文件扩展名:","Select files":"选择文件","%s already present in the queue.":"%s 已经在当前队列里。","Resoultion out of boundaries! <b>%s</b> runtime supports images only up to %wx%hpx.":"超限。<b>%s</b> 支持最大 %wx%hpx 的图片。","File: %s":"文件: %s","b":"b","Uploaded %d/%d files":"已上传 %d/%d 个文件","Upload element accepts only %d file(s) at a time. Extra files were stripped.":"每次只接受同时上传 %d 个文件,多余的文件将会被删除。","%d files queued":"%d 个文件加入到队列","File: %s, size: %d, max file size: %d":"文件: %s, 大小: %d, 最大文件大小: %d","Thumbnails":"缩略图","Drag files here.":"把文件拖到这里。","Runtime ran out of available memory.":"运行时已消耗所有可用内存。","File count error.":"文件数量错误。","File extension error.":"文件扩展名错误。","mb":"mb","Add Files":"增加文件"});
\ No newline at end of file
// Chinese (Taiwan) (zh_TW)
plupload.addI18n({"Stop Upload":"停止上傳","Upload URL might be wrong or doesn't exist.":"檔案URL可能有誤或者不存在。","tb":"tb","Size":"大小","Close":"關閉","You must specify either browse_button or drop_element.":"","Init error.":"初始化錯誤。","Add files to the upload queue and click the start button.":"將檔案加入上傳序列,然後點選”開始上傳“按鈕。","List":"","Filename":"檔案名稱","%s specified, but cannot be found.":"","Image format either wrong or not supported.":"圖片格式錯誤或者不支援。","Status":"狀態","HTTP Error.":"HTTP 錯誤。","Start Upload":"開始上傳","Error: File too large:":"錯誤: 檔案大小太大:","kb":"kb","Duplicate file error.":"錯誤:檔案重複。","File size error.":"錯誤:檔案大小超過限制。","N/A":"N/A","gb":"gb","Error: Invalid file extension:":"錯誤:不接受的檔案格式:","Select files":"選擇檔案","%s already present in the queue.":"%s 已經存在目前的檔案序列。","Resoultion out of boundaries! <b>%s</b> runtime supports images only up to %wx%hpx.":"","File: %s":"檔案: %s","b":"b","Uploaded %d/%d files":"已上傳 %d/%d 個文件","Upload element accepts only %d file(s) at a time. Extra files were stripped.":"每次只能上傳 %d 個檔案,超過限制數量的檔案將被忽略。","%d files queued":"%d 個檔案加入到序列","File: %s, size: %d, max file size: %d":"檔案: %s, 大小: %d, 檔案大小上限: %d","Thumbnails":"","Drag files here.":"把檔案拖曳到這裡。","Runtime ran out of available memory.":"執行時耗盡了所有可用的記憶體。","File count error.":"檔案數量錯誤。","File extension error.":"檔案副檔名錯誤。","mb":"mb","Add Files":"增加檔案"});
\ No newline at end of file
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
videojs.addLanguage("zh-CN",{
"Play": "播放",
"Pause": "暂停",
"Current Time": "当前时间",
"Duration Time": "时长",
"Remaining Time": "剩余时间",
"Stream Type": "媒体流类型",
"LIVE": "直播",
"Loaded": "加载完毕",
"Progress": "进度",
"Fullscreen": "全屏",
"Non-Fullscreen": "退出全屏",
"Mute": "静音",
"Unmute": "取消静音",
"Playback Rate": "播放码率",
"Subtitles": "字幕",
"subtitles off": "字幕关闭",
"Captions": "内嵌字幕",
"captions off": "内嵌字幕关闭",
"Chapters": "节目段落",
"You aborted the media playback": "视频播放被终止",
"A network error caused the media download to fail part-way.": "网络错误导致视频下载中途失败。",
"The media could not be loaded, either because the server or network failed or because the format is not supported.": "视频因格式不支持或者服务器或网络的问题无法加载。",
"The media playback was aborted due to a corruption problem or because the media used features your browser did not support.": "由于视频文件损坏或是该视频使用了你的浏览器不支持的功能,播放终止。",
"No compatible source was found for this media.": "无法找到此视频兼容的源。",
"The media is encrypted and we do not have the keys to decrypt it.": "视频已加密,无法解密。"
});
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
/**
* Created by pader on 16/9/28.
*/
var Vue = require('vue');
var videoUpload = require('../components/common/video-upload.vue');
var thumbUpload = require('../components/common/thumb-upload.vue');
var form = document.forms["coursePublish"];
var vm = new Vue({
el: '#publishMain',
data: {
videoKey: "",
previewKey: ""
},
components: {
videoUpload: videoUpload,
thumbUpload: thumbUpload
},
ready: function() {
var self = this;
this.$on("video-uploaded", function(name, data) {
self.videoKey = data.key;
});
this.$on("thumb-uploaded", function(name, data) {
self.previewKey = data.key;
});
}
});
require.ensure("jquery-validation", function() {
require('jquery-validation');
$(form).validate({
debug: true,
rules: {
required: true
}
});
});
/**
* Created by xiabin on 2016/9/29.
*/
layer.msg('玩命提示中');
\ No newline at end of file
/**
* Created by xiabin on 2016/9/29.
*/
layer.msg('玩命提示中');
/**
* Created by xiabin on 2016/9/29.
*/
layer.msg('玩命提示中');
var token = $('#avatar-uploader').attr('token');
require.ensure('../single-lib/plupload/plupload.full.min.js', function () {
require('script!../single-lib/plupload/plupload.full.min.js');
var uploader = new plupload.Uploader({
runtimes: 'html5,flash,html4',
browse_button: 'avatar-uploader',
url: "http://upload.qiniu.com/",
multipart_params: {
token: token
},
max_file_size: '5MB',
flash_swf_url: __CDN_URL__ + 'assets/single-lib/plupload/Moxie.swf',
max_retries: 0,
dragdrop: false,
multi_selection: false,
auto_start: true,
init: {
'FilesAdded': function (up, files) {
// plupload.each(files, function (file) {
// ready.find(".upload-info-size").text(filesize(file.origSize));
// ready.find("h3").text(file.name);
// });
//
// container.find(".upload-video-btn").hide();
// ready.show();
//
up.start();
up.disableBrowse();
//
// startTime = (new Date()).getTime();
},
'BeforeUpload': function (up, file) {
// 每个文件上传前,处理相关的事情
},
'UploadProgress': function (up, file) {
// progress.css("width", file.percent + "%");
// infoProgress.text(file.percent);
// infoSpeed.text(filesize(up.total.bytesPerSec));
//
// // var avgSpeed = file.loaded / (((new Date()).getTime() - startTime) / 1000);
//
// var sizeRemain = file.origSize - file.loaded;
// var leftSeconds = sizeRemain / up.total.bytesPerSec;
// var toDate = new Date();
// toDate.setTime((new Date()).getTime() + leftSeconds * 1000);
// infoRemain.text(moment(toDate).toNow(true));
// infoProgress.text(file.percent);
// $("#" + file.id + " .attachup-list-element-status").html("上传中 - " + file.percent + "%");
},
'FileUploaded': function (up, file, info) {
// 每个文件上传成功后,处理相关的事情
// 其中info是文件上传成功后,服务端返回的json,形式如:
// {
// "hash": "Fh8xVqod2MQ1mocfI4S4KpRL6D98",
// "key": "gogopher.jpg"
// }
// 查看简单反馈
var res = JSON.parse(info.response);
var url = __QINIU_URL__ + res.key;
$.getJSON(__BASE_URL__ + 'user-center/set-vatar-info?key=' + res.key, function (reponse) {
if (reponse.status) {
window.location.reload();
}
}).error(function () {
layer.alert('设置头像信息接口错误', {'icon': 2, 'title': '提示'});
});
},
'Error': function (up, err, errTip) {
//上传出错时,处理相关的事情
},
'UploadComplete': function () {
//队列文件处理完毕后,处理相关的事情
}
}
});
uploader.init()
});
/**
* Created by xiabin on 2016/9/29.
*/
layer.msg('玩命提示中');
/**
* Created by pader on 16/9/30.
*
* 七牛上传组件
*
* e.g.
* //建议使用 require.ensure 方式加载
* var qiniu = require("utils/qiniu.js");
*
* var uploader = new qiniu.Uploader({
* upload_token: "<UPLOAD_TOKEN>",
* ..其它参数与 plupload 一致
* });
*
* uploader.init();
*/
require("script!../libs/plupload/plupload.full.min.js");
module.exports = {
Uploader: function(option) {
var setting = {
runtimes: 'html5,flash,html4',
url: "http://upload.qiniu.com/",
multipart_params: {},
flash_swf_url: __CDN_URL__ + 'assets/plupload/Moxie.swf',
max_retries: 0
};
if (!option.multipart_params) {
option.multipart_params = {};
}
option.multipart_params.token = option.upload_token;
delete option.upload_token;
$.extend(true, option, setting);
return (new plupload.Uploader(option));
}
};
\ No newline at end of file
/**
* Created by pader on 16/10/8.
*/
module.exports = {
/**
* 简单的生成一段随机字符串
*
* @param {int} len 字符串长度
* @returns {string}
*/
rand: function(len) {
var x="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",tmp="";
for(var i=0;i<len;i++){tmp+=x.charAt(Math.ceil(Math.random()*100000000)%x.length);}
return tmp;
}
};
\ No newline at end of file
......@@ -39,8 +39,11 @@
"webpack": "^1.12.2"
},
"dependencies": {
"file-size": "^1.0.0",
"jquery": "~2.2.2",
"jquery-validation": "^1.15.1",
"moment": "^2.13.0",
"video.js": "^5.11.7",
"vue": "^1.0.8"
}
}
\ No newline at end of file
}
......@@ -11,12 +11,18 @@ var ExtractTextPlugin = require("extract-text-webpack-plugin");
var entry = {
vendor: ["jquery", "vue", js_dir + "/utils/layer"],
site: [css_dir + '/site.css'],
style: [css_dir + '/reset.css', css_dir + '/style.css'],
signup: [js_dir + '/site/signup.js'],
login: [js_dir + '/site/login.js'],
request_password_reset: [js_dir + '/site/request_password_reset']
request_password_reset: [js_dir + '/site/request_password_reset'],
user_center_info: [js_dir + '/user-center/info.js'],
user_favorite: [js_dir + '/user-center/favorite.js'],
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']
};
var config = {
entry: entry,
output: {
......@@ -62,7 +68,9 @@ var config = {
new CopyWebpackPlugin([
// {from: __dirname + '/resource', to: 'resource'},
{from: lib_dir + '/layer', to: 'layer'},
// {from: img_dir, to: 'img'},
{from: img_dir, to: 'img'},
{from: lib_dir + '/videojs/video-js.swf', to: 'libs/videojs/'},
{from: lib_dir + '/plupload', to: 'plupload'},
// {from: manage_dir + '/dist', to: 'manage/dist'},
// {from: manage_dir + '/plugins', to: 'manage/plugins'},
// {from: manage_dir + '/bootstrap', to: 'manage/bootstrap'}
......@@ -74,11 +82,12 @@ var config = {
'js-dir': js_dir,
'css-dir': css_dir,
'layer-js': lib_dir + '/layer/2.4/layer.js',
'plupload-js': lib_dir + '/plupload/plupload.full.min.js',
'qiniu-js': lib_dir + '/qiniu/qiniu.js',
'helper': js_dir + '/helper/helper.js',
'helper-dir': js_dir + '/helper'
}
}
};
......@@ -114,8 +123,8 @@ if (process.env.NODE_ENV === 'production') {
config.plugins = config.plugins.concat([
new webpack.DefinePlugin({
__BASE_URL__: JSON.stringify('http://dev.zuiketang.com/'),
__CDN_URL__: JSON.stringify('http://dev.zuiketang.com/')
__CDN_URL__: JSON.stringify('http://dev.zuiketang.com/'),
__QINIU_URL__: JSON.stringify('http://dev.qdn.pp.cc/'),
}),
]);
// config.devtool = 'source-map'
......
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