-
-
+
+
+
+
+
+ {{ partial('account/register_by_phone') }}
- {% elseif register_with_email %}
-
-
-
-
- {% else %}
-
-
-
-
- {% endif %}
-
-
-
-
-
+
{% endblock %}
@@ -59,6 +38,7 @@
{% block include_js %}
{{ 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 %}
diff --git a/app/Http/Home/Views/account/register_by_email.volt b/app/Http/Home/Views/account/register_by_email.volt
new file mode 100644
index 00000000..75471e99
--- /dev/null
+++ b/app/Http/Home/Views/account/register_by_email.volt
@@ -0,0 +1,35 @@
+{% if register_with_email %}
+
+{% else %}
+
+ 邮箱注册已关闭
+
+{% endif %}
\ No newline at end of file
diff --git a/app/Http/Home/Views/account/register_by_phone.volt b/app/Http/Home/Views/account/register_by_phone.volt
new file mode 100644
index 00000000..e08f494a
--- /dev/null
+++ b/app/Http/Home/Views/account/register_by_phone.volt
@@ -0,0 +1,35 @@
+{% if register_with_phone == 1 %}
+
+{% else %}
+
+ 手机注册已关闭
+
+{% endif %}
\ No newline at end of file
diff --git a/app/Http/Home/Views/user/console/account_email.volt b/app/Http/Home/Views/user/console/account_email.volt
index 0f549223..92835d5f 100644
--- a/app/Http/Home/Views/user/console/account_email.volt
+++ b/app/Http/Home/Views/user/console/account_email.volt
@@ -19,7 +19,7 @@
@@ -28,16 +28,16 @@
-
+
diff --git a/app/Http/Home/Views/user/console/account_phone.volt b/app/Http/Home/Views/user/console/account_phone.volt
index f2475cd2..be966aa2 100644
--- a/app/Http/Home/Views/user/console/account_phone.volt
+++ b/app/Http/Home/Views/user/console/account_phone.volt
@@ -19,7 +19,7 @@
@@ -28,16 +28,16 @@
-
+
diff --git a/app/Services/Logic/Account/PasswordReset.php b/app/Services/Logic/Account/PasswordReset.php
index 57f71008..cdc2e635 100644
--- a/app/Services/Logic/Account/PasswordReset.php
+++ b/app/Services/Logic/Account/PasswordReset.php
@@ -19,6 +19,15 @@ class PasswordReset extends LogicService
{
$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();
$account = $accountValidator->checkAccount($post['account']);
diff --git a/app/Services/Logic/Account/Register.php b/app/Services/Logic/Account/Register.php
index e2c36e02..449e7030 100644
--- a/app/Services/Logic/Account/Register.php
+++ b/app/Services/Logic/Account/Register.php
@@ -21,6 +21,15 @@ class Register extends LogicService
{
$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->checkCode($post['account'], $post['verify_code']);
diff --git a/app/Services/Utils/IndexCourseCache.php b/app/Services/Utils/IndexCourseCache.php
index d34ffc15..7b56a4be 100644
--- a/app/Services/Utils/IndexCourseCache.php
+++ b/app/Services/Utils/IndexCourseCache.php
@@ -22,48 +22,36 @@ class IndexCourseCache extends AppService
public function rebuild($section = null)
{
- $site = $this->getSettings('site');
-
- $type = $site['index_tpl_type'] ?: 'full';
-
if (!$section || $section == 'featured_course') {
- if ($type == 'full') {
- $cache = new IndexFeaturedCourseListCache();
- $cache->rebuild();
- } else {
- $cache = new IndexSimpleFeaturedCourseListCache();
- $cache->rebuild();
- }
+ $cache = new IndexFeaturedCourseListCache();
+ $cache->rebuild();
+
+ $cache = new IndexSimpleFeaturedCourseListCache();
+ $cache->rebuild();
}
if (!$section || $section == 'new_course') {
- if ($type == 'full') {
- $cache = new IndexNewCourseListCache();
- $cache->rebuild();
- } else {
- $cache = new IndexSimpleNewCourseListCache();
- $cache->rebuild();
- }
+ $cache = new IndexNewCourseListCache();
+ $cache->rebuild();
+
+ $cache = new IndexSimpleNewCourseListCache();
+ $cache->rebuild();
}
if (!$section || $section == 'free_course') {
- if ($type == 'full') {
- $cache = new IndexFreeCourseListCache();
- $cache->rebuild();
- } else {
- $cache = new IndexSimpleFreeCourseListCache();
- $cache->rebuild();
- }
+ $cache = new IndexFreeCourseListCache();
+ $cache->rebuild();
+
+ $cache = new IndexSimpleFreeCourseListCache();
+ $cache->rebuild();
}
if (!$section || $section == 'vip_course') {
- if ($type == 'full') {
- $cache = new IndexVipCourseListCache();
- $cache->rebuild();
- } else {
- $cache = new IndexSimpleVipCourseListCache();
- $cache->rebuild();
- }
+ $cache = new IndexVipCourseListCache();
+ $cache->rebuild();
+
+ $cache = new IndexSimpleVipCourseListCache();
+ $cache->rebuild();
}
}
diff --git a/db/migrations/20210324064239.php b/db/migrations/20210324064239.php
index b5eaafd4..3c170df3 100644
--- a/db/migrations/20210324064239.php
+++ b/db/migrations/20210324064239.php
@@ -3268,619 +3268,6 @@ final class V20210324064239 extends AbstractMigration
'after' => 'create_time',
])
->create();
- $this->table('kg_im_friend_group', [
- 'id' => false,
- 'primary_key' => ['id'],
- 'engine' => 'InnoDB',
- 'encoding' => 'utf8mb4',
- 'collation' => 'utf8mb4_general_ci',
- 'comment' => '',
- 'row_format' => 'DYNAMIC',
- ])
- ->addColumn('id', 'integer', [
- 'null' => false,
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'identity' => 'enable',
- 'comment' => '主键编号',
- ])
- ->addColumn('user_id', 'integer', [
- 'null' => false,
- 'default' => '0',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'comment' => '用户编号',
- 'after' => 'id',
- ])
- ->addColumn('name', 'string', [
- 'null' => false,
- 'default' => '',
- 'limit' => 100,
- 'collation' => 'utf8mb4_general_ci',
- 'encoding' => 'utf8mb4',
- 'comment' => '名称',
- 'after' => 'user_id',
- ])
- ->addColumn('priority', 'integer', [
- 'null' => false,
- 'default' => '0',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'comment' => '优先级',
- 'after' => 'name',
- ])
- ->addColumn('deleted', 'integer', [
- 'null' => false,
- 'default' => '0',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'comment' => '删除标识',
- 'after' => 'priority',
- ])
- ->addColumn('user_count', 'integer', [
- 'null' => false,
- 'default' => '0',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'comment' => '成员数',
- 'after' => 'deleted',
- ])
- ->addColumn('create_time', 'integer', [
- 'null' => false,
- 'default' => '0',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'comment' => '创建时间',
- 'after' => 'user_count',
- ])
- ->addColumn('update_time', 'integer', [
- 'null' => false,
- 'default' => '0',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'comment' => '更新时间',
- 'after' => 'create_time',
- ])
- ->addIndex(['user_id'], [
- 'name' => 'user_id',
- 'unique' => true,
- ])
- ->create();
- $this->table('kg_im_friend_user', [
- 'id' => false,
- 'primary_key' => ['id'],
- 'engine' => 'InnoDB',
- 'encoding' => 'utf8mb4',
- 'collation' => 'utf8mb4_general_ci',
- 'comment' => '',
- 'row_format' => 'DYNAMIC',
- ])
- ->addColumn('id', 'integer', [
- 'null' => false,
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'identity' => 'enable',
- 'comment' => '主键编号',
- ])
- ->addColumn('user_id', 'integer', [
- 'null' => false,
- 'default' => '0',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'comment' => '用户编号',
- 'after' => 'id',
- ])
- ->addColumn('friend_id', 'integer', [
- 'null' => false,
- 'default' => '0',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'comment' => '目标编号',
- 'after' => 'user_id',
- ])
- ->addColumn('group_id', 'integer', [
- 'null' => false,
- 'default' => '0',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'comment' => '分组编号',
- 'after' => 'friend_id',
- ])
- ->addColumn('msg_count', 'integer', [
- 'null' => false,
- 'default' => '0',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'comment' => '消息数',
- 'after' => 'group_id',
- ])
- ->addColumn('create_time', 'integer', [
- 'null' => false,
- 'default' => '0',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'comment' => '创建时间',
- 'after' => 'msg_count',
- ])
- ->addColumn('update_time', 'integer', [
- 'null' => false,
- 'default' => '0',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'comment' => '更新时间',
- 'after' => 'create_time',
- ])
- ->addIndex(['user_id', 'friend_id'], [
- 'name' => 'user_friend',
- 'unique' => false,
- ])
- ->create();
- $this->table('kg_im_group', [
- 'id' => false,
- 'primary_key' => ['id'],
- 'engine' => 'InnoDB',
- 'encoding' => 'utf8mb4',
- 'collation' => 'utf8mb4_general_ci',
- 'comment' => '',
- 'row_format' => 'DYNAMIC',
- ])
- ->addColumn('id', 'integer', [
- 'null' => false,
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'identity' => 'enable',
- 'comment' => '主键编号',
- ])
- ->addColumn('owner_id', 'integer', [
- 'null' => false,
- 'default' => '0',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'comment' => '群主编号',
- 'after' => 'id',
- ])
- ->addColumn('course_id', 'integer', [
- 'null' => false,
- 'default' => '0',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'comment' => '课程编号',
- 'after' => 'owner_id',
- ])
- ->addColumn('type', 'integer', [
- 'null' => false,
- 'default' => '1',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'comment' => '类型',
- 'after' => 'course_id',
- ])
- ->addColumn('name', 'string', [
- 'null' => false,
- 'default' => '',
- 'limit' => 100,
- 'collation' => 'utf8mb4_general_ci',
- 'encoding' => 'utf8mb4',
- 'comment' => '名称',
- 'after' => 'type',
- ])
- ->addColumn('avatar', 'string', [
- 'null' => false,
- 'default' => '',
- 'limit' => 100,
- 'collation' => 'utf8mb4_general_ci',
- 'encoding' => 'utf8mb4',
- 'comment' => '头像',
- 'after' => 'name',
- ])
- ->addColumn('about', 'string', [
- 'null' => false,
- 'default' => '',
- 'limit' => 255,
- 'collation' => 'utf8mb4_general_ci',
- 'encoding' => 'utf8mb4',
- 'comment' => '简介',
- 'after' => 'avatar',
- ])
- ->addColumn('published', 'integer', [
- 'null' => false,
- 'default' => '0',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'comment' => '发布标识',
- 'after' => 'about',
- ])
- ->addColumn('deleted', 'integer', [
- 'null' => false,
- 'default' => '0',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'comment' => '删除标识',
- 'after' => 'published',
- ])
- ->addColumn('user_count', 'integer', [
- 'null' => false,
- 'default' => '0',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'comment' => '成员数',
- 'after' => 'deleted',
- ])
- ->addColumn('msg_count', 'integer', [
- 'null' => false,
- 'default' => '0',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'comment' => '消息数',
- 'after' => 'user_count',
- ])
- ->addColumn('create_time', 'integer', [
- 'null' => false,
- 'default' => '0',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'comment' => '创建时间',
- 'after' => 'msg_count',
- ])
- ->addColumn('update_time', 'integer', [
- 'null' => false,
- 'default' => '0',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'comment' => '更新时间',
- 'after' => 'create_time',
- ])
- ->create();
- $this->table('kg_im_group_user', [
- 'id' => false,
- 'primary_key' => ['id'],
- 'engine' => 'InnoDB',
- 'encoding' => 'utf8mb4',
- 'collation' => 'utf8mb4_general_ci',
- 'comment' => '',
- 'row_format' => 'DYNAMIC',
- ])
- ->addColumn('id', 'integer', [
- 'null' => false,
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'identity' => 'enable',
- 'comment' => '主键编号',
- ])
- ->addColumn('group_id', 'integer', [
- 'null' => false,
- 'default' => '0',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'comment' => '群组编号',
- 'after' => 'id',
- ])
- ->addColumn('user_id', 'integer', [
- 'null' => false,
- 'default' => '0',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'comment' => '用户编号',
- 'after' => 'group_id',
- ])
- ->addColumn('priority', 'integer', [
- 'null' => false,
- 'default' => '0',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'comment' => '优先级',
- 'after' => 'user_id',
- ])
- ->addColumn('create_time', 'integer', [
- 'null' => false,
- 'default' => '0',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'comment' => '创建时间',
- 'after' => 'priority',
- ])
- ->addColumn('update_time', 'integer', [
- 'null' => false,
- 'default' => '0',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'comment' => '更新时间',
- 'after' => 'create_time',
- ])
- ->addIndex(['group_id'], [
- 'name' => 'group_id',
- 'unique' => false,
- ])
- ->addIndex(['group_id', 'user_id'], [
- 'name' => 'group_user',
- 'unique' => false,
- ])
- ->addIndex(['user_id'], [
- 'name' => 'user_id',
- 'unique' => false,
- ])
- ->create();
- $this->table('kg_im_message', [
- 'id' => false,
- 'primary_key' => ['id'],
- 'engine' => 'InnoDB',
- 'encoding' => 'utf8mb4',
- 'collation' => 'utf8mb4_general_ci',
- 'comment' => '',
- 'row_format' => 'DYNAMIC',
- ])
- ->addColumn('id', 'integer', [
- 'null' => false,
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'identity' => 'enable',
- 'comment' => '主键编号',
- ])
- ->addColumn('chat_id', 'string', [
- 'null' => false,
- 'default' => '',
- 'limit' => 30,
- 'collation' => 'utf8mb4_general_ci',
- 'encoding' => 'utf8mb4',
- 'comment' => '对话编号',
- 'after' => 'id',
- ])
- ->addColumn('sender_id', 'integer', [
- 'null' => false,
- 'default' => '0',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'comment' => '发送方',
- 'after' => 'chat_id',
- ])
- ->addColumn('receiver_id', 'integer', [
- 'null' => false,
- 'default' => '0',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'comment' => '接收方',
- 'after' => 'sender_id',
- ])
- ->addColumn('receiver_type', 'integer', [
- 'null' => false,
- 'default' => '1',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'comment' => '接收方类型',
- 'after' => 'receiver_id',
- ])
- ->addColumn('content', 'string', [
- 'null' => false,
- 'default' => '',
- 'limit' => 3000,
- 'collation' => 'utf8mb4_general_ci',
- 'encoding' => 'utf8mb4',
- 'comment' => '内容',
- 'after' => 'receiver_type',
- ])
- ->addColumn('viewed', 'integer', [
- 'null' => false,
- 'default' => '0',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'comment' => '已读标识',
- 'after' => 'content',
- ])
- ->addColumn('deleted', 'integer', [
- 'null' => false,
- 'default' => '0',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'comment' => '删除标识',
- 'after' => 'viewed',
- ])
- ->addColumn('create_time', 'integer', [
- 'null' => false,
- 'default' => '0',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'comment' => '创建时间',
- 'after' => 'deleted',
- ])
- ->addColumn('update_time', 'integer', [
- 'null' => false,
- 'default' => '0',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'comment' => '更新时间',
- 'after' => 'create_time',
- ])
- ->addIndex(['chat_id'], [
- 'name' => 'chat_id',
- 'unique' => false,
- ])
- ->addIndex(['receiver_id', 'receiver_type'], [
- 'name' => 'receiver',
- 'unique' => false,
- ])
- ->create();
- $this->table('kg_im_notice', [
- 'id' => false,
- 'primary_key' => ['id'],
- 'engine' => 'InnoDB',
- 'encoding' => 'utf8mb4',
- 'collation' => 'utf8mb4_general_ci',
- 'comment' => '',
- 'row_format' => 'DYNAMIC',
- ])
- ->addColumn('id', 'integer', [
- 'null' => false,
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'identity' => 'enable',
- 'comment' => '主键编号',
- ])
- ->addColumn('sender_id', 'integer', [
- 'null' => false,
- 'default' => '0',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'comment' => '发送方',
- 'after' => 'id',
- ])
- ->addColumn('receiver_id', 'integer', [
- 'null' => false,
- 'default' => '0',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'comment' => '接收方',
- 'after' => 'sender_id',
- ])
- ->addColumn('item_type', 'integer', [
- 'null' => false,
- 'default' => '0',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'comment' => '条目类型',
- 'after' => 'receiver_id',
- ])
- ->addColumn('item_info', 'string', [
- 'null' => false,
- 'default' => '',
- 'limit' => 1500,
- 'collation' => 'utf8mb4_general_ci',
- 'encoding' => 'utf8mb4',
- 'comment' => '条目内容',
- 'after' => 'item_type',
- ])
- ->addColumn('viewed', 'integer', [
- 'null' => false,
- 'default' => '0',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'comment' => '已读标识',
- 'after' => 'item_info',
- ])
- ->addColumn('create_time', 'integer', [
- 'null' => false,
- 'default' => '0',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'comment' => '创建时间',
- 'after' => 'viewed',
- ])
- ->addColumn('update_time', 'integer', [
- 'null' => false,
- 'default' => '0',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'comment' => '更新时间',
- 'after' => 'create_time',
- ])
- ->addIndex(['receiver_id'], [
- 'name' => 'receiver_id',
- 'unique' => false,
- ])
- ->addIndex(['sender_id'], [
- 'name' => 'sender_id',
- 'unique' => false,
- ])
- ->create();
- $this->table('kg_im_user', [
- 'id' => false,
- 'primary_key' => ['id'],
- 'engine' => 'InnoDB',
- 'encoding' => 'utf8mb4',
- 'collation' => 'utf8mb4_general_ci',
- 'comment' => '',
- 'row_format' => 'DYNAMIC',
- ])
- ->addColumn('id', 'integer', [
- 'null' => false,
- 'default' => '0',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'comment' => '主键编号',
- ])
- ->addColumn('name', 'string', [
- 'null' => false,
- 'default' => '',
- 'limit' => 30,
- 'collation' => 'utf8mb4_general_ci',
- 'encoding' => 'utf8mb4',
- 'comment' => '名称',
- 'after' => 'id',
- ])
- ->addColumn('avatar', 'string', [
- 'null' => false,
- 'default' => '',
- 'limit' => 100,
- 'collation' => 'utf8mb4_general_ci',
- 'encoding' => 'utf8mb4',
- 'comment' => '头像',
- 'after' => 'name',
- ])
- ->addColumn('sign', 'string', [
- 'null' => false,
- 'default' => '',
- 'limit' => 30,
- 'collation' => 'utf8mb4_general_ci',
- 'encoding' => 'utf8mb4',
- 'comment' => '签名',
- 'after' => 'avatar',
- ])
- ->addColumn('skin', 'string', [
- 'null' => false,
- 'default' => '',
- 'limit' => 100,
- 'collation' => 'utf8mb4_general_ci',
- 'encoding' => 'utf8mb4',
- 'comment' => '皮肤',
- 'after' => 'sign',
- ])
- ->addColumn('status', 'string', [
- 'null' => false,
- 'default' => 'hide',
- 'limit' => 15,
- 'collation' => 'utf8mb4_general_ci',
- 'encoding' => 'utf8mb4',
- 'comment' => '在线状态',
- 'after' => 'skin',
- ])
- ->addColumn('deleted', 'integer', [
- 'null' => false,
- 'default' => '0',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'comment' => '删除标识',
- 'after' => 'status',
- ])
- ->addColumn('friend_count', 'integer', [
- 'null' => false,
- 'default' => '0',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'comment' => '好友数',
- 'after' => 'deleted',
- ])
- ->addColumn('group_count', 'integer', [
- 'null' => false,
- 'default' => '0',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'comment' => '群组数',
- 'after' => 'friend_count',
- ])
- ->addColumn('create_time', 'integer', [
- 'null' => false,
- 'default' => '0',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'comment' => '创建时间',
- 'after' => 'group_count',
- ])
- ->addColumn('update_time', 'integer', [
- 'null' => false,
- 'default' => '0',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'comment' => '更新时间',
- 'after' => 'create_time',
- ])
- ->create();
$this->table('kg_learning', [
'id' => false,
'primary_key' => ['id'],
diff --git a/db/migrations/20210403184518.php b/db/migrations/20210403184518.php
index 85189d44..5c3aa05a 100644
--- a/db/migrations/20210403184518.php
+++ b/db/migrations/20210403184518.php
@@ -46,15 +46,6 @@ final class V20210403184518 extends AbstractMigration
];
$this->table('kg_user')->insert($user)->saveData();
-
- $imUser = [
- 'id' => $user['id'],
- 'name' => $user['name'],
- 'avatar' => $user['avatar'],
- 'create_time' => $now,
- ];
-
- $this->table('kg_im_user')->insert($imUser)->saveData();
}
protected function initRoleData()
@@ -949,7 +940,6 @@ final class V20210403184518 extends AbstractMigration
'course_review' => ['enabled' => 1, 'point' => 50],
'chapter_study' => ['enabled' => 1, 'point' => 10],
'site_visit' => ['enabled' => 1, 'point' => 10],
- 'im_discuss' => ['enabled' => 1, 'point' => 10],
'article_post' => ['enabled' => 1, 'point' => 20, 'limit' => 50],
'question_post' => ['enabled' => 1, 'point' => 5, 'limit' => 50],
'answer_post' => ['enabled' => 1, 'point' => 5, 'limit' => 50],
diff --git a/db/migrations/20210720153027.php b/db/migrations/20210720153027.php
index 21e1f9d8..0a980597 100644
--- a/db/migrations/20210720153027.php
+++ b/db/migrations/20210720153027.php
@@ -27,7 +27,13 @@ final class V20210720153027 extends AbstractMigration
protected function createCourseTagTable()
{
- $this->table('kg_course_tag', [
+ $tableName = 'kg_course_tag';
+
+ if ($this->table($tableName)->exists()) {
+ return;
+ }
+
+ $this->table($tableName, [
'id' => false,
'primary_key' => ['id'],
'engine' => 'InnoDB',
@@ -80,8 +86,10 @@ final class V20210720153027 extends AbstractMigration
protected function alterCourseTable()
{
- $this->table('kg_course')
- ->addColumn('tags', 'string', [
+ $table = $this->table('kg_course');
+
+ if ($table->hasColumn('tags') == false) {
+ $table->addColumn('tags', 'string', [
'null' => false,
'default' => '',
'limit' => 255,
@@ -89,13 +97,18 @@ final class V20210720153027 extends AbstractMigration
'encoding' => 'utf8mb4',
'comment' => '标签',
'after' => 'summary',
- ])->save();
+ ]);
+ }
+
+ $table->save();
}
protected function alterCategoryTable()
{
- $this->table('kg_category')
- ->addColumn('alias', 'string', [
+ $table = $this->table('kg_category');
+
+ if ($table->hasColumn('alias') == false) {
+ $table->addColumn('alias', 'string', [
'null' => false,
'default' => '',
'limit' => 30,
@@ -103,7 +116,11 @@ final class V20210720153027 extends AbstractMigration
'encoding' => 'utf8mb4',
'comment' => '别名',
'after' => 'name',
- ])->addColumn('icon', 'string', [
+ ]);
+ }
+
+ if ($table->hasColumn('icon') == false) {
+ $table->addColumn('icon', 'string', [
'null' => false,
'default' => '',
'limit' => 100,
@@ -111,13 +128,19 @@ final class V20210720153027 extends AbstractMigration
'encoding' => 'utf8mb4',
'comment' => '图标',
'after' => 'name',
- ])->save();
+ ]);
+ }
+
+ $table->save();
}
protected function alterTagTable()
{
- $this->table('kg_tag')
- ->addColumn('scopes', 'string', [
+ $table = $this->table('kg_tag');
+
+ if ($table->hasColumn('scopes') == false) {
+
+ $table->addColumn('scopes', 'string', [
'null' => false,
'default' => '',
'limit' => 100,
@@ -125,32 +148,43 @@ final class V20210720153027 extends AbstractMigration
'encoding' => 'utf8mb4',
'comment' => '范围',
'after' => 'icon',
- ])
- ->addColumn('course_count', 'integer', [
+ ]);
+ }
+
+ if ($table->hasColumn('course_count') == false) {
+ $table->addColumn('course_count', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '课程数',
'after' => 'follow_count',
- ])
- ->addColumn('article_count', 'integer', [
+ ]);
+ }
+
+ if ($table->hasColumn('article_count') == false) {
+ $table->addColumn('article_count', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '文章数',
'after' => 'course_count',
- ])
- ->addColumn('question_count', 'integer', [
+ ]);
+ }
+
+ if ($table->hasColumn('question_count') == false) {
+ $table->addColumn('question_count', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '问题数',
'after' => 'article_count',
- ])
- ->save();
+ ]);
+ }
+
+ $table->save();
}
protected function handleCourseTags()
diff --git a/db/migrations/20210802021814.php b/db/migrations/20210802021814.php
index 51852a92..59f542dd 100644
--- a/db/migrations/20210802021814.php
+++ b/db/migrations/20210802021814.php
@@ -17,8 +17,10 @@ final class V20210802021814 extends AbstractMigration
protected function alterPageTable()
{
- $this->table('kg_page')
- ->addColumn('alias', 'string', [
+ $table = $this->table('kg_page');
+
+ if ($table->hasColumn('alias') == false) {
+ $table->addColumn('alias', 'string', [
'null' => false,
'default' => '',
'limit' => 50,
@@ -26,7 +28,10 @@ final class V20210802021814 extends AbstractMigration
'encoding' => 'utf8mb4',
'comment' => '别名',
'after' => 'title',
- ])->save();
+ ]);
+ }
+
+ $table->save();
}
}
diff --git a/db/migrations/20210809153030.php b/db/migrations/20210809153030.php
index a8d7ee89..bd94311b 100644
--- a/db/migrations/20210809153030.php
+++ b/db/migrations/20210809153030.php
@@ -5,19 +5,22 @@
* @link https://www.koogua.com
*/
+require_once 'SettingTrait.php';
+
use Phinx\Migration\AbstractMigration;
final class V20210809153030 extends AbstractMigration
{
+ use SettingTrait;
+
public function up()
{
- $this->handleVodSetting();
- $this->handleImSetting();
+ $this->handleVodSettings();
$this->handleRemotePlayUrl();
}
- protected function handleVodSetting()
+ protected function handleVodSettings()
{
$rows = [
[
@@ -32,18 +35,7 @@ final class V20210809153030 extends AbstractMigration
],
];
- $this->table('kg_setting')->insert($rows)->save();
- }
-
- protected function handleImSetting()
- {
- $row = [
- 'section' => 'im.main',
- 'item_key' => 'enabled',
- 'item_value' => '1',
- ];
-
- $this->table('kg_setting')->insert($row)->saveData();
+ $this->insertSettings($rows);
}
protected function handleRemotePlayUrl()
diff --git a/db/migrations/20210820064755.php b/db/migrations/20210820064755.php
index 657de33f..8c19c82b 100644
--- a/db/migrations/20210820064755.php
+++ b/db/migrations/20210820064755.php
@@ -5,17 +5,21 @@
* @link https://www.koogua.com
*/
+require_once 'SettingTrait.php';
+
use Phinx\Migration\AbstractMigration;
final class V20210820064755 extends AbstractMigration
{
+ use SettingTrait;
+
public function up()
{
- $this->handleContactSetting();
+ $this->handleContactSettings();
}
- protected function handleContactSetting()
+ protected function handleContactSettings()
{
$rows = [
[
@@ -65,7 +69,7 @@ final class V20210820064755 extends AbstractMigration
],
];
- $this->table('kg_setting')->insert($rows)->save();
+ $this->insertSettings($rows);
}
}
diff --git a/db/migrations/20210825111618.php b/db/migrations/20210825111618.php
index 5b337651..d3553457 100644
--- a/db/migrations/20210825111618.php
+++ b/db/migrations/20210825111618.php
@@ -19,9 +19,11 @@ final class V20210825111618 extends AbstractMigration
{
$table = $this->table('kg_upload');
- $table->removeIndexByName('md5')->save();
+ if ($table->hasIndexByName('md5')) {
+ $table->removeIndexByName('md5')->save();
+ $table->addIndex('md5')->save();
+ }
- $table->addIndex('md5')->save();
}
}
diff --git a/db/migrations/20210903040558.php b/db/migrations/20210903040558.php
index d998c32b..57f655b1 100644
--- a/db/migrations/20210903040558.php
+++ b/db/migrations/20210903040558.php
@@ -5,17 +5,21 @@
* @link https://www.koogua.com
*/
+require_once 'SettingTrait.php';
+
use Phinx\Migration\AbstractMigration;
final class V20210903040558 extends AbstractMigration
{
+ use SettingTrait;
+
public function up()
{
- $this->handleVodSetting();
+ $this->handleVodSettings();
}
- protected function handleVodSetting()
+ protected function handleVodSettings()
{
$row = $this->getQueryBuilder()
->select('*')
diff --git a/db/migrations/20210916072842.php b/db/migrations/20210916072842.php
index e8b001eb..8aa7b850 100644
--- a/db/migrations/20210916072842.php
+++ b/db/migrations/20210916072842.php
@@ -7,15 +7,19 @@
use Phinx\Migration\AbstractMigration;
+require_once 'SettingTrait.php';
+
final class V20210916072842 extends AbstractMigration
{
+ use SettingTrait;
+
public function up()
{
- $this->handleLocalAuthSetting();
+ $this->handleLocalAuthSettings();
}
- protected function handleLocalAuthSetting()
+ protected function handleLocalAuthSettings()
{
$rows = [
[
@@ -30,7 +34,7 @@ final class V20210916072842 extends AbstractMigration
]
];
- $this->table('kg_setting')->insert($rows)->save();
+ $this->insertSettings($rows);
}
}
diff --git a/db/migrations/20210917093354.php b/db/migrations/20210917093354.php
index 08a64015..0b68b55b 100644
--- a/db/migrations/20210917093354.php
+++ b/db/migrations/20210917093354.php
@@ -5,16 +5,20 @@
* @link https://www.koogua.com
*/
+require_once 'SettingTrait.php';
+
use Phinx\Db\Adapter\MysqlAdapter;
class V20210917093354 extends Phinx\Migration\AbstractMigration
{
+ use SettingTrait;
+
public function up()
{
$this->alterConnectTable();
$this->alterWechatSubscribeTable();
- $this->handleLocalAuthSetting();
+ $this->handleLocalAuthSettings();
}
protected function alterConnectTable()
@@ -92,7 +96,7 @@ class V20210917093354 extends Phinx\Migration\AbstractMigration
$table->save();
}
- protected function handleLocalAuthSetting()
+ protected function handleLocalAuthSettings()
{
$rows = [
[
@@ -107,7 +111,7 @@ class V20210917093354 extends Phinx\Migration\AbstractMigration
]
];
- $this->table('kg_setting')->insert($rows)->save();
+ $this->insertSettings($rows);
}
}
diff --git a/db/migrations/20211017085325.php b/db/migrations/20211017085325.php
index 6d01c66a..f9f52167 100644
--- a/db/migrations/20211017085325.php
+++ b/db/migrations/20211017085325.php
@@ -18,15 +18,20 @@ final class V20211017085325 extends AbstractMigration
protected function alterCourseTable()
{
- $this->table('kg_course')
- ->addColumn('fake_user_count', 'integer', [
+ $table = $this->table('kg_course');
+
+ if ($table->hasColumn('fake_user_count') == false) {
+ $table->addColumn('fake_user_count', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '伪造用户数',
'after' => 'user_count',
- ])->save();
+ ]);
+ }
+
+ $table->save();
}
}
diff --git a/db/migrations/20211019093522.php b/db/migrations/20211019093522.php
index 5946d094..9c9c2d0e 100644
--- a/db/migrations/20211019093522.php
+++ b/db/migrations/20211019093522.php
@@ -19,28 +19,38 @@ final class V20211019093522 extends AbstractMigration
protected function alterUserSessionTable()
{
- $this->table('kg_user_session')
- ->addColumn('deleted', 'integer', [
+ $table = $this->table('kg_user_session');
+
+ if ($table->hasColumn('deleted') == false) {
+ $table->addColumn('deleted', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '删除标识',
'after' => 'client_ip',
- ])->save();
+ ]);
+ }
+
+ $table->save();
}
protected function alterUserTokenTable()
{
- $this->table('kg_user_token')
- ->addColumn('deleted', 'integer', [
+ $table = $this->table('kg_user_token');
+
+ if ($table->hasColumn('deleted') == false) {
+ $table->addColumn('deleted', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '删除标识',
'after' => 'client_ip',
- ])->save();
+ ]);
+ }
+
+ $table->save();
}
}
diff --git a/db/migrations/20211231013226.php b/db/migrations/20211231013226.php
index a3f35979..69337b25 100644
--- a/db/migrations/20211231013226.php
+++ b/db/migrations/20211231013226.php
@@ -2,26 +2,29 @@
use Phinx\Migration\AbstractMigration;
+require_once 'SettingTrait.php';
+
final class V20211231013226 extends AbstractMigration
{
+ use SettingTrait;
+
public function up()
{
- $this->handleSmsSetting();
+ $this->handleSmsSettings();
}
- protected function handleSmsSetting()
+ protected function handleSmsSettings()
{
- $row =
+ $rows = [
[
- [
- 'section' => 'sms',
- 'item_key' => 'region',
- 'item_value' => 'ap-guangzhou',
- ]
- ];
+ 'section' => 'sms',
+ 'item_key' => 'region',
+ 'item_value' => 'ap-guangzhou',
+ ]
+ ];
- $this->table('kg_setting')->insert($row)->save();
+ $this->insertSettings($rows);
}
}
diff --git a/db/migrations/20220607014823.php b/db/migrations/20220607014823.php
index 5c8a5778..95b40e8d 100644
--- a/db/migrations/20220607014823.php
+++ b/db/migrations/20220607014823.php
@@ -21,29 +21,28 @@ final class V20220607014823 extends AbstractMigration
protected function handleSiteSettings()
{
- $rows =
+ $rows = [
[
- [
- 'section' => 'site',
- 'item_key' => 'isp_sn',
- 'item_value' => '',
- ],
- [
- 'section' => 'site',
- 'item_key' => 'isp_link',
- 'item_value' => 'https://dxzhgl.miit.gov.cn',
- ],
- [
- 'section' => 'site',
- 'item_key' => 'company_sn',
- 'item_value' => '',
- ],
- [
- 'section' => 'site',
- 'item_key' => 'company_sn_link',
- 'item_value' => '',
- ],
- ];
+ 'section' => 'site',
+ 'item_key' => 'isp_sn',
+ 'item_value' => '',
+ ],
+ [
+ 'section' => 'site',
+ 'item_key' => 'isp_link',
+ 'item_value' => 'https://dxzhgl.miit.gov.cn',
+ ],
+ [
+ 'section' => 'site',
+ 'item_key' => 'company_sn',
+ 'item_value' => '',
+ ],
+ [
+ 'section' => 'site',
+ 'item_key' => 'company_sn_link',
+ 'item_value' => '',
+ ],
+ ];
$this->insertSettings($rows);
}
diff --git a/db/migrations/20220801025747.php b/db/migrations/20220801025747.php
index 21a3e9ea..6ceec26c 100644
--- a/db/migrations/20220801025747.php
+++ b/db/migrations/20220801025747.php
@@ -20,7 +20,13 @@ class V20220801025747 extends Phinx\Migration\AbstractMigration
protected function createMigrationTaskTable()
{
- $this->table('kg_migration_task', [
+ $tableName = 'kg_migration_task';
+
+ if ($this->table($tableName)->exists()) {
+ return;
+ }
+
+ $this->table($tableName, [
'id' => false,
'primary_key' => ['id'],
'engine' => 'InnoDB',
@@ -70,13 +76,21 @@ class V20220801025747 extends Phinx\Migration\AbstractMigration
protected function dropImTables()
{
- $this->table('kg_im_friend_group')->drop()->save();
- $this->table('kg_im_friend_user')->drop()->save();
- $this->table('kg_im_group')->drop()->save();
- $this->table('kg_im_group_user')->drop()->save();
- $this->table('kg_im_message')->drop()->save();
- $this->table('kg_im_notice')->drop()->save();
- $this->table('kg_im_user')->drop()->save();
+ $tableNames = [
+ 'kg_im_friend_group',
+ 'kg_im_friend_user',
+ 'kg_im_group',
+ 'kg_im_group_user',
+ 'kg_im_message',
+ 'kg_im_notice',
+ 'kg_im_user',
+ ];
+
+ foreach ($tableNames as $tableName) {
+ if ($this->table($tableName)->exists()) {
+ $this->table($tableName)->drop()->save();
+ }
+ }
}
protected function deleteImGroupNav()
diff --git a/public/static/home/js/captcha.verify.email.js b/public/static/home/js/captcha.verify.email.js
new file mode 100644
index 00000000..8ab8f11b
--- /dev/null
+++ b/public/static/home/js/captcha.verify.email.js
@@ -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;
+ }
+
+});
\ No newline at end of file
diff --git a/public/static/home/js/captcha.verify.js b/public/static/home/js/captcha.verify.js
index 5340f9fb..a8bcf813 100644
--- a/public/static/home/js/captcha.verify.js
+++ b/public/static/home/js/captcha.verify.js
@@ -1,8 +1,9 @@
-layui.use(['jquery', 'layer', 'util'], function () {
+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-account');
@@ -28,16 +29,8 @@ layui.use(['jquery', 'layer', 'util'], function () {
}
$account.on('keyup', function () {
- var accountOk;
- var type = $(this).data('type');
var account = $(this).val();
- if (type === 'phone') {
- accountOk = isPhone(account);
- } else if (type === 'email') {
- accountOk = isEmail(account);
- } else {
- accountOk = isPhone(account) || isEmail(account);
- }
+ var accountOk = helper.isPhone(account) || helper.isEmail(account);
if (accountOk && !timeCounting) {
$emit.removeClass('layui-btn-disabled').removeAttr('disabled');
} else {
@@ -46,7 +39,7 @@ layui.use(['jquery', 'layer', 'util'], function () {
});
function sendVerifyCode() {
- if (isEmail($account.val()) || isPhone($account.val())) {
+ if (helper.isEmail($account.val()) || helper.isPhone($account.val())) {
var postUrl;
var postData = {
captcha: {
@@ -54,10 +47,10 @@ layui.use(['jquery', 'layer', 'util'], function () {
rand: $('#cv-captcha-rand').val(),
}
};
- if (isPhone($account.val())) {
+ if (helper.isPhone($account.val())) {
postData.phone = $account.val();
postUrl = '/verify/sms/code';
- } else if (isEmail($account.val())) {
+ } else if (helper.isEmail($account.val())) {
postData.email = $account.val();
postUrl = '/verify/mail/code';
}
@@ -90,12 +83,4 @@ layui.use(['jquery', 'layer', 'util'], function () {
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);
- }
-
});
\ No newline at end of file
diff --git a/public/static/home/js/captcha.verify.phone.js b/public/static/home/js/captcha.verify.phone.js
new file mode 100644
index 00000000..95f0a731
--- /dev/null
+++ b/public/static/home/js/captcha.verify.phone.js
@@ -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;
+ }
+
+});
\ No newline at end of file
diff --git a/public/static/lib/layui/extends/helper.js b/public/static/lib/layui/extends/helper.js
index 2c3c686b..336d1b36 100644
--- a/public/static/lib/layui/extends/helper.js
+++ b/public/static/lib/layui/extends/helper.js
@@ -6,6 +6,14 @@ layui.define(['jquery', 'layer'], function (exports) {
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 () {
var id = Date.now().toString(36);
id += Math.random().toString(36).substr(3);