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
1e3ae2af
Commit
1e3ae2af
authored
Oct 17, 2016
by
xiabin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加浏览记录
parent
5691360f
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
231 additions
and
234 deletions
+231
-234
BrowseRecord.php
src/common/models/BrowseRecord.php
+40
-7
Favorite.php
src/common/models/Favorite.php
+1
-1
Orders.php
src/common/models/Orders.php
+5
-1
HomeController.php
src/frontend/controllers/HomeController.php
+49
-9
UserCenterController.php
src/frontend/controllers/UserCenterController.php
+11
-9
browseRecord.php
src/frontend/views/user-center/browseRecord.php
+42
-81
favorite.php
src/frontend/views/user-center/favorite.php
+31
-25
purchasedCourse.php
src/frontend/views/user-center/purchasedCourse.php
+41
-101
video.js
src/frontend/web/js/home/video.js
+11
-0
No files found.
src/common/models/BrowseRecord.php
View file @
1e3ae2af
...
@@ -4,6 +4,7 @@ namespace common\models;
...
@@ -4,6 +4,7 @@ namespace common\models;
use
Yii
;
use
Yii
;
use
yii\behaviors\TimestampBehavior
;
use
yii\behaviors\TimestampBehavior
;
use
yii\data\Pagination
;
use
yii\redis\ActiveRecord
;
use
yii\redis\ActiveRecord
;
/**
/**
...
@@ -46,8 +47,8 @@ class BrowseRecord extends \yii\db\ActiveRecord
...
@@ -46,8 +47,8 @@ class BrowseRecord extends \yii\db\ActiveRecord
public
function
rules
()
public
function
rules
()
{
{
return
[
return
[
[[
'user_id'
,
'course_id'
,],
'required'
],
[[
'user_id'
,
'course_id'
,
'courseware_id'
],
'required'
],
[[
'user_id'
,
'course_id'
,
'time'
],
'integer'
],
[[
'user_id'
,
'course_id'
,
'
courseware_id'
,
'
time'
],
'integer'
],
];
];
}
}
...
@@ -60,6 +61,7 @@ class BrowseRecord extends \yii\db\ActiveRecord
...
@@ -60,6 +61,7 @@ class BrowseRecord extends \yii\db\ActiveRecord
'id'
=>
'ID'
,
'id'
=>
'ID'
,
'user_id'
=>
'User ID'
,
'user_id'
=>
'User ID'
,
'course_id'
=>
'Course ID'
,
'course_id'
=>
'Course ID'
,
'courseware_id'
=>
'courseware Id'
,
'time'
=>
'Time'
,
'time'
=>
'Time'
,
];
];
}
}
...
@@ -69,14 +71,45 @@ class BrowseRecord extends \yii\db\ActiveRecord
...
@@ -69,14 +71,45 @@ class BrowseRecord extends \yii\db\ActiveRecord
* @param $userId
* @param $userId
* @return mixed
* @return mixed
*/
*/
public
static
function
getByUserId
(
$userId
)
public
static
function
findByUserId
(
$userId
,
$page
,
$num
)
{
{
$tableA
=
self
::
tableName
();
$tableA
=
self
::
tableName
();
$tableB
=
Course
::
tableName
();
$tableB
=
Course
::
tableName
();
$condition
=
"
$tableA
.user_id=:user_id"
;
$params
=
[
':user_id'
=>
$userId
];
//获取总数
$count
=
self
::
find
()
->
where
(
$condition
,
$params
)
->
count
();
$start
=
$page
*
$num
;
$pagination
=
new
Pagination
([
'totalCount'
=>
$count
,
'pageSize'
=>
$num
,
'forcePageParam'
=>
FALSE
]);
$data
=
self
::
find
()
->
where
(
$condition
,
$params
)
->
limit
(
$num
)
->
offset
(
$start
)
->
orderBy
(
"
$tableA
.time DESC"
)
->
joinWith
(
'course'
)
->
asArray
()
->
all
();
return
[
'count'
=>
$count
,
'data'
=>
$data
,
'pagination'
=>
$pagination
];
}
/**
* 获取该课程是被记录浏览记录
* @param $userId
* @param $coursewareId
* @return mixed
*/
public
static
function
findByUserIdAndCoursewareId
(
$userId
,
$coursewareId
)
{
return
self
::
find
()
return
self
::
find
()
->
select
(
"course_id,time,
$tableB
.name,
$tableB
.avatar,
$tableB
.price,
$tableB
.free_time,
$tableB
.intro,
$tableB
.preview_pic,
$tableB
.created_at"
)
->
where
(
"user_id=:user_id and courseware_id=:courseware_id"
,
[
':user_id'
=>
$userId
,
':courseware_id'
=>
$coursewareId
])
->
where
(
"
$tableA
.user_id = :user_id"
,
[
->
one
();
':user_id'
=>
$userId
}
])
->
join
(
'left join'
,
$tableB
,
"
$tableA
.user_id=
$tableB
.id"
)
->
asArray
()
->
all
();
/**
* @return $this
*/
public
function
getCourse
()
{
return
$this
->
hasOne
(
Course
::
className
(),
[
'id'
=>
'course_id'
])
->
select
(
'id,user_id,name,price,preview_pic'
)
->
with
(
'teachers'
);
}
}
}
}
src/common/models/Favorite.php
View file @
1e3ae2af
...
@@ -96,7 +96,7 @@ class Favorite extends \yii\db\ActiveRecord
...
@@ -96,7 +96,7 @@ class Favorite extends \yii\db\ActiveRecord
* @param $coursewareId
* @param $coursewareId
* @return array|null|ActiveRecord
* @return array|null|ActiveRecord
*/
*/
public
static
function
findByUserIdAndCourseId
(
$userId
,
$coursewareId
)
public
static
function
findByUserIdAndCourse
ware
Id
(
$userId
,
$coursewareId
)
{
{
return
self
::
find
()
->
select
(
'id,user_id,courseware_id,created_at'
)
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
])
->
where
(
"user_id=:user_id and courseware_id=:courseware_id"
,
[
':user_id'
=>
$userId
,
':courseware_id'
=>
$coursewareId
])
...
...
src/common/models/Orders.php
View file @
1e3ae2af
...
@@ -4,6 +4,7 @@ namespace common\models;
...
@@ -4,6 +4,7 @@ namespace common\models;
use
Yii
;
use
Yii
;
use
yii\behaviors\TimestampBehavior
;
use
yii\behaviors\TimestampBehavior
;
use
yii\data\Pagination
;
use
yii\redis\ActiveRecord
;
use
yii\redis\ActiveRecord
;
/**
/**
...
@@ -98,11 +99,14 @@ class Orders extends \yii\db\ActiveRecord
...
@@ -98,11 +99,14 @@ class Orders extends \yii\db\ActiveRecord
//获取总数
//获取总数
$count
=
self
::
find
()
->
where
(
$condition
,
$params
)
->
count
();
$count
=
self
::
find
()
->
where
(
$condition
,
$params
)
->
count
();
$start
=
$page
*
$num
;
$start
=
$page
*
$num
;
$pagination
=
new
Pagination
([
'totalCount'
=>
$count
,
'pageSize'
=>
$num
,
'forcePageParam'
=>
FALSE
]);
$data
=
self
::
find
()
$data
=
self
::
find
()
->
where
(
$condition
,
$params
)
->
limit
(
$num
)
->
offset
(
$start
)
->
orderBy
(
"
$tableA
.created_at DESC"
)
->
joinWith
(
'courseWithTeachers'
)
->
asArray
()
->
all
();
->
where
(
$condition
,
$params
)
->
limit
(
$num
)
->
offset
(
$start
)
->
orderBy
(
"
$tableA
.created_at DESC"
)
->
joinWith
(
'courseWithTeachers'
)
->
asArray
()
->
all
();
return
[
return
[
'count'
=>
$count
,
'count'
=>
$count
,
'data'
=>
$data
'data'
=>
$data
,
'pagination'
=>
$pagination
];
];
}
}
...
...
src/frontend/controllers/HomeController.php
View file @
1e3ae2af
...
@@ -4,6 +4,7 @@ namespace frontend\controllers;
...
@@ -4,6 +4,7 @@ namespace frontend\controllers;
use
common\libs\alipay\AliPay
;
use
common\libs\alipay\AliPay
;
use
common\libs\WeixinPay
;
use
common\libs\WeixinPay
;
use
common\models\BrowseRecord
;
use
common\models\Classes
;
use
common\models\Classes
;
use
common\models\Comments
;
use
common\models\Comments
;
use
common\models\Course
;
use
common\models\Course
;
...
@@ -122,7 +123,7 @@ class HomeController extends \yii\web\Controller
...
@@ -122,7 +123,7 @@ class HomeController extends \yii\web\Controller
*/
*/
public
function
actionVideo
(
$courseId
)
public
function
actionVideo
(
$courseId
)
{
{
$coursewareInfo
=
Courseware
::
findOne
([
'id'
=>
$courseId
,
'status'
=>
Courseware
::
STATUS_OK
]);
$coursewareInfo
=
Courseware
::
findOne
([
'
course_
id'
=>
$courseId
,
'status'
=>
Courseware
::
STATUS_OK
]);
$course
=
Course
::
findOne
([
'id'
=>
$courseId
]);
$course
=
Course
::
findOne
([
'id'
=>
$courseId
]);
$teachers
=
$course
->
teachers
;
$teachers
=
$course
->
teachers
;
$userId
=
Yii
::
$app
->
user
->
id
;
$userId
=
Yii
::
$app
->
user
->
id
;
...
@@ -132,17 +133,18 @@ class HomeController extends \yii\web\Controller
...
@@ -132,17 +133,18 @@ class HomeController extends \yii\web\Controller
$coursewareInfo
=
$coursewareInfo
->
toArray
();
$coursewareInfo
=
$coursewareInfo
->
toArray
();
$coursewareInfo
[
'previewUrl'
]
=
Yii
::
$app
->
qiniu
->
getUrl
(
'public'
,
$course
->
preview_pic
);
$coursewareInfo
[
'previewUrl'
]
=
Yii
::
$app
->
qiniu
->
getUrl
(
'public'
,
$course
->
preview_pic
);
$coursewareInfo
[
'intro'
]
=
$course
->
intro
;
$coursewareInfo
[
'intro'
]
=
$course
->
intro
;
$coursewareInfo
[
'courseName'
]
=
$course
->
name
;
$coursewareInfo
[
'teachers'
]
=
ArrayHelper
::
toArray
(
$teachers
);
$coursewareInfo
[
'courseName'
]
=
$course
->
name
;
$coursewareInfo
[
'teachers'
]
=
ArrayHelper
::
toArray
(
$teachers
);
$coursewareInfo
[
'videoUrl'
]
=
Yii
::
$app
->
qiniu
->
getUrl
(
'video'
,
$coursewareInfo
[
'name'
]);
$coursewareInfo
[
'videoUrl'
]
=
Yii
::
$app
->
qiniu
->
getUrl
(
'video'
,
$coursewareInfo
[
'name'
]);
$coursewareInfo
[
'isGuest'
]
=
Yii
::
$app
->
user
->
isGuest
;
$coursewareInfo
[
'isGuest'
]
=
Yii
::
$app
->
user
->
isGuest
;
$coursewareInfo
[
'isSupport'
]
=
(
Support
::
findByUserIdAndCoursewareId
(
$userId
,
$course
Id
)
===
NULL
?
FALSE
:
TRUE
);
$coursewareInfo
[
'isSupport'
]
=
(
Support
::
findByUserIdAndCoursewareId
(
$userId
,
$course
wareInfo
[
'id'
]
)
===
NULL
?
FALSE
:
TRUE
);
$coursewareInfo
[
'isFavorite'
]
=
(
Favorite
::
findByUserIdAndCourse
Id
(
$userId
,
$courseId
)
===
NULL
?
FALSE
:
TRUE
);
$coursewareInfo
[
'isFavorite'
]
=
(
Favorite
::
findByUserIdAndCourse
wareId
(
$userId
,
$coursewareInfo
[
'id'
]
)
===
NULL
?
FALSE
:
TRUE
);
if
(
!
Yii
::
$app
->
user
->
isGuest
)
{
if
(
!
Yii
::
$app
->
user
->
isGuest
)
{
$coursewareInfo
[
'userAvatar'
]
=
User
::
getAvatarUrl
(
Yii
::
$app
->
user
->
identity
->
avatar
);
$coursewareInfo
[
'userAvatar'
]
=
User
::
getAvatarUrl
(
Yii
::
$app
->
user
->
identity
->
avatar
);
}
}
$coursewareInfo
[
'classId'
]
=
$course
->
class_id
;
$coursewareInfo
[
'classId'
]
=
$course
->
class_id
;
$coursewareInfo
[
'className'
]
=
Classes
::
findOne
([
'id'
=>
$course
->
class_id
])
->
name
;
$coursewareInfo
[
'className'
]
=
Classes
::
findOne
([
'id'
=>
$course
->
class_id
])
->
name
;
return
$this
->
render
(
'video'
,
[
return
$this
->
render
(
'video'
,
[
'coursewareInfo'
=>
$coursewareInfo
'coursewareInfo'
=>
$coursewareInfo
]);
]);
...
@@ -223,7 +225,7 @@ class HomeController extends \yii\web\Controller
...
@@ -223,7 +225,7 @@ class HomeController extends \yii\web\Controller
$courseware
=
Courseware
::
findOne
([
'id'
=>
$coursewareId
]);
$courseware
=
Courseware
::
findOne
([
'id'
=>
$coursewareId
]);
//数据不存在则异常
//数据不存在则异常
if
(
$courseware
!==
NULL
)
{
if
(
$courseware
!==
NULL
)
{
$favorite
=
Favorite
::
findByUserIdAndCourseId
(
$userId
,
$coursewareId
);
$favorite
=
Favorite
::
findByUserIdAndCourse
ware
Id
(
$userId
,
$coursewareId
);
if
(
$favorite
===
NULL
)
{
if
(
$favorite
===
NULL
)
{
$favorite
=
new
Favorite
();
$favorite
=
new
Favorite
();
$favorite
->
user_id
=
$userId
;
$favorite
->
user_id
=
$userId
;
...
@@ -295,9 +297,9 @@ class HomeController extends \yii\web\Controller
...
@@ -295,9 +297,9 @@ class HomeController extends \yii\web\Controller
$retData
=
[
$retData
=
[
'id'
=>
$comments
->
id
,
'id'
=>
$comments
->
id
,
'content'
=>
$content
,
'content'
=>
$content
,
'created_at'
=>
$comments
->
created_at
,
'created_at'
=>
$comments
->
created_at
,
'user_id'
=>
$userId
,
'user_id'
=>
$userId
,
'username'
=>
Yii
::
$app
->
user
->
identity
->
username
,
'username'
=>
Yii
::
$app
->
user
->
identity
->
username
,
'avatar'
=>
Yii
::
$app
->
user
->
identity
->
avatar
,
'avatar'
=>
Yii
::
$app
->
user
->
identity
->
avatar
,
];
];
}
else
{
}
else
{
...
@@ -321,6 +323,44 @@ class HomeController extends \yii\web\Controller
...
@@ -321,6 +323,44 @@ class HomeController extends \yii\web\Controller
}
}
}
}
/**
* 记录浏览记录
* @param $coursewareId
* @throws ForbiddenHttpException
*/
public
function
actionBrowseRecord
(
$coursewareId
)
{
if
(
Yii
::
$app
->
request
->
isAjax
)
{
$userId
=
Yii
::
$app
->
user
->
identity
->
getId
();
$courseware
=
Courseware
::
findOne
([
'id'
=>
$coursewareId
]);
if
(
$courseware
!==
NULL
)
{
$browseRecord
=
BrowseRecord
::
findByUserIdAndCoursewareId
(
$userId
,
$coursewareId
);
if
(
$browseRecord
===
NULL
)
{
$browseRecord
=
new
BrowseRecord
();
$browseRecord
->
user_id
=
$userId
;
$browseRecord
->
course_id
=
$courseware
->
course_id
;
$browseRecord
->
courseware_id
=
$courseware
->
id
;
$browseRecord
->
time
=
time
();
$result
=
$browseRecord
->
save
();
//统计数据
$courseware
->
play_count
++
;
$courseware
->
update
();
$course
=
Course
::
findOne
([
'id'
=>
$courseware
->
course_id
]);
$course
->
play_count
++
;
$course
->
update
();
}
else
{
$browseRecord
->
time
=
time
();
$result
=
$browseRecord
->
update
();
}
}
else
{
throw
new
InvalidParamException
(
'参数错误'
);
}
Utils
::
ajaxResponse
(
$result
);
}
else
{
throw
new
\yii\web\ForbiddenHttpException
(
'非法请求'
);
}
}
/**
/**
* 支付宝支付请求
* 支付宝支付请求
* @throws InvalidParamException
* @throws InvalidParamException
...
...
src/frontend/controllers/UserCenterController.php
View file @
1e3ae2af
...
@@ -49,11 +49,6 @@ class UserCenterController extends Controller
...
@@ -49,11 +49,6 @@ class UserCenterController extends Controller
];
];
}
}
public
function
actionTest
()
{
$user
=
Yii
::
$app
->
user
->
identity
;
var_dump
(
$user
->
getBrowseRecords
());
}
/**
/**
* 个人信息页面
* 个人信息页面
...
@@ -77,10 +72,12 @@ class UserCenterController extends Controller
...
@@ -77,10 +72,12 @@ class UserCenterController extends Controller
public
function
actionPurchasedCourse
()
public
function
actionPurchasedCourse
()
{
{
$page
=
Yii
::
$app
->
request
->
get
(
'page'
,
0
);
$page
=
Yii
::
$app
->
request
->
get
(
'page'
,
0
);
$page
--
;
$num
=
Yii
::
$app
->
request
->
get
(
'num'
,
10
);
$num
=
Yii
::
$app
->
request
->
get
(
'num'
,
10
);
$purchasedCourse
=
Orders
::
findPurchasedCourseByUserId
(
Yii
::
$app
->
user
->
getId
(),
$page
,
$num
);
$purchasedCourse
=
Orders
::
findPurchasedCourseByUserId
(
Yii
::
$app
->
user
->
getId
(),
$page
,
$num
);
var_dump
(
$purchasedCourse
);
exit
;
return
$this
->
render
(
'purchasedCourse'
,
[
return
$this
->
render
(
'purchasedCourse'
);
'purchasedCourse'
=>
$purchasedCourse
]);
}
}
/**
/**
...
@@ -105,9 +102,14 @@ class UserCenterController extends Controller
...
@@ -105,9 +102,14 @@ class UserCenterController extends Controller
*/
*/
public
function
actionBrowseRecord
()
public
function
actionBrowseRecord
()
{
{
$browseRecord
=
BrowseRecord
::
getByUserId
(
Yii
::
$app
->
user
->
getId
());
$page
=
Yii
::
$app
->
request
->
get
(
'page'
,
0
);
$page
--
;
$num
=
Yii
::
$app
->
request
->
get
(
'per-page'
,
10
);
$browseRecord
=
BrowseRecord
::
findByUserId
(
Yii
::
$app
->
user
->
getId
(),
$page
,
$num
);
return
$this
->
render
(
'browseRecord'
);
return
$this
->
render
(
'browseRecord'
,
[
'browseRecord'
=>
$browseRecord
]);
}
}
...
...
src/frontend/views/user-center/browseRecord.php
View file @
1e3ae2af
...
@@ -6,101 +6,62 @@
...
@@ -6,101 +6,62 @@
* Time: 上午9:59
* Time: 上午9:59
*/
*/
use
\frontend\assets\AppAsset
;
use
\frontend\assets\AppAsset
;
use
yii\widgets\LinkPager
;
$baseUrl
=
\yii\helpers\Url
::
base
();
$this
->
title
=
'浏览记录'
;
$this
->
title
=
'浏览记录'
;
\frontend\assets\AppAsset
::
addScript
(
$this
,
'@web/assets/user_center_browse_record.js'
)
\frontend\assets\AppAsset
::
addScript
(
$this
,
'@web/assets/user_center_browse_record.js'
)
?>
?>
<div
class=
"empty-data"
>
<?php
if
(
$browseRecord
[
'count'
]
>
0
)
:
?>
您还没购买任何课程!
<div
class=
"cls-list-box clearfix"
>
</div>
<?php
foreach
(
$browseRecord
[
'data'
]
as
$key
=>
$value
)
:
?>
<div
class=
"cls-list-box hide"
>
<div
class=
"col-md-4"
>
<div
class=
"col-md-4"
>
<div
class=
"cls-box-main sm-box"
>
<div
class=
"cls-box-main sm-box"
>
<div
class=
"video-img-box"
>
<div
class=
"video-img-box"
>
<img
src=
"
<?=
AppAsset
::
getStaticUrl
(
'img/videoimg.jpg'
)
?>
"
>
<img
src=
"
<?=
Yii
::
$app
->
qiniu
->
getUrl
(
'public'
,
$value
[
'course'
][
'preview_pic'
])
?>
"
>
<div
class=
"video-list-cnt"
>
<div
class=
"video-list-cnt"
>
<div
class=
"tit"
><a
href=
"#"
>
英国为什么比中国先进入工业时代?
</a></div>
<div
class=
"tit"
><a
href=
"
<?php
echo
$baseUrl
.
'/home/video?courseId='
.
$value
[
'course'
][
'id'
];
?>
"
>
<?=
$value
[
'course'
][
'name'
]
?>
</a></div>
<div
class=
"price"
>
¥182.97
</div>
<div
class=
"price"
>
<?=
$value
[
'course'
][
'price'
]
?>
</div>
</div>
<div
class=
"teacher"
>
<div
class=
"outline"
>
讲师:
<?php
foreach
(
$value
[
'course'
][
'teachers'
]
as
$teaKey
=>
$teaValue
)
:
?>
<span>
购买日期:2016年9月12日 16:02
</span>
<?php
if
(
$teaKey
>
0
)
:
?>
</div>
,
<?=
$teaValue
[
'name'
]
?>
<?php
else
:
?>
<?=
$teaValue
[
'name'
]
?>
<?php
endif
?>
<?php
endforeach
;
?>
</div>
</div>
<div
class=
"outline"
>
<span>
<?=
date
(
"Y-m-d H:i:s"
,
$value
[
'time'
])
?>
</span>
</div>
<div
class=
"play-mask"
>
<a
href=
"
<?php
echo
$baseUrl
.
'/home/video?courseId='
.
$value
[
'course'
][
'id'
];
?>
"
><i
class=
"glyphicon glyphicon-play"
></i></a>
</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>
</div>
</div>
<?php
endforeach
;
?>
<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>
<div
class=
"col-md-4"
>
<div
class=
"container text-center"
>
<div
class=
"cls-box-main sm-box"
>
<?php
echo
LinkPager
::
widget
([
<div
class=
"video-img-box"
>
'pagination'
=>
$browseRecord
[
'pagination'
],
<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>
<?php
else
:
?>
<div
class=
"col-md-4"
>
<div
class=
"empty-data"
>
<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>
<?php
endif
;
?>
<div
class=
"cls-list-box hide"
>
<div
class=
"col-md-4"
>
<div
class=
"col-md-4"
>
<div
class=
"cls-box-main sm-box"
>
<div
class=
"cls-box-main sm-box"
>
<div
class=
"video-img-box"
>
<div
class=
"video-img-box"
>
...
...
src/frontend/views/user-center/favorite.php
View file @
1e3ae2af
...
@@ -14,15 +14,15 @@ $this->title = '收藏记录';
...
@@ -14,15 +14,15 @@ $this->title = '收藏记录';
?>
?>
<?php
if
(
$favorite
[
'count'
]
>
0
)
:?>
<div
class=
"cls-list-box clearfix"
>
<
div
class
="
cls
-
list
-
box
clearfix
">
<?php
foreach
(
$favorite
[
'data'
]
as
$key
=>
$value
)
:
?>
<?php foreach (
$favorite['data']
as
$key
=>
$value
): ?>
<div
class=
"col-md-4"
>
<div class="
col
-
md
-
4
">
<div
class=
"cls-box-main sm-box"
>
<div class="
cls
-
box
-
main
sm
-
box
">
<div
class=
"video-img-box"
>
<div class="
video
-
img
-
box
">
<img
src=
"
<?=
Yii
::
$app
->
qiniu
->
getUrl
(
'public'
,
$value
[
'course'
][
'preview_pic'
])
?>
"
>
<img src="
<?=
Yii
::
$app
->
qiniu
->
getUrl
(
'public'
,
$value
[
'course'
][
'preview_pic'
])
?>
">
<div
class=
"video-list-cnt"
>
<div
class=
"video-list-cnt"
>
<div
class=
"tit"
><a
href=
"
<?php
echo
$baseUrl
.
'/home/video?courseId='
.
$value
[
'course'
][
'id'
];
?>
"
>
<?=
$value
[
'course'
][
'name'
]
?>
</a></div>
<div
class=
"tit"
><a
href=
"
<?php
echo
$baseUrl
.
'/home/video?courseId='
.
$value
[
'course'
][
'id'
];
?>
"
>
<?=
$value
[
'course'
][
'name'
]
?>
</a></div>
<div
class=
"teacher"
>
<div
class=
"teacher"
>
讲师:
<?php
foreach
(
$value
[
'course'
][
'teachers'
]
as
$teaKey
=>
$teaValue
)
:
?>
讲师:
<?php
foreach
(
$value
[
'course'
][
'teachers'
]
as
$teaKey
=>
$teaValue
)
:
?>
<?php
if
(
$teaKey
>
0
)
:
?>
<?php
if
(
$teaKey
>
0
)
:
?>
...
@@ -32,27 +32,33 @@ $this->title = '收藏记录';
...
@@ -32,27 +32,33 @@ $this->title = '收藏记录';
<?php
endif
?>
<?php
endif
?>
<?php
endforeach
;
?>
<?php
endforeach
;
?>
</div>
</div>
<div
class=
"price"
>
<?=
$value
[
'course'
][
'price'
]
?>
</div>
<div
class=
"price"
>
<?=
$value
[
'course'
][
'price'
]
?>
</div>
</div>
</div>
<div
class=
"outline"
>
<div
class=
"outline"
>
<span>
<?=
$value
[
'course'
][
'user'
][
'username'
]
?>
收藏了该内容
</span>
<span>
<?=
$value
[
'course'
][
'user'
][
'username'
]
?>
收藏了该内容
</span>
</div>
</div>
<div
class=
"play-mask"
>
<div
class=
"play-mask"
>
<a
href=
"
<?php
echo
$baseUrl
.
'/home/video?courseId='
.
$value
[
'course'
][
'id'
];
?>
"
><i
class=
"glyphicon glyphicon-play"
></i></a>
<a
href=
"
<?php
echo
$baseUrl
.
'/home/video?courseId='
.
$value
[
'course'
][
'id'
];
?>
"
><i
class=
"glyphicon glyphicon-play"
></i></a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php
endforeach
;
?>
<?php
endforeach
;
?>
</div>
</div>
<div
class=
"container text-center"
>
<?php
echo
LinkPager
::
widget
([
'pagination'
=>
$favorite
[
'pagination'
],
]);
?>
</div>
<?php
else
:?>
<
div
class
="
empty
-
data
">
您没有任何收藏记录!
</div>
<?php endif;?>
<div
class=
"container text-center"
>
<?php
echo
LinkPager
::
widget
([
'pagination'
=>
$favorite
[
'pagination'
],
]);
?>
</div>
src/frontend/views/user-center/purchasedCourse.php
View file @
1e3ae2af
...
@@ -5,118 +5,58 @@
...
@@ -5,118 +5,58 @@
* Date: 2016/9/29
* Date: 2016/9/29
* Time: 上午9:59
* Time: 上午9:59
*/
*/
use
\frontend\assets\AppAsset
;
use
yii\widgets\LinkPager
;
$baseUrl
=
\yii\helpers\Url
::
base
();
$this
->
title
=
'已购课程'
;
$this
->
title
=
'已购课程'
;
\frontend\assets\AppAsset
::
addScript
(
$this
,
'@web/assets/user_center_purchased_course.js'
)
\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>
<?php
if
(
$purchasedCourse
[
'count'
]
>
0
)
:?>
<
div
class
="
cls
-
list
-
box
clearfix
">
<div
class=
"play-mask"
>
<?php foreach (
$purchasedCourse['data']
as
$key
=>
$value
): ?>
<a
href=
"#"
><i
class=
"glyphicon glyphicon-play"
></i></a>
<div class="
col
-
md
-
4
">
<div class="
cls
-
box
-
main
sm
-
box
">
<div class="
video
-
img
-
box
">
<img src="
<?=
Yii
::
$app
->
qiniu
->
getUrl
(
'public'
,
$value
[
'courseWithTeachers'
][
'preview_pic'
])
?>
">
<div
class=
"video-list-cnt"
>
<div
class=
"tit"
><a
href=
"
<?php
echo
$baseUrl
.
'/home/video?courseId='
.
$value
[
'courseWithTeachers'
][
'id'
];
?>
"
>
<?=
$value
[
'courseWithTeachers'
][
'name'
]
?>
</a></div>
<div
class=
"price"
>
<?=
$value
[
'courseWithTeachers'
][
'price'
]
?>
</div>
<div
class=
"teacher"
>
讲师:
<?php
foreach
(
$value
[
'courseWithTeachers'
][
'teachers'
]
as
$teaKey
=>
$teaValue
)
:
?>
<?php
if
(
$teaKey
>
0
)
:
?>
,
<?=
$teaValue
[
'name'
]
?>
<?php
else
:
?>
<?=
$teaValue
[
'name'
]
?>
<?php
endif
?>
<?php
endforeach
;
?>
</div>
</div>
<div
class=
"outline"
>
<span>
购买日期:
<?=
date
(
"Y-m-d H:i:s"
,
$value
[
'updated_at'
])
?>
</span>
</div>
<div
class=
"play-mask"
>
<a
href=
"
<?php
echo
$baseUrl
.
'/home/video?courseId='
.
$value
[
'courseWithTeachers'
][
'id'
];
?>
"
><i
class=
"glyphicon glyphicon-play"
></i></a>
</div>
</div>
</div>
</div>
</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"
>
<?php
endforeach
;
?>
<a
href=
"#"
><i
class=
"glyphicon glyphicon-play"
></i></a>
</div>
</div>
</div>
</div>
</div>
<div
class=
"container text-center"
>
<div
class=
"col-md-4"
>
<?php
echo
LinkPager
::
widget
([
<div
class=
"cls-box-main sm-box"
>
'pagination'
=>
$purchasedCourse
[
'pagination'
],
<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>
<div
class=
"col-md-4"
>
<?php
else
:?>
<div
class=
"cls-box-main sm-box"
>
<
div
class
="
empty
-
data
">
<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>
<
/div
>
<
?php endif;?
>
src/frontend/web/js/home/video.js
View file @
1e3ae2af
...
@@ -23,6 +23,17 @@ $("#main-login").attr('href', 'javascript:;').click(function () {
...
@@ -23,6 +23,17 @@ $("#main-login").attr('href', 'javascript:;').click(function () {
});
});
//记录浏览记录
var
url
=
__BASE_URL__
+
'home/browse-record?coursewareId='
+
coursewareInfo
.
id
;
$
.
getJSON
(
url
,
function
(
response
)
{
if
(
response
.
status
===
false
)
{
layer
.
alert
(
'浏览记录添加逻辑错误'
,
{
'icon'
:
2
,
'title'
:
'提示'
})
}
}).
error
(
function
()
{
layer
.
alert
(
'添加浏览记录错误'
,
{
'icon'
:
2
,
'title'
:
'提示'
})
});
var
href
=
$
(
'#main-sign'
).
attr
(
"href"
);
var
href
=
$
(
'#main-sign'
).
attr
(
"href"
);
$
(
'#main-sign'
).
attr
(
'href'
,
href
+
'?from='
+
coursewareInfo
.
user_id
);
$
(
'#main-sign'
).
attr
(
'href'
,
href
+
'?from='
+
coursewareInfo
.
user_id
);
new
Vue
({
new
Vue
({
...
...
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