Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zuiketang
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏彬
zuiketang
Commits
e0009e36
Commit
e0009e36
authored
Oct 12, 2016
by
汪波
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://gitlab.fingerage.com:999/xiabin/zuiketang
parents
8d1708c9
bed5a1ce
Changes
50
Hide whitespace changes
Inline
Side-by-side
Showing
50 changed files
with
1879 additions
and
264 deletions
+1879
-264
Qiniu.php
src/common/components/Qiniu.php
+8
-1
Utils.php
src/common/libs/Utils.php
+20
-1
AttachUploadForm.php
src/common/models/AttachUploadForm.php
+171
-0
ClassesTeacher.php
src/common/models/ClassesTeacher.php
+23
-0
Comments.php
src/common/models/Comments.php
+30
-1
Course.php
src/common/models/Course.php
+57
-25
CourseTeacher.php
src/common/models/CourseTeacher.php
+34
-0
Courseware.php
src/common/models/Courseware.php
+37
-5
Favorite.php
src/common/models/Favorite.php
+13
-0
Support.php
src/common/models/Support.php
+1
-1
Teacher.php
src/common/models/Teacher.php
+22
-4
UploadPools.php
src/common/models/UploadPools.php
+12
-4
m161010_075253_upload_attachments_init.php
...ole/migrations/m161010_075253_upload_attachments_init.php
+39
-0
HomeController.php
src/frontend/controllers/HomeController.php
+95
-16
MyCourseController.php
src/frontend/controllers/MyCourseController.php
+242
-8
SiteController.php
src/frontend/controllers/SiteController.php
+2
-8
TeacherManagerController.php
src/frontend/controllers/TeacherManagerController.php
+24
-3
UserCenterController.php
src/frontend/controllers/UserCenterController.php
+20
-9
CoursePublishForm.php
src/frontend/models/CoursePublishForm.php
+64
-2
center.php
src/frontend/views/layouts/center.php
+76
-0
centerHeader.php
src/frontend/views/layouts/centerHeader.php
+12
-0
classCenter.php
src/frontend/views/layouts/classCenter.php
+61
-0
main.php
src/frontend/views/layouts/main.php
+1
-7
userCenter.php
src/frontend/views/layouts/userCenter.php
+118
-0
publish.php
src/frontend/views/my-course/publish.php
+11
-9
result.php
src/frontend/views/my-course/result.php
+18
-0
browseRecord.php
src/frontend/views/user-center/browseRecord.php
+126
-0
browse_record.php
src/frontend/views/user-center/browse_record.php
+0
-15
favorite.php
src/frontend/views/user-center/favorite.php
+113
-6
info.php
src/frontend/views/user-center/info.php
+33
-7
purchasedCourse.php
src/frontend/views/user-center/purchasedCourse.php
+122
-0
purchased_course.php
src/frontend/views/user-center/purchased_course.php
+0
-15
reset.css
src/frontend/web/css/reset.css
+0
-1
style.css
src/frontend/web/css/style.css
+58
-0
placeholder.jpg
src/frontend/web/img/placeholder.jpg
+0
-0
thumb-upload.vue
src/frontend/web/js/components/uploader/thumb-upload.vue
+61
-64
video-upload.vue
src/frontend/web/js/components/uploader/video-upload.vue
+2
-2
publish.js
src/frontend/web/js/my-course/publish.js
+102
-18
request_password_reset.js
src/frontend/web/js/site/request_password_reset.js
+1
-1
signup.js
src/frontend/web/js/site/signup.js
+1
-1
token_input.js
src/frontend/web/js/site/token_input.js
+1
-1
browse_record.js
src/frontend/web/js/user-center/browse_record.js
+1
-2
favorite.js
src/frontend/web/js/user-center/favorite.js
+0
-1
info.js
src/frontend/web/js/user-center/info.js
+12
-22
purchased_course.js
src/frontend/web/js/user-center/purchased_course.js
+0
-1
file.js
src/frontend/web/js/utils/file.js
+26
-0
simditor.js
src/frontend/web/js/utils/simditor.js
+5
-0
package.json
src/frontend/web/package.json
+1
-0
webpack.config.js
src/frontend/web/webpack.config.js
+1
-1
my-浏览记录.html
ui/html/my-浏览记录.html
+2
-2
No files found.
src/common/components/Qiniu.php
View file @
e0009e36
...
...
@@ -67,7 +67,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
;
}
...
...
src/common/libs/Utils.php
View file @
e0009e36
...
...
@@ -28,8 +28,8 @@ class Utils
/**
* @param bool $status
* @param null $data
* @param null $messgae
* @param null $data
*/
public
static
function
ajaxResponse
(
$status
=
TRUE
,
$messgae
=
NULL
,
$data
=
NULL
)
{
...
...
@@ -42,6 +42,25 @@ 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
;
}
/**
* 生成4-6位随机数
* @param int $length
...
...
src/common/models/AttachUploadForm.php
0 → 100644
View file @
e0009e36
<?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
src/common/models/ClassesTeacher.php
View file @
e0009e36
...
...
@@ -68,5 +68,28 @@ 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
* @return array
*/
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
;
}
}
src/common/models/Comments.php
View file @
e0009e36
...
...
@@ -3,6 +3,8 @@
namespace
common\models
;
use
Yii
;
use
yii\behaviors\TimestampBehavior
;
use
yii\db\ActiveRecord
;
/**
* This is the model class for table "comments".
...
...
@@ -25,13 +27,29 @@ class Comments extends \yii\db\ActiveRecord
return
'comments'
;
}
/**
* @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'
,
'parent_id'
,
'content'
,
'ip'
,
'created_at'
],
'required'
],
[[
'user_id'
,
'course_id'
,
'parent_id'
,
'content'
,
'ip'
],
'required'
],
[[
'user_id'
,
'course_id'
,
'parent_id'
,
'created_at'
],
'integer'
],
[[
'content'
],
'string'
],
[[
'ip'
],
'string'
,
'max'
=>
32
],
...
...
@@ -53,4 +71,15 @@ class Comments extends \yii\db\ActiveRecord
'created_at'
=>
'Created At'
,
];
}
/**
* 根据id判断数据是否存在
* @param $id
* @return bool
*/
public
static
function
existById
(
$id
)
{
$result
=
self
::
find
()
->
select
(
'id'
)
->
where
(
'id=:id'
,
[
':id'
=>
$id
])
->
one
();
return
$result
===
NULL
?
FALSE
:
TRUE
;
}
}
src/common/models/Course.php
View file @
e0009e36
...
...
@@ -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,31 @@ 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'
=>
'预览图'
];
}
/**
* 根据id判断数据是否存在
* @param $id
* @return bool
*/
public
static
function
existById
(
$id
)
{
$result
=
self
::
find
()
->
select
(
'id'
)
->
where
(
'id=:id'
,
[
':id'
=>
$id
])
->
one
();
return
$result
===
NULL
?
FALSE
:
TRUE
;
}
public
static
function
getBasicData
(
$id
)
{
$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
();
}
}
src/common/models/CourseTeacher.php
0 → 100644
View file @
e0009e36
<?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'
],
];
}
}
src/common/models/Courseware.php
View file @
e0009e36
...
...
@@ -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
]
];
}
...
...
@@ -62,4 +67,31 @@ class Courseware extends \yii\db\ActiveRecord
'updated_at'
=>
'Updated At'
,
];
}
/**
* @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
* @return bool
*/
public
static
function
existById
(
$id
)
{
$result
=
self
::
find
()
->
select
(
'id'
)
->
where
(
'id=:id'
,
[
':id'
=>
$id
])
->
one
();
return
$result
===
NULL
?
FALSE
:
TRUE
;
}
}
src/common/models/Favorite.php
View file @
e0009e36
...
...
@@ -79,4 +79,17 @@ class Favorite extends \yii\db\ActiveRecord
':user_id'
=>
$userId
])
->
join
(
'left join'
,
$tableB
,
"
$tableA
.user_id=
$tableB
.id"
)
->
asArray
()
->
all
();
}
/**
* 判断该用户是否收藏了该课堂
* @param $userId
* @param $courseId
* @return array|null|ActiveRecord
*/
public
static
function
findByUserIdAndCourseId
(
$userId
,
$courseId
)
{
return
self
::
find
()
->
select
(
'id,user_id,course_id,created_at'
)
->
where
(
"user_id=:user_id and course_id=:course_id"
,
[
'user_id'
=>
$userId
,
'course_id'
=>
$courseId
])
->
one
();
}
}
src/common/models/Support.php
View file @
e0009e36
...
...
@@ -75,6 +75,6 @@ class Support extends \yii\db\ActiveRecord
{
return
self
::
find
()
->
select
(
'id,user_id,courseware_id,created_at'
)
->
where
(
"user_id=:user_id and courseware_id=:courseware_id"
,
[
'user_id'
=>
$userId
,
'courseware_id'
=>
$coursewareId
])
->
asArray
()
->
one
();
->
one
();
}
}
src/common/models/Teacher.php
View file @
e0009e36
...
...
@@ -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,7 +36,7 @@ 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
],
...
...
@@ -42,6 +44,24 @@ class Teacher 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'
],
]
// if you're using datetime instead of UNIX timestamp:
// 'value' => new Expression('NOW()'),
]
];
}
/**
* @inheritdoc
*/
...
...
@@ -65,8 +85,6 @@ class Teacher extends \yii\db\ActiveRecord
$model
->
name
=
$name
;
$model
->
avatar
=
'avatar/f6/98/c6/_tjy7DgC0641.jpg'
;
$model
->
intro
=
'这个家伙很懒,什么也没有写。'
;
$model
->
created_at
=
time
();
$model
->
updated_at
=
time
();
if
(
$model
->
save
())
{
return
$model
->
toArray
();
...
...
src/common/models/UploadPools.php
View file @
e0009e36
...
...
@@ -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
;
...
...
src/console/migrations/m161010_075253_upload_attachments_init.php
0 → 100644
View file @
e0009e36
<?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()
{
}
*/
}
src/frontend/controllers/HomeController.php
View file @
e0009e36
...
...
@@ -2,12 +2,49 @@
namespace
frontend\controllers
;
use
common\models\Comments
;
use
common\models\Course
;
use
common\models\Courseware
;
use
common\models\Favorite
;
use
common\models\Support
;
use
Yii
;
use
common\libs\Utils
;
use
yii\base\InvalidParamException
;
use
yii\filters\AccessControl
;
use
yii\helpers\Html
;
class
HomeController
extends
\yii\web\Controller
{
/**
* @inheritdoc
*/
public
function
behaviors
()
{
return
[
//权限限制
'access'
=>
[
'class'
=>
AccessControl
::
className
(),
'only'
=>
[
'support'
,
'favorite'
,
'comments'
],
'rules'
=>
[
[
'allow'
=>
TRUE
,
'actions'
=>
[
'support'
,
'favorite'
],
'roles'
=>
[
'@'
],
],
[
'allow'
=>
TRUE
,
'actions'
=>
[
'comments'
],
'roles'
=>
[
'@'
],
'verbs'
=>
[
'POST'
]
],
],
]
];
}
public
function
actionIndex
()
{
return
$this
->
render
(
'index'
);
...
...
@@ -21,20 +58,23 @@ class HomeController extends \yii\web\Controller
*/
public
function
actionSupport
(
$coursewareId
)
{
if
(
Yii
::
$app
->
request
->
isAjax
)
{
$userId
=
Yii
::
$app
->
user
->
identity
->
getId
();
$support
=
Support
::
findByUserIdAndCoursewareId
(
$userId
,
$coursewareId
);
//没有点赞则点赞否则则取消点赞
if
(
count
(
$support
)
===
0
)
{
$support
=
new
Support
();
$support
->
user_id
=
$userId
;
$support
->
courseware_id
=
$coursewareId
;
$support
->
save
();
if
(
Courseware
::
existById
(
$coursewareId
))
{
$support
=
Support
::
findByUserIdAndCoursewareId
(
$userId
,
$coursewareId
);
//没有点赞则点赞否则则取消点赞
if
(
$support
===
NULL
)
{
$support
=
new
Support
();
$support
->
user_id
=
$userId
;
$support
->
courseware_id
=
$coursewareId
;
$result
=
$support
->
save
();
}
else
{
$result
=
$support
->
delete
();
}
Utils
::
ajaxResponse
(
$result
);
}
else
{
Support
::
deleteAll
(
'id=:id'
,
[
'id'
=>
$support
[
'id'
]]);
}
Utils
::
ajaxResponse
(
TRUE
);
throw
new
InvalidParamException
(
'参数错误'
);
};
}
else
{
throw
new
\yii\web\ForbiddenHttpException
(
'非法请求'
);
}
...
...
@@ -49,10 +89,23 @@ class HomeController extends \yii\web\Controller
public
function
actionFavorite
(
$courseId
)
{
if
(
Yii
::
$app
->
request
->
isAjax
)
{
$userId
=
Yii
::
$app
->
user
->
identity
->
getId
();
//数据不存在则异常
if
(
Course
::
existById
([
'id'
=>
$courseId
]))
{
$favorite
=
Favorite
::
findByUserIdAndCourseId
(
$userId
,
$courseId
);
if
(
$favorite
===
NULL
)
{
$favorite
=
new
Favorite
();
$favorite
->
user_id
=
$userId
;
$favorite
->
course_id
=
$courseId
;
$result
=
$favorite
->
save
();
}
else
{
$result
=
$favorite
->
delete
();
}
Utils
::
ajaxResponse
(
$result
);
Utils
::
ajaxResponse
(
TRUE
,
$courseId
,
$userId
);
}
else
{
throw
new
InvalidParamException
(
'参数错误'
);
}
}
else
{
throw
new
\yii\web\ForbiddenHttpException
(
'非法请求'
);
...
...
@@ -66,10 +119,36 @@ class HomeController extends \yii\web\Controller
*/
public
function
actionComments
()
{
if
(
Yii
::
$app
->
request
->
isAjax
)
{
$userId
=
Yii
::
$app
->
user
->
identity
->
getId
();
$request
=
Yii
::
$app
->
request
;
if
(
$request
->
isAjax
)
{
$parentId
=
$request
->
post
(
'parent-id'
);
$content
=
Html
::
encode
(
$request
->
post
(
'content'
));
$courseId
=
$request
->
post
(
'course-id'
);
//0代表为一级评论不需要验证
if
(
$parentId
==
0
)
{
$parentStatus
=
TRUE
;
}
else
{
$parentStatus
=
Comments
::
existById
(
$parentId
);
}
if
(
$parentStatus
and
Course
::
existById
(
$courseId
)
and
$content
!==
NULL
)
{
$userId
=
Yii
::
$app
->
user
->
identity
->
getId
();
$comments
=
new
Comments
();
$comments
->
user_id
=
$userId
;
$comments
->
parent_id
=
$parentId
;
$comments
->
course_id
=
$courseId
;
$comments
->
content
=
$content
;
$comments
->
ip
=
Utils
::
getRealIP
();
$result
=
$comments
->
save
();
Utils
::
ajaxResponse
(
$result
,
(
$result
===
FALSE
)
?
$comments
->
getErrors
()
:
NULL
);
Utils
::
ajaxResponse
(
TRUE
,
''
,
$userId
);
}
else
{
throw
new
InvalidParamException
(
'参数错误'
);
}
}
else
{
throw
new
\yii\web\ForbiddenHttpException
(
'非法请求'
);
}
...
...
src/frontend/controllers/MyCourseController.php
View file @
e0009e36
<?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
Qiniu\Storage\BucketManager
;
use
Yii
;
use
yii\filters\AccessControl
;
use
yii\web\Response
;
use
yii\web\UploadedFile
;
class
MyCourseController
extends
\yii\web\Controller
{
public
$layout
=
'user-center'
;
public
$layout
=
'classCenter'
;
/**
* @inheritdoc
*/
public
function
behaviors
()
{
return
[
'access'
=>
[
'class'
=>
AccessControl
::
className
(),
//'only' => ['index', 'publish', 'submit'],
'rules'
=>
[
[
'allow'
=>
TRUE
,
'roles'
=>
[
'@'
],
]
],
]
];
}
public
function
actionIndex
()
{
return
$this
->
render
(
'index'
);
//
return $this->render('index');
}
/**
* 发布课程
*
* @return string
*/
public
function
actionPublish
()
{
/* @var \common\components\Qiniu $qiniu */
...
...
@@ -24,16 +58,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)'
);
$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'
=>
$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'
));
}
}
src/frontend/controllers/SiteController.php
View file @
e0009e36
...
...
@@ -65,13 +65,7 @@ class SiteController extends Controller
'roles'
=>
[
'?'
],
],
],
],
'verbs'
=>
[
'class'
=>
VerbFilter
::
className
(),
'actions'
=>
[
'logout'
=>
[
'post'
],
],
],
]
];
}
...
...
@@ -196,7 +190,7 @@ class SiteController extends Controller
}
}
}
else
{
$model
->
addError
(
'token'
,
'验证码错误'
);
$model
->
addError
(
'token'
,
'验证码错误'
);
}
}
...
...
src/frontend/controllers/TeacherManagerController.php
View file @
e0009e36
...
...
@@ -4,11 +4,32 @@ namespace frontend\controllers;
use
common\models\Teacher
;
use
common\models\ClassesTeacher
;
use
Yii
;
use
yii\filters\AccessControl
;
class
TeacherManagerController
extends
\yii\web\Controller
{
public
$layout
=
'user-center'
;
/**
* @inheritdoc
*/
public
function
behaviors
()
{
return
[
'access'
=>
[
'class'
=>
AccessControl
::
className
(),
//'only' => ['index', 'publish', 'submit'],
'rules'
=>
[
[
'allow'
=>
TRUE
,
'roles'
=>
[
'@'
],
]
],
]
];
}
public
function
actionIndex
()
{
return
$this
->
render
(
'index'
);
...
...
@@ -31,13 +52,13 @@ class TeacherManagerController extends \yii\web\Controller
public
function
actionAddTeacher
()
{
//Todo: 假设数据
$uid
=
18
;
$uid
=
Yii
::
$app
->
user
->
identity
->
getId
();
;
$classId
=
1
;
$response
=
\
Yii
::
$app
->
response
;
$response
=
Yii
::
$app
->
response
;
$response
->
format
=
\yii\web\Response
::
FORMAT_JSON
;
$name
=
strip_tags
(
\
Yii
::
$app
->
request
->
post
(
'name'
));
$name
=
strip_tags
(
Yii
::
$app
->
request
->
post
(
'name'
));
$teacher
=
Teacher
::
simpleAddTeacher
(
$name
);
if
(
$teacher
)
{
...
...
src/frontend/controllers/UserCenterController.php
View file @
e0009e36
...
...
@@ -14,17 +14,19 @@ use common\libs\Utils;
use
common\models\BrowseRecord
;
use
common\models\Favorite
;
use
common\models\Orders
;
use
common\models\UploadPools
;
use
common\models\User
;
use
yii\base\ErrorException
;
use
yii\base\Exception
;
use
yii\filters\AccessControl
;
use
yii\helpers\Html
;
use
yii\web\Controller
;
use
Yii
;
class
UserCenterController
extends
Controller
{
public
$layout
=
'user
-c
enter'
;
public
$layout
=
'user
C
enter'
;
public
$defaultAction
=
'info'
;
...
...
@@ -75,8 +77,8 @@ class UserCenterController extends Controller
public
function
actionPurchasedCourse
()
{
$purchasedCourse
=
Orders
::
getPurchasedCourseByUserId
(
Yii
::
$app
->
user
->
getId
());
var_dump
(
$purchasedCourse
);
return
$this
->
render
(
'purchased
_c
ourse'
);
//
var_dump($purchasedCourse);
return
$this
->
render
(
'purchased
C
ourse'
);
}
/**
...
...
@@ -87,7 +89,6 @@ class UserCenterController extends Controller
{
$favorite
=
Favorite
::
getByUserId
(
Yii
::
$app
->
user
->
getId
());
var_dump
(
$favorite
);
return
$this
->
render
(
'favorite'
);
}
...
...
@@ -98,8 +99,7 @@ class UserCenterController extends Controller
public
function
actionBrowseRecord
()
{
$browseRecord
=
BrowseRecord
::
getByUserId
(
Yii
::
$app
->
user
->
getId
());
var_dump
(
$browseRecord
);
return
$this
->
render
(
'browse_record'
);
return
$this
->
render
(
'browseRecord'
);
}
...
...
@@ -121,9 +121,20 @@ class UserCenterController extends Controller
$msg
=
'昵称超过长度限制'
;
}
else
{
$user
=
Yii
::
$app
->
user
->
identity
;
$user
->
avatar
=
$avatar
;
$user
->
username
=
$username
;
$user
->
save
();
$oldAvatar
=
FALSE
;
//标记是否进行资源清理
if
(
$user
->
avatar
!==
$avatar
)
{
$oldAvatar
=
$user
->
avatar
;
}
}
$user
->
avatar
=
Html
::
encode
(
$avatar
);
$user
->
username
=
Html
::
encode
(
$username
);
$user
->
save
();
//资源清理
if
(
$oldAvatar
)
{
//删除
UploadPools
::
deleteFile
(
UploadPools
::
getSkey
(
'public'
,
$oldAvatar
));
//认领资源
UploadPools
::
claimFileBySkey
(
UploadPools
::
getSkey
(
'public'
,
$avatar
));
}
Utils
::
ajaxResponse
(
$status
,
$msg
);
}
else
{
...
...
src/frontend/models/CoursePublishForm.php
View file @
e0009e36
...
...
@@ -5,11 +5,14 @@
* Date: 16/9/28
* Time: 17:43
*/
namespace
frontend\models
;
use
common\models\CourseTeacher
;
use
yii\behaviors\TimestampBehavior
;
use
yii\db\ActiveRecord
;
use
yii\helpers\HtmlPurifier
;
class
CoursePublishForm
extends
\yii\base\Model
class
CoursePublishForm
extends
ActiveRecord
{
public
$name
;
...
...
@@ -20,10 +23,69 @@ class CoursePublishForm extends \yii\base\Model
public
$intro
;
public
$preview
;
public
$recommend
;
public
$status
;
public
$create_at
;
public
$update_at
;
public
function
formName
()
{
return
""
;
}
/**
* @inheritdoc
*/
public
function
attributeLabels
()
{
return
[
'name'
=>
'标题'
,
'avatar'
=>
'Avatar'
,
'intro'
=>
'Intro'
,
'created_at'
=>
'Created At'
,
'updated_at'
=>
'Updated At'
,
];
}
/**
* @inheritdoc
*/
public
function
beforeSave
(
$insert
)
{
if
(
!
parent
::
beforeSave
(
$insert
))
{
return
false
;
}
$this
->
intro
=
HtmlPurifier
::
process
(
$this
->
intro
);
return
true
;
}
public
function
rules
()
{
return
[
[[
'name'
,
'video'
,
'preview'
],
'required'
],
[
'name'
,
'string'
,
'length'
=>
[
1
,
60
]],
[
'teacher'
,
'exist'
,
'targetAttribute'
=>
'teacher_id'
,
'targetClass'
=>
CourseTeacher
::
className
(),
'allowArray'
=>
true
],
[
'prirce'
,
'integer'
,
'min'
=>
0
,
'max'
=>
9999
],
[
'free_time'
,
'integer'
,
'min'
=>
0
,
'max'
=>
15
],
[
'recommend'
,
'boolean'
],
[
'status'
,
'in'
,
'range'
=>
[
0
,
1
,
2
,
3
]]
];
}
/**
* @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()'),
]
];
}
...
...
src/frontend/views/layouts/
user-
center.php
→
src/frontend/views/layouts/center.php
View file @
e0009e36
...
...
@@ -47,71 +47,27 @@ $(function() {
JS;
$this
->
registerJs
(
$js
,
View
::
POS_END
);
$this
->
registerCss
(
'[v-cloak] {display:none;}'
);
?>
<?php
$this
->
beginPage
()
?>
<!DOCTYPE html>
<html
lang=
"
<?=
\Yii
::
$app
->
language
?>
"
>
<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
()
?>
<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>
<?=
$content
?>
<div
class=
"foot navbar-fixed-bottom"
>
<p><a
href=
"#"
>
隐私权政策
</a>
-
<a
href=
"#"
>
服务条款
</a>
-
<a
href=
"#
"
>
地图条款
</a></p>
<p>
©2016 Zuiketang.com
</p>
<p><a
href=
"javascript:;"
>
隐私权政策
</a>
-
<a
href=
"javascript:;"
>
服务条款
</a>
-
<a
href=
"javascript:;
"
>
地图条款
</a></p>
<p>
©2016 Zuiketang.com
</p>
</div>
<?php
$this
->
endBody
();
?>
...
...
src/frontend/views/layouts/centerHeader.php
0 → 100644
View file @
e0009e36
<?php
/**
* Created by PhpStorm.
* User: xiabin
* Date: 2016/10/10
* Time: 下午1:47
*/
?>
<div
class=
"tp-head navbar-fixed-top clearfix"
>
<div
class=
"menu-btn fl"
><a
href=
"javascript:;"
><i
class=
"icon-menu"
></i></a></div>
<div
class=
"avatar fr"
><a
href=
"
<?=
\yii\helpers\Url
::
base
()
.
'user-center'
?>
"
><img
src=
"
<?=
Yii
::
$app
->
assetManager
->
baseUrl
?>
/img/avatar.jpg"
></a></div>
</div>
src/frontend/views/layouts/classCenter.php
0 → 100644
View file @
e0009e36
<?php
use
yii\helpers\Html
;
use
yii\web\View
;
use
frontend\assets\AppAsset
;
/* @var $this \yii\web\View */
/* @var $content string */
$this
->
beginPage
();
$this
->
beginBody
();
$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>
<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"
>
<?=
$this
->
render
(
'centerHeader'
)
?>
<div
class=
"tp-main"
>
<div
class=
"container"
>
<?=
$content
?>
</div>
</div>
</div>
<?php
$this
->
endContent
();
$this
->
endBody
();
$this
->
endPage
();
src/frontend/views/layouts/main.php
View file @
e0009e36
...
...
@@ -38,13 +38,7 @@ $baseUrl = \yii\helpers\Url::base();
<li><a
href=
"
<?=
$baseUrl
.
"/site/signup"
?>
"
>
注册
</a></li>
<?php
else
:
?>
<?=
'<li>'
.
Html
::
beginForm
([
'/site/logout'
],
'post'
)
.
Html
::
submitButton
(
'Logout ('
.
Yii
::
$app
->
user
->
identity
->
username
.
')'
)
.
Html
::
endForm
()
.
'</li>'
;
?>
<?php
endif
;
?>
</ul>
...
...
src/frontend/views/layouts/userCenter.php
0 → 100644
View file @
e0009e36
<?php
use
yii\helpers\Html
;
use
yii\web\View
;
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
);
?>
<?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
src=
"
<?=
AppAsset
::
getStaticUrl
(
'img/logo.png'
)
?>
"
></a></div>
<div
class=
"side-menu"
>
<!-- 左侧菜单 -->
<ul
class=
"simple-menu"
>
<li
<?=
(
Yii
::
$app
->
controller
->
id
===
'user-center'
and
Yii
::
$app
->
controller
->
action
->
id
===
'info'
)
?
'class = "active"'
:
''
?>
>
<a
href=
"
<?=
$baseUrl
.
'/user-center'
?>
"
><i
class=
"glyphicon glyphicon-th-list"
></i>
基本信息
</a>
</li>
<li
<?=
(
Yii
::
$app
->
controller
->
id
===
'user-center'
and
Yii
::
$app
->
controller
->
action
->
id
===
'purchased-course'
)
?
'class = "active"'
:
''
?>
>
<a
href=
"
<?=
$baseUrl
.
'/user-center/purchased-course'
?>
"
><i
class=
"glyphicon glyphicon-ok"
></i>
已购课程
</a></li>
<li
<?=
(
Yii
::
$app
->
controller
->
id
===
'user-center'
and
Yii
::
$app
->
controller
->
action
->
id
===
'favorite'
)
?
'class = "active"'
:
''
?>
>
<a
href=
"
<?=
$baseUrl
.
'/user-center/favorite'
?>
"
><i
class=
"glyphicon glyphicon-star"
></i>
收藏纪录
</a>
</li>
<li
<?=
(
Yii
::
$app
->
controller
->
id
===
'user-center'
and
Yii
::
$app
->
controller
->
action
->
id
===
'browse-record'
)
?
'class = "active"'
:
''
?>
>
<a
href=
"
<?=
$baseUrl
.
'/user-center/browse-record'
?>
"
><i
class=
"glyphicon glyphicon-eye-open"
></i>
浏览记录
</a>
</li>
<li><a
href=
"javascript:;"
><i
class=
"glyphicon glyphicon-play-circle"
></i>
我的课堂
</a></li>
<li><a
href=
"
<?=
$baseUrl
.
'/site/logout'
?>
"
><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"
>
<?=
$this
->
render
(
'centerHeader'
)
?>
<div
class=
"tp-main"
>
<div
class=
"container"
>
<?=
$content
?>
</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
();
?>
src/frontend/views/my-course/publish.php
View file @
e0009e36
<?php
use
frontend\assets\AppAsset
;
use
yii\widgets\ActiveForm
;
/*
* @var $this yii\web\View
...
...
@@ -11,7 +12,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 +59,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 +77,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
src/frontend/views/my-course/result.php
0 → 100644
View file @
e0009e36
<?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>
src/frontend/views/user-center/browseRecord.php
0 → 100644
View file @
e0009e36
<?php
/**
* Created by PhpStorm.
* User: xiabin
* Date: 2016/9/29
* Time: 上午9:59
*/
use
\frontend\assets\AppAsset
;
$this
->
title
=
'浏览记录'
;
\frontend\assets\AppAsset
::
addScript
(
$this
,
'@web/assets/user_center_browse_record.js'
)
?>
<div
class=
"empty-data"
>
您还没购买任何课程!
</div>
<div
class=
"cls-list-box hide"
>
<div
class=
"col-md-4"
>
<div
class=
"cls-box-main sm-box"
>
<div
class=
"video-img-box"
>
<img
src=
"
<?=
AppAsset
::
getStaticUrl
(
'img/videoimg.jpg'
)
?>
"
>
<div
class=
"video-list-cnt"
>
<div
class=
"tit"
><a
href=
"#"
>
英国为什么比中国先进入工业时代?
</a></div>
<div
class=
"price"
>
¥182.97
</div>
</div>
<div
class=
"outline"
>
<span>
购买日期:2016年9月12日 16:02
</span>
</div>
<div
class=
"avatar"
><img
src=
"
<?=
AppAsset
::
getStaticUrl
(
'img/avatar2.jpg'
)
?>
"
></div>
<div
class=
"play-mask"
>
<a
href=
"#"
><i
class=
"glyphicon glyphicon-play"
></i></a>
</div>
</div>
</div>
</div>
<div
class=
"col-md-4"
>
<div
class=
"cls-box-main sm-box"
>
<div
class=
"video-img-box"
>
<img
src=
"
<?=
AppAsset
::
getStaticUrl
(
'img/videoimg.jpg'
)
?>
"
>
<div
class=
"video-list-cnt"
>
<div
class=
"tit"
><a
href=
"#"
>
英国为什么比中国先进入工业时代?
</a></div>
<div
class=
"price"
>
¥182.97
</div>
</div>
<div
class=
"outline"
>
<span>
购买日期:2016年9月12日 16:02
</span>
</div>
<div
class=
"avatar"
><img
src=
"
<?=
AppAsset
::
getStaticUrl
(
'img/avatar2.jpg'
)
?>
"
></div>
<div
class=
"play-mask"
>
<a
href=
"#"
><i
class=
"glyphicon glyphicon-play"
></i></a>
</div>
</div>
</div>
</div>
<div
class=
"col-md-4"
>
<div
class=
"cls-box-main sm-box"
>
<div
class=
"video-img-box"
>
<img
src=
"
<?=
AppAsset
::
getStaticUrl
(
'img/videoimg.jpg'
)
?>
"
>
<div
class=
"video-list-cnt"
>
<div
class=
"tit"
><a
href=
"#"
>
英国为什么比中国先进入工业时代?
</a></div>
<div
class=
"price"
>
¥182.97
</div>
</div>
<div
class=
"outline"
>
<span>
购买日期:2016年9月12日 16:02
</span>
</div>
<div
class=
"avatar"
><img
src=
"
<?=
AppAsset
::
getStaticUrl
(
'img/avatar2.jpg'
)
?>
"
></div>
<div
class=
"play-mask"
>
<a
href=
"#"
><i
class=
"glyphicon glyphicon-play"
></i></a>
</div>
</div>
</div>
</div>
<div
class=
"col-md-4"
>
<div
class=
"cls-box-main sm-box"
>
<div
class=
"video-img-box"
>
<img
src=
"
<?=
AppAsset
::
getStaticUrl
(
'img/videoimg.jpg'
)
?>
"
>
<div
class=
"video-list-cnt"
>
<div
class=
"tit"
><a
href=
"#"
>
英国为什么比中国先进入工业时代?
</a></div>
<div
class=
"price"
>
¥182.97
</div>
</div>
<div
class=
"outline"
>
<span>
购买日期:2016年9月12日 16:02
</span>
</div>
<div
class=
"avatar"
><img
src=
"
<?=
AppAsset
::
getStaticUrl
(
'img/avatar2.jpg'
)
?>
"
></div>
<div
class=
"play-mask"
>
<a
href=
"#"
><i
class=
"glyphicon glyphicon-play"
></i></a>
</div>
</div>
</div>
</div>
<div
class=
"col-md-4"
>
<div
class=
"cls-box-main sm-box"
>
<div
class=
"video-img-box"
>
<img
src=
"
<?=
AppAsset
::
getStaticUrl
(
'img/videoimg.jpg'
)
?>
"
>
<div
class=
"video-list-cnt"
>
<div
class=
"tit"
><a
href=
"#"
>
英国为什么比中国先进入工业时代?
</a></div>
<div
class=
"price"
>
¥182.97
</div>
</div>
<div
class=
"outline"
>
<span>
购买日期:2016年9月12日 16:02
</span>
</div>
<div
class=
"avatar"
><img
src=
"
<?=
AppAsset
::
getStaticUrl
(
'img/avatar2.jpg'
)
?>
"
></div>
<div
class=
"play-mask"
>
<a
href=
"#"
><i
class=
"glyphicon glyphicon-play"
></i></a>
</div>
</div>
</div>
</div>
</div>
src/frontend/views/user-center/browse_record.php
deleted
100644 → 0
View file @
8d1708c9
<?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>
src/frontend/views/user-center/favorite.php
View file @
e0009e36
...
...
@@ -5,11 +5,118 @@
* Date: 2016/9/27
* Time: 下午4:16
*/
\frontend\assets\AppAsset
::
addScript
(
$this
,
'@web/assets/user_favorite.js'
)
use
\frontend\assets\AppAsset
;
$this
->
title
=
'收藏记录'
;
\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
<div
class=
"cls-list-box"
>
<div
class=
"col-md-4"
>
<div
class=
"cls-box-main sm-box"
>
<div
class=
"video-img-box"
>
<img
src=
"
<?=
AppAsset
::
getStaticUrl
(
'img/videoimg.jpg'
)
?>
"
>
<div
class=
"video-list-cnt"
>
<div
class=
"tit"
><a
href=
"#"
>
英国为什么比中国先进入工业时代?
</a></div>
<div
class=
"price"
>
¥182.97
</div>
</div>
<div
class=
"outline"
>
<span>
购买日期:2016年9月12日 16:02
</span>
</div>
<div
class=
"avatar"
><img
src=
"
<?=
AppAsset
::
getStaticUrl
(
'img/avatar2.jpg'
)
?>
"
></div>
<div
class=
"play-mask"
>
<a
href=
"#"
><i
class=
"glyphicon glyphicon-play"
></i></a>
</div>
</div>
</div>
</div>
<div
class=
"col-md-4"
>
<div
class=
"cls-box-main sm-box"
>
<div
class=
"video-img-box"
>
<img
src=
"
<?=
AppAsset
::
getStaticUrl
(
'img/videoimg.jpg'
)
?>
"
>
<div
class=
"video-list-cnt"
>
<div
class=
"tit"
><a
href=
"#"
>
英国为什么比中国先进入工业时代?
</a></div>
<div
class=
"price"
>
¥182.97
</div>
</div>
<div
class=
"outline"
>
<span>
购买日期:2016年9月12日 16:02
</span>
</div>
<div
class=
"avatar"
><img
src=
"
<?=
AppAsset
::
getStaticUrl
(
'img/avatar2.jpg'
)
?>
"
></div>
<div
class=
"play-mask"
>
<a
href=
"#"
><i
class=
"glyphicon glyphicon-play"
></i></a>
</div>
</div>
</div>
</div>
<div
class=
"col-md-4"
>
<div
class=
"cls-box-main sm-box"
>
<div
class=
"video-img-box"
>
<img
src=
"
<?=
AppAsset
::
getStaticUrl
(
'img/videoimg.jpg'
)
?>
"
>
<div
class=
"video-list-cnt"
>
<div
class=
"tit"
><a
href=
"#"
>
英国为什么比中国先进入工业时代?
</a></div>
<div
class=
"price"
>
¥182.97
</div>
</div>
<div
class=
"outline"
>
<span>
购买日期:2016年9月12日 16:02
</span>
</div>
<div
class=
"avatar"
><img
src=
"
<?=
AppAsset
::
getStaticUrl
(
'img/avatar2.jpg'
)
?>
"
></div>
<div
class=
"play-mask"
>
<a
href=
"#"
><i
class=
"glyphicon glyphicon-play"
></i></a>
</div>
</div>
</div>
</div>
<div
class=
"col-md-4"
>
<div
class=
"cls-box-main sm-box"
>
<div
class=
"video-img-box"
>
<img
src=
"
<?=
AppAsset
::
getStaticUrl
(
'img/videoimg.jpg'
)
?>
"
>
<div
class=
"video-list-cnt"
>
<div
class=
"tit"
><a
href=
"#"
>
英国为什么比中国先进入工业时代?
</a></div>
<div
class=
"price"
>
¥182.97
</div>
</div>
<div
class=
"outline"
>
<span>
购买日期:2016年9月12日 16:02
</span>
</div>
<div
class=
"avatar"
><img
src=
"
<?=
AppAsset
::
getStaticUrl
(
'img/avatar2.jpg'
)
?>
"
></div>
<div
class=
"play-mask"
>
<a
href=
"#"
><i
class=
"glyphicon glyphicon-play"
></i></a>
</div>
</div>
</div>
</div>
<div
class=
"col-md-4"
>
<div
class=
"cls-box-main sm-box"
>
<div
class=
"video-img-box"
>
<img
src=
"
<?=
AppAsset
::
getStaticUrl
(
'img/videoimg.jpg'
)
?>
"
>
<div
class=
"video-list-cnt"
>
<div
class=
"tit"
><a
href=
"#"
>
英国为什么比中国先进入工业时代?
</a></div>
<div
class=
"price"
>
¥182.97
</div>
</div>
<div
class=
"outline"
>
<span>
购买日期:2016年9月12日 16:02
</span>
</div>
<div
class=
"avatar"
><img
src=
"
<?=
AppAsset
::
getStaticUrl
(
'img/avatar2.jpg'
)
?>
"
></div>
<div
class=
"play-mask"
>
<a
href=
"#"
><i
class=
"glyphicon glyphicon-play"
></i></a>
</div>
</div>
</div>
</div>
</div>
src/frontend/views/user-center/info.php
View file @
e0009e36
...
...
@@ -9,20 +9,28 @@
$url
=
Yii
::
$app
->
qiniu
->
storages
[
'public'
][
'url'
];
?>
<div
class=
"add-box"
>
<div
id=
"edit-container"
class=
"add-box"
style=
"display: none"
>
<div
class=
"add-box-main"
>
<div
class=
"tit"
>
基本信息
</div>
<div
class=
"upload-avatar"
id=
"avatar-uploader"
token=
"
<?=
$publicToken
?>
"
>
<div
id=
"upload-avatar-value"
>
<i
class=
" icon-image"
></i>
<p>
上传头像
</p>
</div>
<span
id=
"upload-process"
style=
"display:none;"
class=
"loading-tip"
>
上传中
</span>
<div
class=
"upload-avatar"
>
<img
id=
"avatar-uploader"
token=
"
<?=
$publicToken
?>
"
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
)
?>
"
>
<input
id=
"avatar"
type=
"hidden"
value=
"
<?=
\yii\bootstrap\Html
::
encode
(
Yii
::
$app
->
user
->
identity
->
avatar
)
?>
"
>
</div>
<input
id=
"avatar"
type=
"hidden"
value=
"
<?=
\yii\bootstrap\Html
::
encode
(
Yii
::
$app
->
user
->
identity
->
avatar
)
?>
"
>
<div
class=
"type-name"
>
<input
id=
"username"
type=
"text"
value=
"
<?=
\yii\bootstrap\Html
::
encode
(
Yii
::
$app
->
user
->
identity
->
username
)
?>
"
<input
id=
"username"
type=
"text"
value=
"
<?=
\yii\bootstrap\Html
::
encode
(
Yii
::
$app
->
user
->
identity
->
username
)
?>
"
placeholder=
"请输入您的昵称..."
>
</div>
...
...
@@ -32,3 +40,21 @@ $url = Yii::$app->qiniu->storages['public']['url'];
</div>
</div>
</div>
<div
id=
"normal-container"
class=
"add-box"
>
<div
class=
"add-box-main"
>
<div
class=
"tit"
>
基本信息
</div>
<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
)
?>
"
>
</div>
<div
class=
"type-name m-b-20"
>
<?=
\yii\bootstrap\Html
::
encode
(
Yii
::
$app
->
user
->
identity
->
username
)
?>
</div>
<a
id=
"edit"
href=
"javascript:;"
class=
"edit-info"
><i
class=
"icon-mode_edit"
></i></a>
</div>
</div>
src/frontend/views/user-center/purchasedCourse.php
0 → 100644
View file @
e0009e36
<?php
/**
* Created by PhpStorm.
* User: xiabin
* Date: 2016/9/29
* Time: 上午9:59
*/
use
\frontend\assets\AppAsset
;
$this
->
title
=
'已购课程'
;
\frontend\assets\AppAsset
::
addScript
(
$this
,
'@web/assets/user_center_purchased_course.js'
)
?>
<div
class=
"cls-list-box"
>
<div
class=
"col-md-4"
>
<div
class=
"cls-box-main sm-box"
>
<div
class=
"video-img-box"
>
<img
src=
"
<?=
AppAsset
::
getStaticUrl
(
'img/videoimg.jpg'
)
?>
"
>
<div
class=
"video-list-cnt"
>
<div
class=
"tit"
><a
href=
"#"
>
英国为什么比中国先进入工业时代?
</a></div>
<div
class=
"price"
>
¥182.97
</div>
</div>
<div
class=
"outline"
>
<span>
购买日期:2016年9月12日 16:02
</span>
</div>
<div
class=
"avatar"
><img
src=
"
<?=
AppAsset
::
getStaticUrl
(
'img/avatar2.jpg'
)
?>
"
></div>
<div
class=
"play-mask"
>
<a
href=
"#"
><i
class=
"glyphicon glyphicon-play"
></i></a>
</div>
</div>
</div>
</div>
<div
class=
"col-md-4"
>
<div
class=
"cls-box-main sm-box"
>
<div
class=
"video-img-box"
>
<img
src=
"
<?=
AppAsset
::
getStaticUrl
(
'img/videoimg.jpg'
)
?>
"
>
<div
class=
"video-list-cnt"
>
<div
class=
"tit"
><a
href=
"#"
>
英国为什么比中国先进入工业时代?
</a></div>
<div
class=
"price"
>
¥182.97
</div>
</div>
<div
class=
"outline"
>
<span>
购买日期:2016年9月12日 16:02
</span>
</div>
<div
class=
"avatar"
><img
src=
"
<?=
AppAsset
::
getStaticUrl
(
'img/avatar2.jpg'
)
?>
"
></div>
<div
class=
"play-mask"
>
<a
href=
"#"
><i
class=
"glyphicon glyphicon-play"
></i></a>
</div>
</div>
</div>
</div>
<div
class=
"col-md-4"
>
<div
class=
"cls-box-main sm-box"
>
<div
class=
"video-img-box"
>
<img
src=
"
<?=
AppAsset
::
getStaticUrl
(
'img/videoimg.jpg'
)
?>
"
>
<div
class=
"video-list-cnt"
>
<div
class=
"tit"
><a
href=
"#"
>
英国为什么比中国先进入工业时代?
</a></div>
<div
class=
"price"
>
¥182.97
</div>
</div>
<div
class=
"outline"
>
<span>
购买日期:2016年9月12日 16:02
</span>
</div>
<div
class=
"avatar"
><img
src=
"
<?=
AppAsset
::
getStaticUrl
(
'img/avatar2.jpg'
)
?>
"
></div>
<div
class=
"play-mask"
>
<a
href=
"#"
><i
class=
"glyphicon glyphicon-play"
></i></a>
</div>
</div>
</div>
</div>
<div
class=
"col-md-4"
>
<div
class=
"cls-box-main sm-box"
>
<div
class=
"video-img-box"
>
<img
src=
"
<?=
AppAsset
::
getStaticUrl
(
'img/videoimg.jpg'
)
?>
"
>
<div
class=
"video-list-cnt"
>
<div
class=
"tit"
><a
href=
"#"
>
英国为什么比中国先进入工业时代?
</a></div>
<div
class=
"price"
>
¥182.97
</div>
</div>
<div
class=
"outline"
>
<span>
购买日期:2016年9月12日 16:02
</span>
</div>
<div
class=
"avatar"
><img
src=
"
<?=
AppAsset
::
getStaticUrl
(
'img/avatar2.jpg'
)
?>
"
></div>
<div
class=
"play-mask"
>
<a
href=
"#"
><i
class=
"glyphicon glyphicon-play"
></i></a>
</div>
</div>
</div>
</div>
<div
class=
"col-md-4"
>
<div
class=
"cls-box-main sm-box"
>
<div
class=
"video-img-box"
>
<img
src=
"
<?=
AppAsset
::
getStaticUrl
(
'img/videoimg.jpg'
)
?>
"
>
<div
class=
"video-list-cnt"
>
<div
class=
"tit"
><a
href=
"#"
>
英国为什么比中国先进入工业时代?
</a></div>
<div
class=
"price"
>
¥182.97
</div>
</div>
<div
class=
"outline"
>
<span>
购买日期:2016年9月12日 16:02
</span>
</div>
<div
class=
"avatar"
><img
src=
"
<?=
AppAsset
::
getStaticUrl
(
'img/avatar2.jpg'
)
?>
"
></div>
<div
class=
"play-mask"
>
<a
href=
"#"
><i
class=
"glyphicon glyphicon-play"
></i></a>
</div>
</div>
</div>
</div>
</div>
src/frontend/views/user-center/purchased_course.php
deleted
100644 → 0
View file @
8d1708c9
<?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>
src/frontend/web/css/reset.css
View file @
e0009e36
...
...
@@ -181,7 +181,6 @@ ul,
ol
,
li
{
list-style
:
none
;
float
:
left
;
}
i
,
em
{
...
...
src/frontend/web/css/style.css
View file @
e0009e36
...
...
@@ -18,9 +18,15 @@ html {
.m-t-20
{
margin-top
:
20px
;
}
.m-b-20
{
margin-bottom
:
20px
;
}
.d-i-b
{
display
:
inline-block
;
}
.tit
{
font-size
:
16px
;
}
/*side bar*/
...
...
@@ -388,11 +394,13 @@ html {
background-color
:
#fff
;
}
.add-box-main
{
position
:
relative
;
padding
:
20px
40px
;
text-align
:
center
;
}
.add-box-main
.tit
{
text-align
:
left
;
font-size
:
16px
;
}
.upload-avatar
{
position
:
relative
;
...
...
@@ -427,9 +435,46 @@ html {
cursor
:
pointer
;
}
.upload-avatar
img
{
position
:
absolute
;
left
:
0
;
top
:
0
;
height
:
100px
;
width
:
100px
;
border-radius
:
100%
;
z-index
:
2
;
}
.upload-avatar
span
.loading-tip
{
position
:
absolute
;
display
:
inline-block
;
width
:
100px
;
height
:
100px
;
text-align
:
center
;
line-height
:
100px
;
color
:
#fff
;
top
:
0
;
left
:
0
;
border-radius
:
100%
;
background-color
:
rgba
(
0
,
0
,
0
,
.5
);
z-index
:
3
;
}
.edit-info
{
position
:
absolute
;
display
:
inline-block
;
width
:
50px
;
height
:
50px
;
border-radius
:
100%
;
text-align
:
center
;
line-height
:
52px
;
font-size
:
18px
;
text-decoration
:
none
;
right
:
20px
;
top
:
20px
;
background-color
:
#f3f3f3
;
}
.edit-info
:hover
{
background-color
:
#3f7de4
;
color
:
#fff
;
text-decoration
:
none
;
}
.type-name
{
font-size
:
14px
;
...
...
@@ -1014,4 +1059,17 @@ textarea.input-r-control {
}
.sm-box
:hover
.play-mask
{
opacity
:
1
;
}
.apply-class-box
{
max-width
:
600px
;
margin
:
0
auto
}
.empty-data
{
height
:
300px
;
text-align
:
center
;
padding-top
:
110px
;
background
:
url("../img/empty.png")
center
top
no-repeat
;
color
:
#999
;
}
\ No newline at end of file
src/frontend/web/img/placeholder.jpg
0 → 100644
View file @
e0009e36
2.64 KB
src/frontend/web/js/components/uploader/thumb-upload.vue
View file @
e0009e36
...
...
@@ -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
>
src/frontend/web/js/components/uploader/video-upload.vue
View file @
e0009e36
...
...
@@ -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'
,
{
...
...
src/frontend/web/js/my-course/publish.js
View file @
e0009e36
...
...
@@ -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
src/frontend/web/js/site/request_password_reset.js
View file @
e0009e36
...
...
@@ -31,7 +31,7 @@ $.ajax({
initGeetest
({
gt
:
data
.
gt
,
challenge
:
data
.
challenge
,
product
:
"
embed
"
,
// 产品形式,包括:float,embed,popup。注意只对PC版验证码有效
product
:
"
float
"
,
// 产品形式,包括:float,embed,popup。注意只对PC版验证码有效
offline
:
!
data
.
success
// 表示用户后台检测极验服务器是否宕机,一般不需要关注
// 更多配置参数请参见:http://www.geetest.com/install/sections/idx-client-sdk.html#config
},
handlerEmbed
);
...
...
src/frontend/web/js/site/signup.js
View file @
e0009e36
...
...
@@ -52,7 +52,7 @@ $.ajax({
initGeetest
({
gt
:
data
.
gt
,
challenge
:
data
.
challenge
,
product
:
"
embed
"
,
// 产品形式,包括:float,embed,popup。注意只对PC版验证码有效
product
:
"
float
"
,
// 产品形式,包括:float,embed,popup。注意只对PC版验证码有效
offline
:
!
data
.
success
// 表示用户后台检测极验服务器是否宕机,一般不需要关注
// 更多配置参数请参见:http://www.geetest.com/install/sections/idx-client-sdk.html#config
},
handlerEmbed
);
...
...
src/frontend/web/js/site/token_input.js
View file @
e0009e36
...
...
@@ -34,7 +34,7 @@ $.ajax({
initGeetest
({
gt
:
data
.
gt
,
challenge
:
data
.
challenge
,
product
:
"
embed
"
,
// 产品形式,包括:float,embed,popup。注意只对PC版验证码有效
product
:
"
float
"
,
// 产品形式,包括:float,embed,popup。注意只对PC版验证码有效
offline
:
!
data
.
success
// 表示用户后台检测极验服务器是否宕机,一般不需要关注
// 更多配置参数请参见:http://www.geetest.com/install/sections/idx-client-sdk.html#config
},
handlerEmbed
);
...
...
src/frontend/web/js/user-center/browse_record.js
View file @
e0009e36
/**
* Created by xiabin on 2016/9/29.
*/
layer
.
msg
(
'玩命提示中'
);
\ No newline at end of file
*/
\ No newline at end of file
src/frontend/web/js/user-center/favorite.js
View file @
e0009e36
/**
* Created by xiabin on 2016/9/29.
*/
layer
.
msg
(
'玩命提示中'
);
src/frontend/web/js/user-center/info.js
View file @
e0009e36
...
...
@@ -36,34 +36,19 @@ require.ensure('../libs/plupload/plupload.full.min.js', function () {
// 每个文件上传前,处理相关的事情
},
'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));
$
(
'#upload-process'
).
show
();
// 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"
// }
// 查看简单反馈
$
(
'#upload-process'
).
hide
();
var
res
=
JSON
.
parse
(
info
.
response
);
var
url
=
__QINIU_URL__
+
res
.
key
;
$
(
'#avatar-uploader'
).
attr
(
'src'
,
url
);
var
html
=
'<img src="'
+
url
+
'">'
;
$
(
'#upload-avatar-value'
).
html
(
html
);
$
(
'#avatar'
).
val
(
res
.
key
);
},
'Error'
:
function
(
up
,
err
,
errTip
)
{
//上传出错时,处理相关的事情
...
...
@@ -104,7 +89,7 @@ $("#save").click(function () {
if
(
!
reponse
.
status
===
true
)
{
layer
.
alert
(
reponse
.
message
||
'系统错误'
,
{
icon
:
2
,
title
:
"提示"
})
}
else
{
layer
.
alert
(
'保存成功'
,
{
icon
:
1
,
title
:
"提示"
})
window
.
location
.
reload
();
}
}
}).
error
(
function
()
{
...
...
@@ -113,3 +98,8 @@ $("#save").click(function () {
})
});
$
(
'#edit'
).
click
(
function
()
{
$
(
'#edit-container'
).
show
();
$
(
'#normal-container'
).
hide
();
});
src/frontend/web/js/user-center/purchased_course.js
View file @
e0009e36
/**
* Created by xiabin on 2016/9/29.
*/
layer
.
msg
(
'玩命提示中'
);
src/frontend/web/js/utils/file.js
0 → 100644
View file @
e0009e36
/**
* 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
src/frontend/web/js/utils/simditor.js
0 → 100644
View file @
e0009e36
/**
* Created by pader on 16/10/10.
*/
require
(
"../../node_modules/simditor/styles/simditor.css"
);
module
.
exports
=
require
(
"simditor"
);
\ No newline at end of file
src/frontend/web/package.json
View file @
e0009e36
...
...
@@ -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"
}
...
...
src/frontend/web/webpack.config.js
View file @
e0009e36
...
...
@@ -44,7 +44,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"
}
...
...
ui/html/my-浏览记录.html
View file @
e0009e36
...
...
@@ -42,11 +42,11 @@
<div
class=
"tp-main"
>
<div
class=
"container"
>
<!-- 没有内容 -->
<div
class=
"empty-data"
>
<div
class=
"empty-data
hide
"
>
您还没购买任何课程!
</div>
<div
class=
"cls-list-box
hide
"
>
<div
class=
"cls-list-box "
>
<div
class=
"col-md-4"
>
<div
class=
"cls-box-main sm-box"
>
<div
class=
"video-img-box"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment