1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-27 04:57:39 +08:00

完成我的订单以及课程,用户列表等分排列

This commit is contained in:
xiaochong0302 2020-06-09 19:07:25 +08:00
parent a900da52ac
commit b6f9a08fee
19 changed files with 303 additions and 112 deletions

View File

@ -12,8 +12,8 @@ use App\Services\Frontend\Course\PackageList as CoursePackageListService;
use App\Services\Frontend\Course\RecommendedList as CourseRecommendedListService; use App\Services\Frontend\Course\RecommendedList as CourseRecommendedListService;
use App\Services\Frontend\Course\RelatedList as CourseRelatedListService; use App\Services\Frontend\Course\RelatedList as CourseRelatedListService;
use App\Services\Frontend\Course\ReviewList as CourseReviewListService; use App\Services\Frontend\Course\ReviewList as CourseReviewListService;
use App\Services\Frontend\Course\TeacherList as CourseTeacherListService;
use App\Services\Frontend\Course\TopicList as CourseTopicListService; use App\Services\Frontend\Course\TopicList as CourseTopicListService;
use App\Services\Frontend\Course\UserList as CourseTeacherListService;
use App\Services\Frontend\Reward\OptionList as RewardOptionList; use App\Services\Frontend\Reward\OptionList as RewardOptionList;
use Phalcon\Mvc\View; use Phalcon\Mvc\View;
@ -28,9 +28,12 @@ class CourseController extends Controller
*/ */
public function listAction() public function listAction()
{ {
$_REQUEST['limit'] = 12;
$service = new CourseListService(); $service = new CourseListService();
$pager = $service->handle(); $pager = $service->handle();
$pager->items = kg_array_object($pager->items); $pager->items = kg_array_object($pager->items);
$service = new CourseQueryService(); $service = new CourseQueryService();
@ -73,12 +76,12 @@ class CourseController extends Controller
$service = new RewardOptionList(); $service = new RewardOptionList();
$rewards = $service->handle(); $rewardOptions = $service->handle();
$this->view->setVar('course', $course); $this->view->setVar('course', $course);
$this->view->setVar('chapters', $chapters); $this->view->setVar('chapters', $chapters);
$this->view->setVar('teachers', $teachers); $this->view->setVar('teachers', $teachers);
$this->view->setVar('rewards', $rewards); $this->view->setVar('reward_options', $rewardOptions);
} }
/** /**

View File

@ -8,6 +8,7 @@ use App\Services\Frontend\My\OrderList as MyOrderListService;
use App\Services\Frontend\My\RefundList as MyRefundListService; use App\Services\Frontend\My\RefundList as MyRefundListService;
use App\Services\Frontend\My\ReviewList as MyReviewListService; use App\Services\Frontend\My\ReviewList as MyReviewListService;
use App\Services\Frontend\My\UserInfo as UserInfoService; use App\Services\Frontend\My\UserInfo as UserInfoService;
use App\Services\Frontend\My\UserUpdate as UserUpdateService;
/** /**
* @RoutePrefix("/my") * @RoutePrefix("/my")
@ -50,18 +51,6 @@ class MyController extends Controller
$this->view->setVar('account', $account); $this->view->setVar('account', $account);
} }
/**
* @Post("/profile/update", name="web.my.update_profile")
*/
public function updateProfileAction()
{
$service = new UserInfoService();
$user = $service->handle();
$this->view->setVar('user', $user);
}
/** /**
* @Get("/consults", name="web.my.consults") * @Get("/consults", name="web.my.consults")
*/ */
@ -95,6 +84,8 @@ class MyController extends Controller
$pager = $service->handle(); $pager = $service->handle();
$pager->items = kg_array_object($pager->items);
$this->view->setVar('pager', $pager); $this->view->setVar('pager', $pager);
} }
@ -110,4 +101,18 @@ class MyController extends Controller
$this->view->setVar('pager', $pager); $this->view->setVar('pager', $pager);
} }
/**
* @Post("/profile/update", name="web.my.update_profile")
*/
public function updateProfileAction()
{
$service = new UserUpdateService();
$service->handle();
$content = ['msg' => '更新资料成功'];
return $this->jsonSuccess($content);
}
} }

View File

@ -20,9 +20,9 @@ class VipController extends Controller
{ {
$service = new VipOptionListService(); $service = new VipOptionListService();
$vipOptionList = $service->handle(); $vipOptions = $service->handle();
$this->view->setVar('vip_option_list', $vipOptionList); $this->view->setVar('vip_options', $vipOptions);
} }
/** /**

View File

@ -62,21 +62,40 @@ class Index extends Service
{ {
$cache = new IndexNewCourseListCache(); $cache = new IndexNewCourseListCache();
return $cache->get(); $courses = $cache->get();
return $this->handleCategoryCourses($courses);
} }
public function getFreeCourses() public function getFreeCourses()
{ {
$cache = new IndexFreeCourseListCache(); $cache = new IndexFreeCourseListCache();
return $cache->get(); $courses = $cache->get();
return $this->handleCategoryCourses($courses);
} }
public function getVipCourses() public function getVipCourses()
{ {
$cache = new IndexVipCourseListCache(); $cache = new IndexVipCourseListCache();
return $cache->get(); $courses = $cache->get();
return $this->handleCategoryCourses($courses);
}
protected function handleCategoryCourses($items, $limit = 8)
{
if (count($items) == 0) {
return [];
}
foreach ($items as &$item) {
$item['courses'] = array_slice($item['courses'], 0, $limit);
}
return $items;
} }
} }

View File

@ -6,10 +6,14 @@
{{ partial('course/list_filter') }} {{ partial('course/list_filter') }}
{% if pager.total_pages > 0 %} {% if pager.total_pages > 0 %}
<div class="course-list container clearfix"> <div class="course-list clearfix">
{% for item in pager.items %} <div class="layui-row layui-col-space20">
{{ course_card(item) }} {% for item in pager.items %}
{% endfor %} <div class="layui-col-md3">
{{ course_card(item) }}
</div>
{% endfor %}
</div>
</div> </div>
{{ partial('partials/pager') }} {{ partial('partials/pager') }}
{% else %} {% else %}

View File

@ -15,10 +15,10 @@
<div class="layui-card-header">赞赏支持</div> <div class="layui-card-header">赞赏支持</div>
<div class="layui-card-body"> <div class="layui-card-body">
<div class="sidebar-order"> <div class="sidebar-order">
{% for reward in rewards %} {% for option in reward_options %}
{% set item_id = [course.id,reward.id]|join('-') %} {% set item_id = [course.id,option.id]|join('-') %}
{% set order_url = url({'for':'web.order.confirm'},{'item_id':item_id,'item_type':'reward'}) %} {% set order_url = url({'for':'web.order.confirm'},{'item_id':item_id,'item_type':'reward'}) %}
<a class="layui-btn layui-btn-xs reward-btn" href="{{ order_url }}">{{ reward.title }}</a> <a class="layui-btn layui-btn-xs reward-btn" href="{{ order_url }}">{{ option.title }}</a>
{% endfor %} {% endfor %}
</div> </div>
</div> </div>

View File

@ -49,16 +49,16 @@
{{ partial('course/chapters') }} {{ partial('course/chapters') }}
</div> </div>
{% if show_tab_packages == 1 %} {% if show_tab_packages == 1 %}
{% set package_url = url({'for':'web.course.packages','id':course.id}) %} {% set packages_url = url({'for':'web.course.packages','id':course.id}) %}
<div class="layui-tab-item" id="tab-packages" data-url="{{ package_url }}"></div> <div class="layui-tab-item" id="tab-packages" data-url="{{ packages_url }}"></div>
{% endif %} {% endif %}
{% if show_tab_consults == 1 %} {% if show_tab_consults == 1 %}
{% set consult_url = url({'for':'web.course.consults','id':course.id}) %} {% set consults_url = url({'for':'web.course.consults','id':course.id}) %}
<div class="layui-tab-item" id="tab-consults" data-url="{{ consult_url }}"></div> <div class="layui-tab-item" id="tab-consults" data-url="{{ consults_url }}"></div>
{% endif %} {% endif %}
{% if show_tab_reviews == 1 %} {% if show_tab_reviews == 1 %}
{% set review_url = url({'for':'web.course.reviews','id':course.id}) %} {% set reviews_url = url({'for':'web.course.reviews','id':course.id}) %}
<div class="layui-tab-item" id="tab-reviews" data-url="{{ review_url }}"></div> <div class="layui-tab-item" id="tab-reviews" data-url="{{ reviews_url }}"></div>
{% endif %} {% endif %}
</div> </div>
</div> </div>
@ -74,8 +74,8 @@
{{ partial('course/order') }} {{ partial('course/order') }}
{{ partial('course/teachers') }} {{ partial('course/teachers') }}
{% if show_sidebar_topics %} {% if show_sidebar_topics %}
{% set topic_url = url({'for':'web.course.topics','id':course.id}) %} {% set topics_url = url({'for':'web.course.topics','id':course.id}) %}
<div class="sidebar" id="sidebar-topics" data-url="{{ topic_url }}"></div> <div class="sidebar" id="sidebar-topics" data-url="{{ topics_url }}"></div>
{% endif %} {% endif %}
{% if show_sidebar_recommended %} {% if show_sidebar_recommended %}
{% set recommended_url = url({'for':'web.course.recommended','id':course.id}) %} {% set recommended_url = url({'for':'web.course.recommended','id':course.id}) %}

View File

@ -5,14 +5,14 @@
{% set teacher_url = url({'for':'web.user.show','id':teacher.id}) %} {% set teacher_url = url({'for':'web.user.show','id':teacher.id}) %}
<div class="sidebar-teacher-card clearfix" title="{{ teacher.about|e }}"> <div class="sidebar-teacher-card clearfix" title="{{ teacher.about|e }}">
<div class="avatar"> <div class="avatar">
<img src="{{ teacher.avatar }}" alt="{{ teacher.about|e }}"> <img src="{{ teacher.avatar }}" alt="{{ teacher.name }}">
</div> </div>
<div class="info"> <div class="info">
<div class="name"> <div class="name layui-elip">
<a href="{{ teacher_url }}">{{ teacher.name }}</a> <a href="{{ teacher_url }}">{{ teacher.name }}</a>
</div> </div>
{% set title = teacher.title ? teacher.title : '小小教书匠' %} {% set title = teacher.title ? teacher.title : '小小教书匠' %}
<div class="title">{{ title }}</div> <div class="title layui-elip">{{ title }}</div>
</div> </div>
</div> </div>
{% endfor %} {% endfor %}

View File

@ -17,9 +17,13 @@
{% set class = loop.first ? 'layui-tab-item layui-show' : 'layui-tab-item' %} {% set class = loop.first ? 'layui-tab-item layui-show' : 'layui-tab-item' %}
<div class="{{ class }}"> <div class="{{ class }}">
<div class="index-course-list clearfix"> <div class="index-course-list clearfix">
{% for course in category.courses %} <div class="layui-row layui-col-space20">
{{ course_card(course) }} {% for course in category.courses %}
{% endfor %} <div class="layui-col-md3">
{{ course_card(course) }}
</div>
{% endfor %}
</div>
</div> </div>
</div> </div>
{% endfor %} {% endfor %}

View File

@ -0,0 +1,61 @@
{% extends 'templates/full.volt' %}
{% block content %}
{{ partial('partials/macro_order') }}
{% set status_types = {'all':'全部订单','pending':'待支付','finished':'已完成','closed':'已关闭','refunded':'已退款'} %}
<div class="layui-breadcrumb breadcrumb">
<a href="/">首页</a>
<a><cite>我的订单</cite></a>
</div>
<div class="container">
<div class="order-filter">
{% set status = request.get('status','trim','all') %}
{% for key,val in status_types %}
{% set class = (status == key) ? 'layui-btn layui-btn-sm' : 'none' %}
{% set url = (key == 'all') ? url({'for':'web.my.orders'}) : url({'for':'web.my.orders'},{'status':key}) %}
<a class="{{ class }}" href="{{ url }}">{{ val }}</a>
{% endfor %}
</div>
{% if pager.total_pages > 0 %}
<table class="layui-table kg-table" lay-size="lg" lay-skin="nob">
<colgroup>
<col>
<col>
<col>
<col>
</colgroup>
<thead>
<tr>
<th>信息</th>
<th>金额</th>
<th>时间</th>
<th>状态</th>
<th>操作</th>
</tr>
</thead>
<tbody>
{% for item in pager.items %}
<tr>
<td>
<p>名称:{{ item.subject }}</p>
<p>单号:{{ item.sn }}</p>
</td>
<td>¥{{ item.amount }}</td>
<td>{{ date('Y-m-d H:i',item.create_time) }}</td>
<td>{{ order_status(item.status) }}</td>
<td align="center">
<a class="btn-view layui-btn layui-btn-xs" data-url="">详情</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{{ partial('partials/pager') }}
{% endif %}
</div>
{% endblock %}

View File

@ -11,7 +11,7 @@
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">昵称</label> <label class="layui-form-label">昵称</label>
<div class="layui-input-block"> <div class="layui-input-block">
<input class="layui-input" type="text" name="name" lay-verify="required"> <input class="layui-input" type="text" name="name" value="{{ user.name }}" lay-verify="required">
</div> </div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">

View File

@ -39,6 +39,7 @@
{% else %} {% else %}
<span class="free">会员免费</span> <span class="free">会员免费</span>
{% endif %} {% endif %}
<span class="level">{{ level_info(course.level) }}</span>
<span class="user">{{ course.user_count }}人购买</span> <span class="user">{{ course.user_count }}人购买</span>
{% elseif course.market_price > 0 %} {% elseif course.market_price > 0 %}
<span class="price">¥{{ course.market_price }}</span> <span class="price">¥{{ course.market_price }}</span>

View File

@ -0,0 +1,11 @@
{%- macro order_status(value) %}
{% if value == 'pending' %}
<span class="layui-badge layui-bg-blue">待支付</span>
{% elseif value == 'finished' %}
<span class="layui-badge layui-bg-green">已完成</span>
{% elseif value == 'closed' %}
<span class="layui-badge layui-bg-cyan">已关闭</span>
{% elseif value == 'refunded' %}
<span class="layui-badge layui-bg-red">已退款</span>
{% endif %}
{%- endmacro %}

View File

@ -9,17 +9,24 @@
{% if pager.total_pages > 0 %} {% if pager.total_pages > 0 %}
<div class="teach-user-list clearfix"> <div class="teach-user-list clearfix">
{% for item in pager.items %} <div class="layui-row layui-col-space20">
{% set teacher_title = item.title ? item.title : '小小教书匠' %} {% for item in pager.items %}
{% set teacher_url = url({'for':'web.teacher.show','id':item.id}) %} {% set user_title = item.title ? item.title : '小小教书匠' %}
<div class="user-card" title="{{ item.about|e }}"> {% set user_about = item.about ? item.about|e : '这个人很懒,什么都没留下' %}
<div class="avatar"> {% set user_url = url({'for':'web.teacher.show','id':item.id}) %}
<a href="{{ teacher_url }}"><img src="{{ item.avatar }}" alt="{{ item.name }}"></a> <div class="layui-col-md3">
<div class="user-card" title="{{ user_about }}">
<div class="avatar">
<a href="{{ user_url }}"><img src="{{ item.avatar }}" alt="{{ item.name }}"></a>
</div>
<div class="name layui-elip">
<a href="{{ user_url }}">{{ item.name }}</a>
</div>
<div class="title layui-elip">{{ user_title }}</div>
</div>
</div> </div>
<div class="name"><a href="{{ teacher_url }}">{{ item.name }}</a></div> {% endfor %}
<div class="title">{{ teacher_title }}</div> </div>
</div>
{% endfor %}
</div> </div>
{{ partial('partials/pager') }} {{ partial('partials/pager') }}
{% endif %} {% endif %}

View File

@ -2,9 +2,13 @@
{% if pager.total_pages > 0 %} {% if pager.total_pages > 0 %}
<div class="course-list clearfix"> <div class="course-list clearfix">
{% for item in pager.items %} <div class="layui-row layui-col-space20">
{{ course_card(item) }} {% for item in pager.items %}
{% endfor %} <div class="layui-col-md3">
{{ course_card(item) }}
</div>
{% endfor %}
</div>
</div> </div>
{{ partial('partials/pager_ajax') }} {{ partial('partials/pager_ajax') }}
{% endif %} {% endif %}

View File

@ -15,21 +15,25 @@
<div class="vip-header">开通会员</div> <div class="vip-header">开通会员</div>
<div class="vip-option-list clearfix"> <div class="vip-option-list">
{% for option in vip_option_list %} <div class="layui-row layui-col-space20">
{% set order_url = url({'for':'web.order.confirm'},{'item_id':option.id,'item_type':'vip'}) %} {% for option in vip_options %}
<div class="vip-option-card"> {% set order_url = url({'for':'web.order.confirm'},{'item_id':option.id,'item_type':'vip'}) %}
<div class="title">{{ option.title }}</div> <div class="layui-col-md3">
<div class="price">¥{{ option.price }}</div> <div class="vip-option-card">
<div class="order"><a class="layui-btn layui-btn-sm layui-bg-red" href="{{ order_url }}">立即开通</a></div> <div class="title">{{ option.title }}</div>
</div> <div class="price">¥{{ option.price }}</div>
{% endfor %} <div class="order"><a class="layui-btn layui-btn-sm layui-bg-red" href="{{ order_url }}">立即开通</a></div>
</div>
</div>
{% endfor %}
</div>
</div> </div>
{% set courses_url = url({'for':'web.vip.courses'}) %} {% set courses_url = url({'for':'web.vip.courses'},{'limit':12}) %}
{% set users_url = url({'for':'web.vip.users'}) %} {% set users_url = url({'for':'web.vip.users'},{'limit':12}) %}
<div class="container"> <div class="vip-tab-container">
<div class="layui-tab layui-tab-brief user-tab"> <div class="layui-tab layui-tab-brief user-tab">
<ul class="layui-tab-title"> <ul class="layui-tab-title">
<li class="layui-this">课程</li> <li class="layui-this">课程</li>

View File

@ -1,15 +1,24 @@
{% if pager.total_pages > 0 %} {% if pager.total_pages > 0 %}
<div class="vip-user-list clearfix"> <div class="vip-user-list clearfix">
{% for item in pager.items %} <div class="layui-row layui-col-space20">
{% set user_url = url({'for':'web.user.show','id':item.id}) %} {% for item in pager.items %}
<div class="user-card" title="{{ item.about|e }}"> {% set user_about = item.about ? item.about|e : '这个人很懒,什么都没留下' %}
<div class="avatar"> {% set user_url = url({'for':'web.user.show','id':item.id}) %}
<a href="{{ user_url }}"><img src="{{ item.avatar }}" alt="{{ item.name }}"></a> <div class="layui-col-md3">
<div class="user-card" title="{{ user_about }}">
<div class="avatar">
<a href="{{ user_url }}"><img src="{{ item.avatar }}" alt="{{ item.name }}"></a>
</div>
<div class="name layui-elip">
<a href="{{ user_url }}">{{ item.name }}</a>
</div>
<div class="title layui-elip">
<span class="layui-badge layui-bg-orange">vip</span>
</div>
</div>
</div> </div>
<div class="name"><a href="{{ user_url }}">{{ item.name }}</a></div> {% endfor %}
<div class="title"><span class="layui-badge layui-bg-orange">vip</span></div> </div>
</div>
{% endfor %}
</div> </div>
{{ partial('partials/pager_ajax') }} {{ partial('partials/pager_ajax') }}
{% endif %} {% endif %}

View File

@ -0,0 +1,51 @@
<?php
namespace App\Services\Frontend\My;
use App\Caches\User as UserCache;
use App\Services\Frontend\Service as FrontendService;
use App\Validators\User as UserValidator;
class UserUpdate extends FrontendService
{
public function handle()
{
$post = $this->request->getPost();
$user = $this->getLoginUser();
$validator = new UserValidator();
$data = [];
if (!empty($post['name'])) {
$data['name'] = $validator->checkName($post['name']);
if ($data['name'] != $user->name) {
$validator->checkIfNameTaken($data['name']);
}
}
if (!empty($post['gender'])) {
$data['gender'] = $validator->checkGender($post['gender']);
}
if (!empty($post['about'])) {
$data['about'] = $validator->checkAbout($post['about']);
}
$user->update($data);
$this->rebuildUserCache($user->id);
return $user;
}
protected function rebuildUserCache($id)
{
$cache = new UserCache();
$cache->rebuild($id);
}
}

View File

@ -101,6 +101,7 @@
} }
.pager { .pager {
margin-top: 25px;
text-align: center; text-align: center;
} }
@ -142,6 +143,10 @@
border-bottom: 1px solid #f6f6f6; border-bottom: 1px solid #f6f6f6;
} }
.index-course-list .course-card {
box-shadow: 0 1px 2px 1px rgba(0, 0, 0, 0.05);
}
.index-carousel { .index-carousel {
text-align: center; text-align: center;
} }
@ -242,20 +247,21 @@
.course-card { .course-card {
float: left; float: left;
width: 20%; width: 100%;
height: 200px; height: 230px;
background-color: #fff;
border-radius: 2px;
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
} }
.course-card .cover { .course-card .cover {
width: 210px;
height: 118px;
margin-bottom: 10px; margin-bottom: 10px;
overflow: hidden; overflow: hidden;
} }
.course-card .cover img { .course-card .cover img {
width: 100%; width: 270px;
height: 100%; height: 152px;
transition: all 0.6s; transition: all 0.6s;
} }
@ -264,15 +270,14 @@
} }
.course-card .title { .course-card .title {
width: 210px; padding: 0 5px;
white-space: nowrap;
margin-bottom: 10px; margin-bottom: 10px;
overflow: hidden;
} }
.course-card .meta { .course-card .meta {
color: #666; color: #666;
font-size: 12px; font-size: 12px;
padding: 0 5px;
} }
.course-card .meta span { .course-card .meta span {
@ -686,21 +691,16 @@
.vip-option-card { .vip-option-card {
float: left; float: left;
width: 262px; width: 100%;
height: 150px; height: 170px;
padding-top: 30px;
margin-right: 30px;
background-color: #fff; background-color: #fff;
border-radius: 2px; border-radius: 2px;
text-align: center; text-align: center;
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
} }
.vip-option-card:last-child {
margin-right: 0;
}
.vip-option-card .title { .vip-option-card .title {
margin-top: 25px;
margin-bottom: 15px; margin-bottom: 15px;
font-size: 18px; font-size: 18px;
} }
@ -989,31 +989,26 @@
color: #666; color: #666;
} }
.teach-user-list .user-card { .teach-user-list {
width: 203px; margin-bottom: 30px;
margin-bottom: 25px; }
.vip-user-list {
margin-bottom: 30px;
}
.user-card {
float: left;
width: 100%;
height: 220px;
text-align: center;
background-color: #fff; background-color: #fff;
border-radius: 2px; border-radius: 2px;
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
} }
.vip-user-list {
margin-bottom: 15px;
}
.vip-user-list .user-card {
width: 195px;
}
.user-card {
float: left;
height: 210px;
margin-right: 25px;
text-align: center;
}
.user-card .avatar { .user-card .avatar {
margin-top: 20px; margin-top: 25px;
margin-bottom: 15px; margin-bottom: 15px;
} }
@ -1095,3 +1090,16 @@
.security-item .action { .security-item .action {
float: right; float: right;
} }
.order-filter {
line-height: 40px;
margin-bottom: 20px;
}
.order-filter a {
margin-right: 30px;
}
.kg-table p {
line-height: 1.8em;
}