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
3c56cb0d
Commit
3c56cb0d
authored
Oct 15, 2016
by
xiabin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交视频播放页面相关
parent
19ca989b
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
103 additions
and
60 deletions
+103
-60
Comments.php
src/common/models/Comments.php
+20
-0
Course.php
src/common/models/Course.php
+2
-2
Courseware.php
src/common/models/Courseware.php
+2
-1
HomeController.php
src/frontend/controllers/HomeController.php
+36
-10
course-lists.vue
src/frontend/web/js/home/components/course-lists.vue
+5
-5
video-intro.vue
src/frontend/web/js/home/components/video-intro.vue
+34
-38
video-play.vue
src/frontend/web/js/home/components/video-play.vue
+4
-4
No files found.
src/common/models/Comments.php
View file @
3c56cb0d
...
@@ -82,4 +82,24 @@ class Comments extends \yii\db\ActiveRecord
...
@@ -82,4 +82,24 @@ class Comments extends \yii\db\ActiveRecord
$result
=
self
::
find
()
->
select
(
'id'
)
->
where
(
'id=:id'
,
[
':id'
=>
$id
])
->
one
();
$result
=
self
::
find
()
->
select
(
'id'
)
->
where
(
'id=:id'
,
[
':id'
=>
$id
])
->
one
();
return
$result
===
NULL
?
FALSE
:
TRUE
;
return
$result
===
NULL
?
FALSE
:
TRUE
;
}
}
public
static
function
getCommentsListsByCoursewareId
(
$coursewareId
,
$page
,
$num
)
{
$condition
=
"courseware_id=:courseware_id"
;
$params
=
[
':courseware_id'
=>
$coursewareId
];
//获取总数
$count
=
self
::
find
()
->
where
(
$condition
,
$params
)
->
count
();
$start
=
$page
*
$num
;
$data
=
[];
if
(
$count
>
0
)
{
$tableA
=
self
::
tableName
();
$tableB
=
User
::
tableName
();
$data
=
self
::
find
()
->
select
(
"
$tableA
.id,
$tableA
.comment,
$tableA
.user_id,
$tableB
.name,
$tableB
.avatar"
)
->
where
(
$condition
,
$params
)
->
limit
(
$num
)
->
offset
(
$start
)
->
orderBy
(
'created_at DESC'
)
->
leftJoin
(
$tableB
,
"
$tableA
.user_id =
$tableB
.id"
)
->
asArray
()
->
all
();
}
return
[
'count'
=>
$count
,
'data'
=>
$data
];
}
}
}
src/common/models/Course.php
View file @
3c56cb0d
...
@@ -83,7 +83,7 @@ class Course extends \yii\db\ActiveRecord
...
@@ -83,7 +83,7 @@ class Course extends \yii\db\ActiveRecord
[
'price'
,
'integer'
,
'min'
=>
0
,
'max'
=>
9999
],
[
'price'
,
'integer'
,
'min'
=>
0
,
'max'
=>
9999
],
[
'free_time'
,
'integer'
,
'min'
=>
0
,
'max'
=>
15
],
[
'free_time'
,
'integer'
,
'min'
=>
0
,
'max'
=>
15
],
[
'recommend'
,
'boolean'
],
[
'recommend'
,
'boolean'
],
[[
'recommend'
,
'comment_count'
,
'favorit_count'
,
'support_count'
,
'play_count'
],
'default'
,
'value'
=>
0
],
[[
'recommend'
,
'comment_count'
,
'favorit
e
_count'
,
'support_count'
,
'play_count'
],
'default'
,
'value'
=>
0
],
[
'status'
,
'in'
,
'range'
=>
[
0
,
1
,
2
,
3
]]
[
'status'
,
'in'
,
'range'
=>
[
0
,
1
,
2
,
3
]]
];
];
}
}
...
@@ -141,7 +141,7 @@ class Course extends \yii\db\ActiveRecord
...
@@ -141,7 +141,7 @@ class Course extends \yii\db\ActiveRecord
$count
=
self
::
find
()
->
where
(
$condition
,
$params
)
->
count
();
$count
=
self
::
find
()
->
where
(
$condition
,
$params
)
->
count
();
$start
=
$page
*
$num
;
$start
=
$page
*
$num
;
if
(
$count
>
0
)
{
if
(
$count
>
0
)
{
$data
=
self
::
find
()
->
select
(
'id,user_id,price,name,intro,preview_pic,recommend,play_count,comment_count,favorit_count,support_count,created_at'
)
->
where
(
$condition
,
$params
)
->
limit
(
$num
)
->
offset
(
$start
)
->
with
(
'teachers'
)
->
asArray
()
->
all
();
$data
=
self
::
find
()
->
select
(
'id,user_id,price,name,intro,preview_pic,recommend,play_count,comment_count,favorit
e
_count,support_count,created_at'
)
->
where
(
$condition
,
$params
)
->
limit
(
$num
)
->
offset
(
$start
)
->
with
(
'teachers'
)
->
asArray
()
->
all
();
}
}
return
[
return
[
'count'
=>
$count
,
'count'
=>
$count
,
...
...
src/common/models/Courseware.php
View file @
3c56cb0d
...
@@ -52,7 +52,7 @@ class Courseware extends ActiveRecord
...
@@ -52,7 +52,7 @@ class Courseware extends ActiveRecord
[[
'user_id'
,
'course_id'
,
'type'
,
'status'
,
'size'
,
'time'
],
'integer'
],
[[
'user_id'
,
'course_id'
,
'type'
,
'status'
,
'size'
,
'time'
],
'integer'
],
[[
'name'
],
'string'
,
'max'
=>
128
],
[[
'name'
],
'string'
,
'max'
=>
128
],
[[
'format'
],
'string'
,
'max'
=>
16
],
[[
'format'
],
'string'
,
'max'
=>
16
],
[[
'comment_count'
,
'favorit_count'
,
'support_count'
,
'play_count'
],
'default'
,
'value'
=>
0
],
[[
'comment_count'
,
'favorit
e
_count'
,
'support_count'
,
'play_count'
],
'default'
,
'value'
=>
0
],
];
];
}
}
...
@@ -103,4 +103,5 @@ class Courseware extends ActiveRecord
...
@@ -103,4 +103,5 @@ class Courseware extends ActiveRecord
$result
=
self
::
find
()
->
select
(
'id'
)
->
where
(
'id=:id'
,
[
':id'
=>
$id
])
->
one
();
$result
=
self
::
find
()
->
select
(
'id'
)
->
where
(
'id=:id'
,
[
':id'
=>
$id
])
->
one
();
return
$result
===
NULL
?
FALSE
:
TRUE
;
return
$result
===
NULL
?
FALSE
:
TRUE
;
}
}
}
}
src/frontend/controllers/HomeController.php
View file @
3c56cb0d
...
@@ -85,7 +85,7 @@ class HomeController extends \yii\web\Controller
...
@@ -85,7 +85,7 @@ class HomeController extends \yii\web\Controller
*/
*/
public
function
actionGetCourseLists
(
$classId
,
$page
,
$num
=
10
)
public
function
actionGetCourseLists
(
$classId
,
$page
,
$num
=
10
)
{
{
if
(
Yii
::
$app
->
request
->
isAjax
or
TRUE
)
{
if
(
Yii
::
$app
->
request
->
isAjax
)
{
if
(
$page
>=
0
and
$num
>
0
)
{
if
(
$page
>=
0
and
$num
>
0
)
{
$result
=
Course
::
getCourseListsByClassId
(
$classId
,
$page
,
$num
);
$result
=
Course
::
getCourseListsByClassId
(
$classId
,
$page
,
$num
);
}
else
{
}
else
{
...
@@ -115,7 +115,7 @@ class HomeController extends \yii\web\Controller
...
@@ -115,7 +115,7 @@ class HomeController extends \yii\web\Controller
/**
/**
* 视频播放
* 视频播放
页面
* @param $courseId
* @param $courseId
* @return string
* @return string
*/
*/
...
@@ -132,19 +132,39 @@ class HomeController extends \yii\web\Controller
...
@@ -132,19 +132,39 @@ class HomeController extends \yii\web\Controller
$coursewareInfo
[
'intro'
]
=
$course
->
intro
;
$coursewareInfo
[
'intro'
]
=
$course
->
intro
;
$coursewareInfo
[
'teachers'
]
=
ArrayHelper
::
toArray
(
$teachers
);
$coursewareInfo
[
'teachers'
]
=
ArrayHelper
::
toArray
(
$teachers
);
$coursewareInfo
[
'videoUrl'
]
=
Yii
::
$app
->
qiniu
->
getUrl
(
'video'
,
$coursewareInfo
[
'name'
]);
$coursewareInfo
[
'videoUrl'
]
=
Yii
::
$app
->
qiniu
->
getUrl
(
'video'
,
$coursewareInfo
[
'name'
]);
var_dump
(
$coursewareInfo
)
;
$coursewareInfo
[
'isGuest'
]
=
Yii
::
$app
->
user
->
isGuest
;
return
$this
->
render
(
'video'
,
[
return
$this
->
render
(
'video'
,
[
'coursewareInfo'
=>
$coursewareInfo
'coursewareInfo'
=>
$coursewareInfo
]);
]);
}
}
}
}
/**
* 获取评论列表
* @param $coursewareId
* @throws ForbiddenHttpException
*/
public
function
actionGetCommentLists
(
$coursewareId
,
$page
,
$num
)
{
if
(
Yii
::
$app
->
request
->
isAjax
or
TRUE
)
{
if
(
$page
>=
0
and
$num
>
0
)
{
$result
=
Comments
::
getCommentsListsByCoursewareId
(
$coursewareId
,
$page
,
$num
);
}
else
{
throw
new
InvalidParamException
(
'参数错误'
);
}
Utils
::
ajaxResponse
(
TRUE
,
'ok'
,
$result
);
}
else
{
throw
new
ForbiddenHttpException
(
'非法请求'
);
}
}
/**
/**
* 点赞或者取消点赞
* 点赞或者取消点赞
* @param $coursewareId
* @param $coursewareId
* @throws \yii\web\ForbiddenHttpException
* @throws \yii\web\ForbiddenHttpException
*/
*/
public
function
actionSupport
(
$coursewareId
)
public
function
actionSupport
(
$coursewareId
)
{
{
if
(
Yii
::
$app
->
request
->
isAjax
)
{
if
(
Yii
::
$app
->
request
->
isAjax
)
{
$userId
=
Yii
::
$app
->
user
->
identity
->
getId
();
$userId
=
Yii
::
$app
->
user
->
identity
->
getId
();
...
@@ -174,7 +194,8 @@ class HomeController extends \yii\web\Controller
...
@@ -174,7 +194,8 @@ class HomeController extends \yii\web\Controller
* @param $courseId
* @param $courseId
* @throws \yii\web\ForbiddenHttpException
* @throws \yii\web\ForbiddenHttpException
*/
*/
public
function
actionFavorite
(
$courseId
)
public
function
actionFavorite
(
$courseId
)
{
{
if
(
Yii
::
$app
->
request
->
isAjax
)
{
if
(
Yii
::
$app
->
request
->
isAjax
)
{
$userId
=
Yii
::
$app
->
user
->
identity
->
getId
();
$userId
=
Yii
::
$app
->
user
->
identity
->
getId
();
...
@@ -205,7 +226,8 @@ class HomeController extends \yii\web\Controller
...
@@ -205,7 +226,8 @@ class HomeController extends \yii\web\Controller
* 评论
* 评论
* @throws \yii\web\ForbiddenHttpException
* @throws \yii\web\ForbiddenHttpException
*/
*/
public
function
actionComments
()
public
function
actionComments
()
{
{
$request
=
Yii
::
$app
->
request
;
$request
=
Yii
::
$app
->
request
;
if
(
$request
->
isAjax
)
{
if
(
$request
->
isAjax
)
{
...
@@ -246,7 +268,8 @@ class HomeController extends \yii\web\Controller
...
@@ -246,7 +268,8 @@ class HomeController extends \yii\web\Controller
* 支付宝支付请求
* 支付宝支付请求
* @throws InvalidParamException
* @throws InvalidParamException
*/
*/
public
function
actionPay
(
$courseId
)
public
function
actionPay
(
$courseId
)
{
{
$courseBaseInfo
=
Course
::
findBaseInfoByCourseId
(
$courseId
);
$courseBaseInfo
=
Course
::
findBaseInfoByCourseId
(
$courseId
);
if
(
$courseBaseInfo
!==
NULL
)
{
if
(
$courseBaseInfo
!==
NULL
)
{
...
@@ -294,7 +317,8 @@ class HomeController extends \yii\web\Controller
...
@@ -294,7 +317,8 @@ class HomeController extends \yii\web\Controller
/**
/**
* 获取微信支付的二维码
* 获取微信支付的二维码
*/
*/
public
function
actionWeixinPayQrcode
()
public
function
actionWeixinPayQrcode
()
{
{
$userId
=
Yii
::
$app
->
user
->
identity
->
getId
();
$userId
=
Yii
::
$app
->
user
->
identity
->
getId
();
$courseBaseInfo
=
Course
::
findBaseInfoByCourseId
(
$courseId
);
$courseBaseInfo
=
Course
::
findBaseInfoByCourseId
(
$courseId
);
...
@@ -313,7 +337,8 @@ class HomeController extends \yii\web\Controller
...
@@ -313,7 +337,8 @@ class HomeController extends \yii\web\Controller
/**
/**
* 移动端微信支付
* 移动端微信支付
*/
*/
public
function
actionMobilePay
()
public
function
actionMobilePay
()
{
{
$weixinpay
=
\Yii
::
$app
->
params
[
'weixinpay'
];
$weixinpay
=
\Yii
::
$app
->
params
[
'weixinpay'
];
$client
=
new
Client
(
$client
=
new
Client
(
...
@@ -356,7 +381,8 @@ class HomeController extends \yii\web\Controller
...
@@ -356,7 +381,8 @@ class HomeController extends \yii\web\Controller
* @param $price
* @param $price
* @return false|string
* @return false|string
*/
*/
private
function
generateOrderNumber
(
$userId
,
$courseId
,
$price
)
private
function
generateOrderNumber
(
$userId
,
$courseId
,
$price
)
{
{
return
md5
(
date
(
"YmdHis"
,
time
())
.
"_
{
$userId
}
_
{
$courseId
}
_
{
$price
}
"
);
return
md5
(
date
(
"YmdHis"
,
time
())
.
"_
{
$userId
}
_
{
$courseId
}
_
{
$price
}
"
);
}
}
...
...
src/frontend/web/js/home/components/course-lists.vue
View file @
3c56cb0d
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
<p>
{{
transcateTime
(
item
.
created_at
)
}}
</p>
<p>
{{
transcateTime
(
item
.
created_at
)
}}
</p>
<div
class=
"v-detail"
>
<div
class=
"v-detail"
>
<span><i
class=
"icon-comment-full"
></i>
{{
item
.
comment_count
}}
</span>
<span><i
class=
"icon-comment-full"
></i>
{{
item
.
comment_count
}}
</span>
<span><i
class=
"icon-fav-full"
></i>
{{
item
.
favorit_count
}}
</span>
<span><i
class=
"icon-fav-full"
></i>
{{
item
.
favorit
e
_count
}}
</span>
<span><i
class=
"icon-zan-full"
></i>
{{
item
.
support_count
}}
</span>
<span><i
class=
"icon-zan-full"
></i>
{{
item
.
support_count
}}
</span>
</div>
</div>
</div>
</div>
...
@@ -67,14 +67,14 @@
...
@@ -67,14 +67,14 @@
var
url
=
__BASE_URL__
+
'home/get-course-lists?classId='
+
classId
+
'&page='
+
var
url
=
__BASE_URL__
+
'home/get-course-lists?classId='
+
classId
+
'&page='
+
page
+
'&num='
+
num
;
page
+
'&num='
+
num
;
var
self
=
this
;
var
self
=
this
;
$
.
getJSON
(
url
,
function
(
reponse
)
{
$
.
getJSON
(
url
,
function
(
re
s
ponse
)
{
if
(
reponse
.
status
===
true
)
{
if
(
re
s
ponse
.
status
===
true
)
{
var
result
=
reponse
.
data
;
var
result
=
re
s
ponse
.
data
;
self
.
count
=
result
.
count
;
self
.
count
=
result
.
count
;
self
.
lists
=
self
.
lists
.
concat
(
result
.
data
);
self
.
lists
=
self
.
lists
.
concat
(
result
.
data
);
self
.
more
=
(
self
.
count
>
self
.
lists
.
length
);
self
.
more
=
(
self
.
count
>
self
.
lists
.
length
);
}
else
{
}
else
{
layer
.
alert
(
reponse
.
message
,
{
'icon'
:
2
,
'title'
:
'提示'
})
layer
.
alert
(
re
s
ponse
.
message
,
{
'icon'
:
2
,
'title'
:
'提示'
})
}
}
}).
error
(
function
()
{
}).
error
(
function
()
{
layer
.
alert
(
'获取推荐课堂列表错误'
,
{
'icon'
:
2
,
'title'
:
'提示'
})
layer
.
alert
(
'获取推荐课堂列表错误'
,
{
'icon'
:
2
,
'title'
:
'提示'
})
...
...
src/frontend/web/js/home/components/video-intro.vue
View file @
3c56cb0d
...
@@ -4,19 +4,19 @@
...
@@ -4,19 +4,19 @@
<div
class=
"video-description"
>
<div
class=
"video-description"
>
<div
class=
"title"
>
视频介绍
</div>
<div
class=
"title"
>
视频介绍
</div>
<div
class=
"text"
>
<div
class=
"text"
>
<?= \yii\helpers\Html::encode($coursewareInfo['intro']) ?>
{{
coursewareInfo
.
intro
}}
</div>
</div>
</div>
</div>
<div
class=
"video-comment"
>
<div
class=
"video-comment"
>
<div
class=
"title"
>
评论
<div
class=
"title"
>
评论
<small>
607次
</small>
<small>
{{
coursewareInfo
.
comment_count
}}
</small>
</div>
</div>
</div>
</div>
<div
class=
"comment-login"
>
<div
v-if=
"coursewareInfo.isGuest"
class=
"comment-login"
>
需要
<a
href=
""
>
登录
</a>
才能评论
需要
<a
href=
""
>
登录
</a>
才能评论
</div>
</div>
<div
class=
"comment-box"
>
<div
v-else
class=
"comment-box"
>
<div
class=
"comment-head"
>
<div
class=
"comment-head"
>
<img
src=
""
>
<img
src=
""
>
</div>
</div>
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
</div>
</div>
</div>
</div>
<div
class=
"comment-main-list clearfix"
>
<div
v-for=
"
{item in lists}"
class="comment-main-list clearfix">
<div
class=
"user-h pull-left"
><img
src=
""
></div>
<div
class=
"user-h pull-left"
><img
src=
""
></div>
<div
class=
"user-i"
>
<div
class=
"user-i"
>
<span>
Frank
<small>
10分钟前
</small></span>
<span>
Frank
<small>
10分钟前
</small></span>
...
@@ -34,50 +34,46 @@
...
@@ -34,50 +34,46 @@
</div>
</div>
</div>
</div>
<div
class=
"comment-main-list clearfix"
>
<div
class=
"user-h pull-left"
><img
src=
""
></div>
<div
class=
"user-i"
>
<span>
Frank
<small>
10分钟前
</small></span>
<p>
呵呵。。。不知为什么我听了你这么说话特牙疼
</p>
</div>
</div>
<div
class=
"comment-main-list clearfix"
>
<div
class=
"user-h pull-left"
><img
src=
""
></div>
<div
class=
"user-i"
>
<span>
Frank
<small>
10分钟前
</small></span>
<p>
呵呵。。。不知为什么我听了你这么说话特牙疼
</p>
</div>
</div>
<div
class=
"comment-main-list clearfix"
>
<div
class=
"user-h pull-left"
><img
src=
""
></div>
<div
class=
"user-i"
>
<span>
Frank
<small>
10分钟前
</small></span>
<p>
呵呵。。。不知为什么我听了你这么说话特牙疼
</p>
</div>
</div>
<div
class=
"comment-main-list clearfix"
>
<div
class=
"user-h pull-left"
><img
src=
""
></div>
<div
class=
"user-i"
>
<span>
Frank
<small>
10分钟前
</small></span>
<p>
呵呵。。。不知为什么我听了你这么说话特牙疼
</p>
</div>
</div>
</div>
</div>
</div>
</div>
</
template
>
</
template
>
<
script
>
<
script
>
export
default
{
export
default
{
data
(){
data
(){
return
{}
return
{
lists
:
[],
page
:
0
,
num
:
10
,
more
:
false
}
},
},
props
:
{
props
:
{
coursewareInfo
:
{
coursewareInfo
:
{
require
:
true
require
:
true
}
}
},
},
components
:
{}
methods
:
{
getCommentlists
(
coursewareId
,
page
,
num
){
var
self
=
this
;
var
url
=
__BASE_URL__
+
'home/get-comment-lists?coursewareId='
+
coursewareId
+
'&page='
+
page
+
'&num='
+
num
;
$
.
getJSON
(
url
,
function
(
response
)
{
if
(
response
.
status
===
true
)
{
var
result
=
response
.
data
;
self
.
more
=
(
result
.
count
>
self
.
lists
.
length
);
self
.
lists
=
self
.
lists
.
concat
(
result
.
data
);
}
else
{
layer
.
alert
(
response
.
message
,
{
'icon'
:
2
,
'title'
:
'提示'
})
}
}).
error
(
function
()
{
layer
.
alert
(
'获取评论信息出错'
,
{
'icon'
:
2
,
'title'
:
'提示'
})
});
}
},
ready
(){
this
.
getCommentlists
(
this
.
coursewareInfo
.
id
,
this
.
page
,
this
.
num
);
}
}
}
</
script
>
</
script
>
src/frontend/web/js/home/components/video-play.vue
View file @
3c56cb0d
...
@@ -21,14 +21,14 @@
...
@@ -21,14 +21,14 @@
<div class="
video
-
detail
-
info
">
<div class="
video
-
detail
-
info
">
<div class="
video
-
teacher
">
<div class="
video
-
teacher
">
<a href="
#
"><img src=""></a>
<a href="
#
"><img src=""></a>
<p><a href="
#
">乔布斯</a></p>
<p><a href="
javascript
:;
">乔布斯</a></p>
<span>2016-10-08</span>
<span>2016-10-08</span>
</div>
</div>
<div class="
video
-
sm
-
info
">
<div class="
video
-
sm
-
info
">
<a href="
#
"><i class="
icon
-
comment
-
empty
"></i>543
</a>
<a href="
javascript
:;
"><i class="
icon
-
comment
-
empty
"></i>{{coursewareInfo.comment_count
}}
</a>
<a href="
#
"><i class="
icon
-
fav
-
empty
"></i>31
</a>
<a href="
javascript
:;
"><i class="
icon
-
fav
-
empty
"></i>{{coursewareInfo.favorite_count
}}
</a>
<a href="
#
"><i class="
icon
-
zan
-
empty
"></i>97
</a>
<a href="
javascript
:;
"><i class="
icon
-
zan
-
empty
"></i>{{coursewareInfo.support_count
}}
</a>
</div>
</div>
</div>
</div>
</div>
</div>
...
...
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