1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-24 12:05:39 +08:00

Merge branch 'koogua/v1.5.8'

This commit is contained in:
koogua 2022-08-31 10:28:38 +08:00
commit 73d04e3c63
22 changed files with 530 additions and 227 deletions

View File

@ -1,4 +1,12 @@
### [v1.5.7](https://gitee.com/koogua/course-tencent-cloud/releases/v1.5.7)(2022-08-28) ### [v1.5.8](https://gitee.com/koogua/course-tencent-cloud/releases/v1.5.8)(2022-08-28)
- 整理migrations
- 更新自动安装脚本
- 优化登录/注册/忘记密码页
- 修复移动端首页课程缓存刷新
- sitemap条目增加过滤条件
### [v1.5.7](https://gitee.com/koogua/course-tencent-cloud/releases/v1.5.7)(2022-08-18)
- 清理群组残留 - 清理群组残留
- 升级腾讯云存储SDK到v2.5.6 - 升级腾讯云存储SDK到v2.5.6

View File

@ -39,6 +39,8 @@ class SitemapTask extends Task
$filename = tmp_path('sitemap.xml'); $filename = tmp_path('sitemap.xml');
echo '------ start sitemap task ------' . PHP_EOL;
$this->addIndex(); $this->addIndex();
$this->addCourses(); $this->addCourses();
$this->addArticles(); $this->addArticles();
@ -50,6 +52,8 @@ class SitemapTask extends Task
$this->addOthers(); $this->addOthers();
$this->sitemap->build($filename); $this->sitemap->build($filename);
echo '------ end sitemap task ------' . PHP_EOL;
} }
protected function getSiteUrl() protected function getSiteUrl()
@ -73,6 +77,7 @@ class SitemapTask extends Task
*/ */
$courses = CourseModel::query() $courses = CourseModel::query()
->where('published = 1') ->where('published = 1')
->andWhere('deleted = 0')
->orderBy('id DESC') ->orderBy('id DESC')
->limit(500) ->limit(500)
->execute(); ->execute();
@ -92,6 +97,7 @@ class SitemapTask extends Task
*/ */
$articles = ArticleModel::query() $articles = ArticleModel::query()
->where('published = :published:', ['published' => ArticleModel::PUBLISH_APPROVED]) ->where('published = :published:', ['published' => ArticleModel::PUBLISH_APPROVED])
->andWhere('deleted = 0')
->orderBy('id DESC') ->orderBy('id DESC')
->limit(500) ->limit(500)
->execute(); ->execute();
@ -111,6 +117,7 @@ class SitemapTask extends Task
*/ */
$questions = QuestionModel::query() $questions = QuestionModel::query()
->where('published = :published:', ['published' => QuestionModel::PUBLISH_APPROVED]) ->where('published = :published:', ['published' => QuestionModel::PUBLISH_APPROVED])
->andWhere('deleted = 0')
->orderBy('id DESC') ->orderBy('id DESC')
->limit(500) ->limit(500)
->execute(); ->execute();
@ -128,7 +135,10 @@ class SitemapTask extends Task
/** /**
* @var Resultset|UserModel[] $teachers * @var Resultset|UserModel[] $teachers
*/ */
$teachers = UserModel::query()->where('edu_role = 2')->execute(); $teachers = UserModel::query()
->where('edu_role = :edu_role:', ['edu_role' => UserModel::EDU_ROLE_TEACHER])
->andWhere('deleted = 0')
->execute();
if ($teachers->count() == 0) return; if ($teachers->count() == 0) return;
@ -143,7 +153,10 @@ class SitemapTask extends Task
/** /**
* @var Resultset|TopicModel[] $topics * @var Resultset|TopicModel[] $topics
*/ */
$topics = TopicModel::query()->where('published = 1')->execute(); $topics = TopicModel::query()
->where('published = 1')
->andWhere('deleted = 0')
->execute();
if ($topics->count() == 0) return; if ($topics->count() == 0) return;
@ -158,7 +171,10 @@ class SitemapTask extends Task
/** /**
* @var Resultset|PageModel[] $pages * @var Resultset|PageModel[] $pages
*/ */
$pages = PageModel::query()->where('published = 1')->execute(); $pages = PageModel::query()
->where('published = 1')
->andWhere('deleted = 0')
->execute();
if ($pages->count() == 0) return; if ($pages->count() == 0) return;
@ -173,7 +189,10 @@ class SitemapTask extends Task
/** /**
* @var Resultset|HelpModel[] $helps * @var Resultset|HelpModel[] $helps
*/ */
$helps = HelpModel::query()->where('published = 1')->execute(); $helps = HelpModel::query()
->where('published = 1')
->andWhere('deleted = 0')
->execute();
if ($helps->count() == 0) return; if ($helps->count() == 0) return;

View File

@ -44,32 +44,13 @@ class AccountController extends Controller
$captcha = $service->getSettings('captcha'); $captcha = $service->getSettings('captcha');
$this->seo->prependTitle('注册'); $this->seo->prependTitle('用户注册');
$this->view->setVar('return_url', $returnUrl); $this->view->setVar('return_url', $returnUrl);
$this->view->setVar('local_oauth', $oauthProvider['local']); $this->view->setVar('local_oauth', $oauthProvider['local']);
$this->view->setVar('captcha', $captcha); $this->view->setVar('captcha', $captcha);
} }
/**
* @Post("/register", name="home.account.do_register")
*/
public function doRegisterAction()
{
$service = new AccountService();
$service->register();
$returnUrl = $this->request->getPost('return_url', 'string');
$content = [
'location' => $returnUrl ?: '/',
'msg' => '注册成功',
];
return $this->jsonSuccess($content);
}
/** /**
* @Get("/login", name="home.account.login") * @Get("/login", name="home.account.login")
*/ */
@ -96,13 +77,69 @@ class AccountController extends Controller
$returnUrl = $this->request->getHTTPReferer(); $returnUrl = $this->request->getHTTPReferer();
$this->seo->prependTitle('登录'); $this->seo->prependTitle('用户登录');
$this->view->setVar('oauth_provider', $oauthProvider); $this->view->setVar('oauth_provider', $oauthProvider);
$this->view->setVar('return_url', $returnUrl); $this->view->setVar('return_url', $returnUrl);
$this->view->setVar('captcha', $captcha); $this->view->setVar('captcha', $captcha);
} }
/**
* @Get("/logout", name="home.account.logout")
*/
public function logoutAction()
{
$service = new AccountService();
$service->logout();
return $this->response->redirect(['for' => 'home.index']);
}
/**
* @Get("/forget", name="home.account.forget")
*/
public function forgetAction()
{
$service = new FullH5UrlService();
if ($service->isMobileBrowser() && $service->h5Enabled()) {
$location = $service->getAccountForgetUrl();
return $this->response->redirect($location);
}
if ($this->authUser->id > 0) {
return $this->response->redirect(['for' => 'home.index']);
}
$service = new AccountService();
$captcha = $service->getSettings('captcha');
$this->seo->prependTitle('重置密码');
$this->view->setVar('captcha', $captcha);
}
/**
* @Post("/register", name="home.account.do_register")
*/
public function doRegisterAction()
{
$service = new AccountService();
$service->register();
$returnUrl = $this->request->getPost('return_url', 'string');
$content = [
'location' => $returnUrl ?: '/',
'msg' => '注册成功',
];
return $this->jsonSuccess($content);
}
/** /**
* @Post("/password/login", name="home.account.pwd_login") * @Post("/password/login", name="home.account.pwd_login")
*/ */
@ -135,44 +172,6 @@ class AccountController extends Controller
return $this->jsonSuccess(['location' => $location]); return $this->jsonSuccess(['location' => $location]);
} }
/**
* @Get("/logout", name="home.account.logout")
*/
public function logoutAction()
{
$service = new AccountService();
$service->logout();
return $this->response->redirect(['for' => 'home.index']);
}
/**
* @Get("/password/forget", name="home.account.forget_pwd")
*/
public function forgetPasswordAction()
{
$service = new FullH5UrlService();
if ($service->isMobileBrowser() && $service->h5Enabled()) {
$location = $service->getAccountForgetUrl();
return $this->response->redirect($location);
}
if ($this->authUser->id > 0) {
return $this->response->redirect(['for' => 'home.index']);
}
$service = new AccountService();
$captcha = $service->getSettings('captcha');
$this->seo->prependTitle('忘记密码');
$this->view->pick('account/forget_password');
$this->view->setVar('captcha', $captcha);
}
/** /**
* @Post("/password/reset", name="home.account.reset_pwd") * @Post("/password/reset", name="home.account.reset_pwd")
*/ */

View File

@ -47,6 +47,15 @@ class Account extends Service
{ {
$post = $this->request->getPost(); $post = $this->request->getPost();
/**
* 使用[account|phone|email]做账户名字段兼容
*/
if (isset($post['phone'])) {
$post['account'] = $post['phone'];
} elseif (isset($post['email'])) {
$post['account'] = $post['email'];
}
$validator = new AccountValidator(); $validator = new AccountValidator();
$user = $validator->checkUserLogin($post['account'], $post['password']); $user = $validator->checkUserLogin($post['account'], $post['password']);
@ -74,6 +83,15 @@ class Account extends Service
{ {
$post = $this->request->getPost(); $post = $this->request->getPost();
/**
* 使用[account|phone|email]做账户名字段兼容
*/
if (isset($post['phone'])) {
$post['account'] = $post['phone'];
} elseif (isset($post['email'])) {
$post['account'] = $post['email'];
}
$validator = new AccountValidator(); $validator = new AccountValidator();
$user = $validator->checkVerifyLogin($post['account'], $post['verify_code']); $user = $validator->checkVerifyLogin($post['account'], $post['verify_code']);

View File

@ -0,0 +1,42 @@
{% extends 'templates/main.volt' %}
{% block content %}
{% set action_url = url({'for':'home.account.reset_pwd'}) %}
<div class="layui-breadcrumb breadcrumb">
<a href="/">首页</a>
<a><cite>重置密码</cite></a>
</div>
<div class="login-wrap wrap">
<div class="layui-tab layui-tab-brief login-tab">
<ul class="layui-tab-title login-tab-title">
<li class="layui-this">手机方式</li>
<li>邮箱方式</li>
</ul>
<div class="layui-tab-content">
<div class="layui-tab-item layui-show">
{{ partial('account/forget_by_phone') }}
</div>
<div class="layui-tab-item">
{{ partial('account/forget_by_email') }}
</div>
</div>
</div>
<div class="link">
<a class="login-link" href="{{ url({'for':'home.account.login'}) }}">用户登录</a>
<span class="separator">·</span>
<a class="forget-link" href="{{ url({'for':'home.account.register'}) }}">用户注册</a>
</div>
</div>
{% endblock %}
{% block include_js %}
{{ js_include('https://ssl.captcha.qq.com/TCaptcha.js',false) }}
{{ js_include('home/js/captcha.verify.phone.js') }}
{{ js_include('home/js/captcha.verify.email.js') }}
{% endblock %}

View File

@ -0,0 +1,28 @@
<form class="layui-form account-form" method="POST" action="{{ action_url }}">
<div class="layui-form-item">
<label class="layui-icon layui-icon-email"></label>
<input id="cv-email" class="layui-input" type="text" name="email" autocomplete="off" placeholder="邮箱" lay-verify="email">
</div>
<div class="layui-form-item">
<label class="layui-icon layui-icon-password"></label>
<input class="layui-input" type="password" name="new_password" autocomplete="off" placeholder="新密码字母数字特殊字符6-16位" lay-verify="required">
</div>
<div class="layui-form-item">
<div class="layui-input-inline verify-input-inline">
<label class="layui-icon layui-icon-vercode"></label>
<input class="layui-input" type="text" name="verify_code" autocomplete="off" placeholder="验证码" lay-verify="required">
</div>
<div class="layui-input-inline verify-btn-inline">
<button id="cv-email-emit-btn" class="layui-btn layui-btn-disabled" type="button" disabled="disabled">获取验证码</button>
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-block">
<button id="cv-email-submit-btn" class="layui-btn layui-btn-fluid layui-btn-disabled" disabled="disabled" lay-submit="true" lay-filter="go">重置密码</button>
<input id="cv-email-captcha-enabled" type="hidden" value="{{ captcha.enabled }}">
<input id="cv-email-captcha-appId" type="hidden" value="{{ captcha.app_id }}">
<input id="cv-email-captcha-ticket" type="hidden" name="captcha[ticket]">
<input id="cv-email-captcha-rand" type="hidden" name="captcha[rand]">
</div>
</div>
</form>

View File

@ -0,0 +1,28 @@
<form class="layui-form account-form" method="POST" action="{{ action_url }}">
<div class="layui-form-item">
<label class="layui-icon layui-icon-cellphone"></label>
<input id="cv-phone" class="layui-input" type="text" name="phone" autocomplete="off" placeholder="手机" lay-verify="phone">
</div>
<div class="layui-form-item">
<label class="layui-icon layui-icon-password"></label>
<input class="layui-input" type="password" name="new_password" autocomplete="off" placeholder="新密码字母数字特殊字符6-16位" lay-verify="required">
</div>
<div class="layui-form-item">
<div class="layui-input-inline verify-input-inline">
<label class="layui-icon layui-icon-vercode"></label>
<input class="layui-input" type="text" name="verify_code" autocomplete="off" placeholder="验证码" lay-verify="required">
</div>
<div class="layui-input-inline verify-btn-inline">
<button id="cv-phone-emit-btn" class="layui-btn layui-btn-disabled" type="button" disabled="disabled">获取验证码</button>
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-block">
<button id="cv-phone-submit-btn" class="layui-btn layui-btn-fluid layui-btn-disabled" disabled="disabled" lay-submit="true" lay-filter="go">重置密码</button>
<input id="cv-phone-captcha-enabled" type="hidden" value="{{ captcha.enabled }}">
<input id="cv-phone-captcha-appId" type="hidden" value="{{ captcha.app_id }}">
<input id="cv-phone-captcha-ticket" type="hidden" name="captcha[ticket]">
<input id="cv-phone-captcha-rand" type="hidden" name="captcha[rand]">
</div>
</div>
</form>

View File

@ -1,48 +0,0 @@
{% extends 'templates/main.volt' %}
{% block content %}
<div class="layui-breadcrumb breadcrumb">
<a href="/">首页</a>
<a><cite>忘记密码</cite></a>
</div>
<div class="account-wrap wrap">
<form class="layui-form account-form" method="POST" action="{{ url({'for':'home.account.reset_pwd'}) }}">
<div class="layui-form-item">
<label class="layui-icon layui-icon-username"></label>
<input id="cv-account" class="layui-input" type="text" name="account" autocomplete="off" placeholder="手机 / 邮箱" lay-verify="required">
</div>
<div class="layui-form-item">
<label class="layui-icon layui-icon-password"></label>
<input class="layui-input" type="password" name="new_password" autocomplete="off" placeholder="新密码字母数字特殊字符6-16位" lay-verify="required">
</div>
<div class="layui-form-item">
<div class="layui-input-inline verify-input-inline">
<label class="layui-icon layui-icon-vercode"></label>
<input class="layui-input" type="text" name="verify_code" autocomplete="off" placeholder="验证码" lay-verify="required">
</div>
<div class="layui-input-inline verify-btn-inline">
<button id="cv-emit-btn" class="layui-btn layui-btn-disabled" type="button" disabled="disabled">获取验证码</button>
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-block">
<button id="cv-submit-btn" class="layui-btn layui-btn-fluid layui-btn-disabled" disabled="disabled" lay-submit="true" lay-filter="go">重置密码</button>
<input id="cv-captcha-enabled" type="hidden" value="{{ captcha.enabled }}">
<input id="cv-captcha-appId" type="hidden" value="{{ captcha.app_id }}">
<input id="cv-captcha-ticket" type="hidden" name="captcha[ticket]">
<input id="cv-captcha-rand" type="hidden" name="captcha[rand]">
</div>
</div>
</form>
</div>
{% endblock %}
{% block include_js %}
{{ js_include('https://ssl.captcha.qq.com/TCaptcha.js',false) }}
{{ js_include('home/js/captcha.verify.js') }}
{% endblock %}

View File

@ -4,7 +4,7 @@
<div class="layui-breadcrumb breadcrumb"> <div class="layui-breadcrumb breadcrumb">
<a href="/">首页</a> <a href="/">首页</a>
<a><cite>登录</cite></a> <a><cite>用户登录</cite></a>
</div> </div>
<div class="login-wrap wrap"> <div class="login-wrap wrap">
@ -23,9 +23,9 @@
</div> </div>
</div> </div>
<div class="link"> <div class="link">
<a class="login-link" href="{{ url({'for':'home.account.register'}) }}">免费注册</a> <a class="login-link" href="{{ url({'for':'home.account.register'}) }}">用户注册</a>
<span class="separator">·</span> <span class="separator">·</span>
<a class="forget-link" href="{{ url({'for':'home.account.forget_pwd'}) }}">忘记密码</a> <a class="forget-link" href="{{ url({'for':'home.account.forget'}) }}">忘记密码</a>
</div> </div>
<div class="oauth"> <div class="oauth">
{% if oauth_provider.qq.enabled == 1 %} {% if oauth_provider.qq.enabled == 1 %}

View File

@ -4,54 +4,33 @@
{% set register_with_phone = local_oauth.register_with_phone == 1 %} {% set register_with_phone = local_oauth.register_with_phone == 1 %}
{% set register_with_email = local_oauth.register_with_email == 1 %} {% set register_with_email = local_oauth.register_with_email == 1 %}
{% set action_url = url({'for':'home.account.do_register'}) %}
<div class="layui-breadcrumb breadcrumb"> <div class="layui-breadcrumb breadcrumb">
<a href="/">首页</a> <a href="/">首页</a>
<a><cite>注册</cite></a> <a><cite>用户注册</cite></a>
</div> </div>
<div class="account-wrap wrap"> <div class="login-wrap wrap">
<form class="layui-form account-form" method="POST" action="{{ url({'for':'home.account.do_register'}) }}"> <div class="layui-tab layui-tab-brief login-tab">
{% if register_with_phone and register_with_email %} <ul class="layui-tab-title login-tab-title">
<div class="layui-form-item"> <li class="layui-this">手机注册</li>
<label class="layui-icon layui-icon-username"></label> <li>邮箱注册</li>
<input id="cv-account" class="layui-input" type="text" name="account" autocomplete="off" placeholder="手机 / 邮箱" lay-verify="required"> </ul>
<div class="layui-tab-content">
<div class="layui-tab-item layui-show">
{{ partial('account/register_by_phone') }}
</div> </div>
{% elseif register_with_email %} <div class="layui-tab-item">
<div class="layui-form-item"> {{ partial('account/register_by_email') }}
<label class="layui-icon layui-icon-email"></label>
<input id="cv-account" class="layui-input" type="text" name="account" autocomplete="off" placeholder="邮箱" lay-verify="email">
</div>
{% else %}
<div class="layui-form-item">
<label class="layui-icon layui-icon-cellphone"></label>
<input id="cv-account" class="layui-input" type="text" name="account" autocomplete="off" placeholder="手机" lay-verify="phone">
</div>
{% endif %}
<div class="layui-form-item">
<label class="layui-icon layui-icon-password"></label>
<input class="layui-input" type="password" name="password" autocomplete="off" placeholder="密码字母数字特殊字符6-16位" lay-verify="required">
</div>
<div class="layui-form-item">
<div class="layui-input-inline verify-input-inline">
<label class="layui-icon layui-icon-vercode"></label>
<input class="layui-input" type="text" name="verify_code" placeholder="验证码" lay-verify="required">
</div>
<div class="layui-input-inline verify-btn-inline">
<button id="cv-emit-btn" class="layui-btn layui-btn-disabled" type="button" disabled="disabled">获取验证码</button>
</div> </div>
</div> </div>
<div class="layui-form-item">
<div class="layui-input-block">
<button id="cv-submit-btn" class="layui-btn layui-btn-fluid layui-btn-disabled" disabled="disabled" lay-submit="true" lay-filter="go">注册帐号</button>
<input type="hidden" name="return_url" value="{{ return_url }}">
<input id="cv-captcha-enabled" type="hidden" value="{{ captcha.enabled }}">
<input id="cv-captcha-appId" type="hidden" value="{{ captcha.app_id }}">
<input id="cv-captcha-ticket" type="hidden" name="captcha[ticket]">
<input id="cv-captcha-rand" type="hidden" name="captcha[rand]">
</div> </div>
<div class="link">
<a class="login-link" href="{{ url({'for':'home.account.login'}) }}">用户登录</a>
<span class="separator">·</span>
<a class="forget-link" href="{{ url({'for':'home.account.forget'}) }}">忘记密码</a>
</div> </div>
</form>
</div> </div>
{% endblock %} {% endblock %}
@ -59,6 +38,7 @@
{% block include_js %} {% block include_js %}
{{ js_include('https://ssl.captcha.qq.com/TCaptcha.js',false) }} {{ js_include('https://ssl.captcha.qq.com/TCaptcha.js',false) }}
{{ js_include('home/js/captcha.verify.js') }} {{ js_include('home/js/captcha.verify.phone.js') }}
{{ js_include('home/js/captcha.verify.email.js') }}
{% endblock %} {% endblock %}

View File

@ -0,0 +1,35 @@
{% if register_with_email %}
<form class="layui-form account-form" method="POST" action="{{ action_url }}">
<div class="layui-form-item">
<label class="layui-icon layui-icon-email"></label>
<input id="cv-email" class="layui-input" type="text" name="email" autocomplete="off" placeholder="邮箱" lay-verify="email">
</div>
<div class="layui-form-item">
<label class="layui-icon layui-icon-password"></label>
<input class="layui-input" type="password" name="password" autocomplete="off" placeholder="密码字母数字特殊字符6-16位" lay-verify="required">
</div>
<div class="layui-form-item">
<div class="layui-input-inline verify-input-inline">
<label class="layui-icon layui-icon-vercode"></label>
<input class="layui-input" type="text" name="verify_code" placeholder="验证码" lay-verify="required">
</div>
<div class="layui-input-inline verify-btn-inline">
<button id="cv-email-emit-btn" class="layui-btn layui-btn-disabled" type="button" disabled="disabled">获取验证码</button>
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-block">
<button id="cv-email-submit-btn" class="layui-btn layui-btn-fluid layui-btn-disabled" disabled="disabled" lay-submit="true" lay-filter="go">注册帐号</button>
<input type="hidden" name="return_url" value="{{ return_url }}">
<input id="cv-email-captcha-enabled" type="hidden" value="{{ captcha.enabled }}">
<input id="cv-email-captcha-appId" type="hidden" value="{{ captcha.app_id }}">
<input id="cv-email-captcha-ticket" type="hidden" name="captcha[ticket]">
<input id="cv-email-captcha-rand" type="hidden" name="captcha[rand]">
</div>
</div>
</form>
{% else %}
<div class="register-close-tips">
<i class="layui-icon layui-icon-tips"></i> 邮箱注册已关闭
</div>
{% endif %}

View File

@ -0,0 +1,35 @@
{% if register_with_phone == 1 %}
<form class="layui-form account-form" method="POST" action="{{ action_url }}">
<div class="layui-form-item">
<label class="layui-icon layui-icon-cellphone"></label>
<input id="cv-phone" class="layui-input" type="text" name="phone" autocomplete="off" placeholder="手机" lay-verify="phone">
</div>
<div class="layui-form-item">
<label class="layui-icon layui-icon-password"></label>
<input class="layui-input" type="password" name="password" autocomplete="off" placeholder="密码字母数字特殊字符6-16位" lay-verify="required">
</div>
<div class="layui-form-item">
<div class="layui-input-inline verify-input-inline">
<label class="layui-icon layui-icon-vercode"></label>
<input class="layui-input" type="text" name="verify_code" placeholder="验证码" lay-verify="required">
</div>
<div class="layui-input-inline verify-btn-inline">
<button id="cv-phone-emit-btn" class="layui-btn layui-btn-disabled" type="button" disabled="disabled">获取验证码</button>
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-block">
<button id="cv-phone-submit-btn" class="layui-btn layui-btn-fluid layui-btn-disabled" disabled="disabled" lay-submit="true" lay-filter="go">注册帐号</button>
<input type="hidden" name="return_url" value="{{ return_url }}">
<input id="cv-phone-captcha-enabled" type="hidden" value="{{ captcha.enabled }}">
<input id="cv-phone-captcha-appId" type="hidden" value="{{ captcha.app_id }}">
<input id="cv-phone-captcha-ticket" type="hidden" name="captcha[ticket]">
<input id="cv-phone-captcha-rand" type="hidden" name="captcha[rand]">
</div>
</div>
</form>
{% else %}
<div class="register-close-tips">
<i class="layui-icon layui-icon-tips"></i> 手机注册已关闭
</div>
{% endif %}

View File

@ -19,7 +19,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 id="cv-account" class="layui-input" type="text" name="email" data-type="email" lay-verify="required"> <input id="cv-email" class="layui-input" type="text" name="email" lay-verify="required">
</div> </div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
@ -28,16 +28,16 @@
<input class="layui-input" type="text" name="verify_code" lay-verify="required"> <input class="layui-input" type="text" name="verify_code" lay-verify="required">
</div> </div>
<div class="layui-input-inline verify-btn-inline"> <div class="layui-input-inline verify-btn-inline">
<button id="cv-emit-btn" class="layui-btn layui-btn-disabled" type="button" disabled="disabled">获取验证码</button> <button id="cv-email-emit-btn" class="layui-btn layui-btn-disabled" type="button" disabled="disabled">获取验证码</button>
</div> </div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
<div class="layui-input-block"> <div class="layui-input-block">
<button id="cv-submit-btn" class="layui-btn layui-btn-fluid layui-btn-disabled" disabled="disabled" lay-submit="true" lay-filter="go">提交修改</button> <button id="cv-email-submit-btn" class="layui-btn layui-btn-fluid layui-btn-disabled" disabled="disabled" lay-submit="true" lay-filter="go">提交修改</button>
<input id="cv-captcha-enabled" type="hidden" value="{{ captcha.enabled }}"> <input id="cv-email-captcha-enabled" type="hidden" value="{{ captcha.enabled }}">
<input id="cv-captcha-appId" type="hidden" value="{{ captcha.app_id }}"> <input id="cv-email-captcha-appId" type="hidden" value="{{ captcha.app_id }}">
<input id="cv-captcha-ticket" type="hidden" name="captcha[ticket]"> <input id="cv-email-captcha-ticket" type="hidden" name="captcha[ticket]">
<input id="cv-captcha-rand" type="hidden" name="captcha[rand]"> <input id="cv-email-captcha-rand" type="hidden" name="captcha[rand]">
</div> </div>
</div> </div>
</form> </form>
@ -50,6 +50,6 @@
{% block include_js %} {% block include_js %}
{{ js_include('https://ssl.captcha.qq.com/TCaptcha.js',false) }} {{ js_include('https://ssl.captcha.qq.com/TCaptcha.js',false) }}
{{ js_include('home/js/captcha.verify.js') }} {{ js_include('home/js/captcha.verify.email.js') }}
{% endblock %} {% endblock %}

View File

@ -19,7 +19,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 id="cv-account" class="layui-input" type="text" name="phone" data-type="phone" lay-verify="required"> <input id="cv-phone" class="layui-input" type="text" name="phone" lay-verify="required">
</div> </div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
@ -28,16 +28,16 @@
<input class="layui-input" type="text" name="verify_code" lay-verify="required"> <input class="layui-input" type="text" name="verify_code" lay-verify="required">
</div> </div>
<div class="layui-input-inline verify-btn-inline"> <div class="layui-input-inline verify-btn-inline">
<button id="cv-emit-btn" class="layui-btn layui-btn-disabled" type="button" disabled="disabled">获取验证码</button> <button id="cv-phone-emit-btn" class="layui-btn layui-btn-disabled" type="button" disabled="disabled">获取验证码</button>
</div> </div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
<div class="layui-input-block"> <div class="layui-input-block">
<button id="cv-submit-btn" class="layui-btn layui-btn-fluid layui-btn-disabled" disabled="disabled" lay-submit="true" lay-filter="go">提交修改</button> <button id="cv-phone-submit-btn" class="layui-btn layui-btn-fluid layui-btn-disabled" disabled="disabled" lay-submit="true" lay-filter="go">提交修改</button>
<input id="cv-captcha-enabled" type="hidden" value="{{ captcha.enabled }}"> <input id="cv-phone-captcha-enabled" type="hidden" value="{{ captcha.enabled }}">
<input id="cv-captcha-appId" type="hidden" value="{{ captcha.app_id }}"> <input id="cv-phone-captcha-appId" type="hidden" value="{{ captcha.app_id }}">
<input id="cv-captcha-ticket" type="hidden" name="captcha[ticket]"> <input id="cv-phone-captcha-ticket" type="hidden" name="captcha[ticket]">
<input id="cv-captcha-rand" type="hidden" name="captcha[rand]"> <input id="cv-phone-captcha-rand" type="hidden" name="captcha[rand]">
</div> </div>
</div> </div>
</form> </form>
@ -50,6 +50,6 @@
{% block include_js %} {% block include_js %}
{{ js_include('https://ssl.captcha.qq.com/TCaptcha.js',false) }} {{ js_include('https://ssl.captcha.qq.com/TCaptcha.js',false) }}
{{ js_include('home/js/captcha.verify.js') }} {{ js_include('home/js/captcha.verify.phone.js') }}
{% endblock %} {% endblock %}

View File

@ -19,6 +19,15 @@ class PasswordReset extends LogicService
{ {
$post = $this->request->getPost(); $post = $this->request->getPost();
/**
* 使用[account|phone|email]做账户名字段兼容
*/
if (isset($post['phone'])) {
$post['account'] = $post['phone'];
} elseif (isset($post['email'])) {
$post['account'] = $post['email'];
}
$accountValidator = new AccountValidator(); $accountValidator = new AccountValidator();
$account = $accountValidator->checkAccount($post['account']); $account = $accountValidator->checkAccount($post['account']);

View File

@ -21,6 +21,15 @@ class Register extends LogicService
{ {
$post = $this->request->getPost(); $post = $this->request->getPost();
/**
* 使用[account|phone|email]做账户名字段兼容
*/
if (isset($post['phone'])) {
$post['account'] = $post['phone'];
} elseif (isset($post['email'])) {
$post['account'] = $post['email'];
}
$verifyValidator = new VerifyValidator(); $verifyValidator = new VerifyValidator();
$verifyValidator->checkCode($post['account'], $post['verify_code']); $verifyValidator->checkCode($post['account'], $post['verify_code']);

View File

@ -22,49 +22,37 @@ class IndexCourseCache extends AppService
public function rebuild($section = null) public function rebuild($section = null)
{ {
$site = $this->getSettings('site');
$type = $site['index_tpl_type'] ?: 'full';
if (!$section || $section == 'featured_course') { if (!$section || $section == 'featured_course') {
if ($type == 'full') {
$cache = new IndexFeaturedCourseListCache(); $cache = new IndexFeaturedCourseListCache();
$cache->rebuild(); $cache->rebuild();
} else {
$cache = new IndexSimpleFeaturedCourseListCache(); $cache = new IndexSimpleFeaturedCourseListCache();
$cache->rebuild(); $cache->rebuild();
} }
}
if (!$section || $section == 'new_course') { if (!$section || $section == 'new_course') {
if ($type == 'full') {
$cache = new IndexNewCourseListCache(); $cache = new IndexNewCourseListCache();
$cache->rebuild(); $cache->rebuild();
} else {
$cache = new IndexSimpleNewCourseListCache(); $cache = new IndexSimpleNewCourseListCache();
$cache->rebuild(); $cache->rebuild();
} }
}
if (!$section || $section == 'free_course') { if (!$section || $section == 'free_course') {
if ($type == 'full') {
$cache = new IndexFreeCourseListCache(); $cache = new IndexFreeCourseListCache();
$cache->rebuild(); $cache->rebuild();
} else {
$cache = new IndexSimpleFreeCourseListCache(); $cache = new IndexSimpleFreeCourseListCache();
$cache->rebuild(); $cache->rebuild();
} }
}
if (!$section || $section == 'vip_course') { if (!$section || $section == 'vip_course') {
if ($type == 'full') {
$cache = new IndexVipCourseListCache(); $cache = new IndexVipCourseListCache();
$cache->rebuild(); $cache->rebuild();
} else {
$cache = new IndexSimpleVipCourseListCache(); $cache = new IndexSimpleVipCourseListCache();
$cache->rebuild(); $cache->rebuild();
} }
} }
}
} }

View File

@ -479,8 +479,8 @@
.article-card .cover { .article-card .cover {
flex: 0 0 auto; flex: 0 0 auto;
width: 150px; width: 180px;
height: 84px; height: 100px;
margin-left: 10px; margin-left: 10px;
} }

View File

@ -0,0 +1,80 @@
layui.use(['jquery', 'layer', 'util', 'helper'], function () {
var $ = layui.jquery;
var layer = layui.layer;
var util = layui.util;
var helper = layui.helper;
var timeCounting = false;
var $account = $('#cv-email');
var $emit = $('#cv-email-emit-btn');
var $submit = $('#cv-email-submit-btn');
if ($('#cv-email-captcha-enabled').val() === '1') {
var captcha = new TencentCaptcha(
$emit[0],
$('#cv-email-captcha-appId').val(),
function (res) {
if (res.ret === 0) {
$('#cv-email-captcha-ticket').val(res.ticket);
$('#cv-email-captcha-rand').val(res.randstr);
sendVerifyCode();
}
}
);
} else {
$emit.on('click', function () {
sendVerifyCode();
});
}
$account.on('keyup', function () {
var account = $(this).val();
var accountOk = helper.isEmail(account);
if (accountOk && !timeCounting) {
$emit.removeClass('layui-btn-disabled').removeAttr('disabled');
} else {
$emit.addClass('layui-btn-disabled').attr('disabled', 'disabled');
}
});
function sendVerifyCode() {
if (helper.isEmail($account.val())) {
var postUrl = '/verify/mail/code';
var postData = {
email: $account.val(),
captcha: {
ticket: $('#cv-email-captcha-ticket').val(),
rand: $('#cv-email-captcha-rand').val(),
}
};
$.ajax({
type: 'POST',
url: postUrl,
data: postData,
success: function () {
layer.msg('发送验证码成功', {icon: 1});
}
});
$submit.removeClass('layui-btn-disabled').removeAttr('disabled');
$emit.addClass('layui-btn-disabled').attr('disabled', 'disabled');
showCountDown($emit);
}
}
function showCountDown() {
var serverTime = new Date().getTime();
var endTime = serverTime + 60 * 1000;
util.countdown(endTime, serverTime, function (date, serverTime, timer) {
var left = date[0] * 86400 + date[1] * 3600 + date[2] * 60 + date[3];
$emit.text(left + '秒');
if (left === 0) {
$emit.removeClass('layui-btn-disabled').removeAttr('disabled').text('重新发送');
clearInterval(timer);
timeCounting = false;
}
});
timeCounting = true;
}
});

View File

@ -1,8 +1,9 @@
layui.use(['jquery', 'layer', 'util'], function () { layui.use(['jquery', 'layer', 'util', 'helper'], function () {
var $ = layui.jquery; var $ = layui.jquery;
var layer = layui.layer; var layer = layui.layer;
var util = layui.util; var util = layui.util;
var helper = layui.helper;
var timeCounting = false; var timeCounting = false;
var $account = $('#cv-account'); var $account = $('#cv-account');
@ -28,16 +29,8 @@ layui.use(['jquery', 'layer', 'util'], function () {
} }
$account.on('keyup', function () { $account.on('keyup', function () {
var accountOk;
var type = $(this).data('type');
var account = $(this).val(); var account = $(this).val();
if (type === 'phone') { var accountOk = helper.isPhone(account) || helper.isEmail(account);
accountOk = isPhone(account);
} else if (type === 'email') {
accountOk = isEmail(account);
} else {
accountOk = isPhone(account) || isEmail(account);
}
if (accountOk && !timeCounting) { if (accountOk && !timeCounting) {
$emit.removeClass('layui-btn-disabled').removeAttr('disabled'); $emit.removeClass('layui-btn-disabled').removeAttr('disabled');
} else { } else {
@ -46,7 +39,7 @@ layui.use(['jquery', 'layer', 'util'], function () {
}); });
function sendVerifyCode() { function sendVerifyCode() {
if (isEmail($account.val()) || isPhone($account.val())) { if (helper.isEmail($account.val()) || helper.isPhone($account.val())) {
var postUrl; var postUrl;
var postData = { var postData = {
captcha: { captcha: {
@ -54,10 +47,10 @@ layui.use(['jquery', 'layer', 'util'], function () {
rand: $('#cv-captcha-rand').val(), rand: $('#cv-captcha-rand').val(),
} }
}; };
if (isPhone($account.val())) { if (helper.isPhone($account.val())) {
postData.phone = $account.val(); postData.phone = $account.val();
postUrl = '/verify/sms/code'; postUrl = '/verify/sms/code';
} else if (isEmail($account.val())) { } else if (helper.isEmail($account.val())) {
postData.email = $account.val(); postData.email = $account.val();
postUrl = '/verify/mail/code'; postUrl = '/verify/mail/code';
} }
@ -90,12 +83,4 @@ layui.use(['jquery', 'layer', 'util'], function () {
timeCounting = true; timeCounting = true;
} }
function isEmail(email) {
return /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/.test(email);
}
function isPhone(phone) {
return /^1(3|4|5|6|7|8|9)\d{9}$/.test(phone);
}
}); });

View File

@ -0,0 +1,80 @@
layui.use(['jquery', 'layer', 'util', 'helper'], function () {
var $ = layui.jquery;
var layer = layui.layer;
var util = layui.util;
var helper = layui.helper;
var timeCounting = false;
var $account = $('#cv-phone');
var $emit = $('#cv-phone-emit-btn');
var $submit = $('#cv-phone-submit-btn');
if ($('#cv-phone-captcha-enabled').val() === '1') {
var captcha = new TencentCaptcha(
$emit[0],
$('#cv-phone-captcha-appId').val(),
function (res) {
if (res.ret === 0) {
$('#cv-phone-captcha-ticket').val(res.ticket);
$('#cv-phone-captcha-rand').val(res.randstr);
sendVerifyCode();
}
}
);
} else {
$emit.on('click', function () {
sendVerifyCode();
});
}
$account.on('keyup', function () {
var account = $(this).val();
var accountOk = helper.isPhone(account);
if (accountOk && !timeCounting) {
$emit.removeClass('layui-btn-disabled').removeAttr('disabled');
} else {
$emit.addClass('layui-btn-disabled').attr('disabled', 'disabled');
}
});
function sendVerifyCode() {
if (helper.isPhone($account.val())) {
var postUrl = '/verify/sms/code';
var postData = {
phone: $account.val(),
captcha: {
ticket: $('#cv-phone-captcha-ticket').val(),
rand: $('#cv-phone-captcha-rand').val(),
}
};
$.ajax({
type: 'POST',
url: postUrl,
data: postData,
success: function () {
layer.msg('发送验证码成功', {icon: 1});
}
});
$submit.removeClass('layui-btn-disabled').removeAttr('disabled');
$emit.addClass('layui-btn-disabled').attr('disabled', 'disabled');
showCountDown($emit);
}
}
function showCountDown() {
var serverTime = new Date().getTime();
var endTime = serverTime + 60 * 1000;
util.countdown(endTime, serverTime, function (date, serverTime, timer) {
var left = date[0] * 86400 + date[1] * 3600 + date[2] * 60 + date[3];
$emit.text(left + '秒');
if (left === 0) {
$emit.removeClass('layui-btn-disabled').removeAttr('disabled').text('重新发送');
clearInterval(timer);
timeCounting = false;
}
});
timeCounting = true;
}
});

View File

@ -6,6 +6,14 @@ layui.define(['jquery', 'layer'], function (exports) {
var helper = {}; var helper = {};
helper.isEmail = function (email) {
return /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/.test(email);
};
helper.isPhone = function (phone) {
return /^1(3|4|5|6|7|8|9)\d{9}$/.test(phone);
};
helper.getRequestId = function () { helper.getRequestId = function () {
var id = Date.now().toString(36); var id = Date.now().toString(36);
id += Math.random().toString(36).substr(3); id += Math.random().toString(36).substr(3);