-
- 账号安全
-
-
-
-
-
-
登录密码
-
经常更改密码有助于保护您的帐号安全
+ {% if oauth_provider.wechat.enabled == 1 %}
+
-
-
-
-
手机绑定
- {% if account.phone %}
-
已绑定手机:{{ account.phone|anonymous }}
+
+ {% if wechat_oa_connected == 0 %}
+
+
关注官方公众号,订阅系统重要通知
{% else %}
-
可用于登录和重置密码
+
你已经关注官方公众号
{% endif %}
-
-
-
-
-
- 邮箱绑定
- {% if account.email %}
- 已绑定邮箱:{{ account.email|anonymous }}
- {% else %}
- 可用于登录和重置密码
- {% endif %}
-
-
-
-
-
- 开放登录
-
- {% if connects %}
-
已经绑定的第三方帐号
-
-
-
- 提供方 |
- 用户信息 |
- 更新日期 |
- 操作 |
-
- {% for connect in connects %}
- {% set url = url({'for':'home.uc.unconnect','id':connect.id}) %}
- {% set time = connect.update_time > 0 ? connect.update_time : connect.create_time %}
-
- {{ connect_provider(connect) }} |
- {{ connect_user(connect) }} |
- {{ date('Y-m-d H:i',time) }} |
- 解绑 |
-
- {% endfor %}
-
{% endif %}
-
支持绑定的第三方帐号
-
- {% if oauth_provider.qq.enabled == 1 %}
-
- {% endif %}
- {% if oauth_provider.weixin.enabled == 1 %}
-
- {% endif %}
- {% if oauth_provider.weibo.enabled == 1 %}
-
+
+
+ 账号安全
+
+
+
+
+
+ 登录密码
+ 经常更改密码有助于保护您的帐号安全
+
+
+
+
+
+
+ 手机绑定
+ {% if account.phone %}
+ 已绑定手机:{{ account.phone|anonymous }}
+ {% else %}
+ 可用于登录和重置密码
+ {% endif %}
+
+
+
+
+
+
+ 邮箱绑定
+ {% if account.email %}
+ 已绑定邮箱:{{ account.email|anonymous }}
+ {% else %}
+ 可用于登录和重置密码
+ {% endif %}
+
+
+
+
+
+
+
+ 开放登录
+
+ {% if connects|length > 0 %}
+
已经绑定的第三方帐号
+
+
+
+ 提供方 |
+ 用户信息 |
+ 更新日期 |
+ 操作 |
+
+ {% for connect in connects %}
+ {% set url = url({'for':'home.uc.unconnect','id':connect.id}) %}
+ {% set time = connect.update_time > 0 ? connect.update_time : connect.create_time %}
+
+ {{ connect_provider(connect) }} |
+ {{ connect_user(connect) }} |
+ {{ date('Y-m-d H:i',time) }} |
+ 解绑 |
+
+ {% endfor %}
+
+
{% endif %}
+
支持绑定的第三方帐号
+
+ {% if oauth_provider.qq.enabled == 1 %}
+
+ {% endif %}
+ {% if oauth_provider.weixin.enabled == 1 %}
+
+ {% endif %}
+ {% if oauth_provider.weibo.enabled == 1 %}
+
+ {% endif %}
+
+{% endblock %}
+
+{% block include_js %}
+
+ {% if oauth_provider.wechat.enabled == 1 and wechat_oa_connected == 0 %}
+ {{ js_include('home/js/wechat.oa.subscribe.js') }}
+ {% endif %}
+
{% endblock %}
\ No newline at end of file
diff --git a/app/Http/Home/Views/user/console/menu.volt b/app/Http/Home/Views/user/console/menu.volt
index 8f80df14..c2f28d20 100644
--- a/app/Http/Home/Views/user/console/menu.volt
+++ b/app/Http/Home/Views/user/console/menu.volt
@@ -7,7 +7,6 @@
{% endif %}
{%- endmacro %}
-{% set wechat_oa_enabled = setting('wechat.oa','enabled') %}
{% set point_enabled = setting('point','enabled') %}
@@ -70,9 +69,6 @@
个人信息
收货地址
帐号安全
- {% if wechat_oa_enabled == 1 %}
-
关注订阅
- {% endif %}
\ No newline at end of file
diff --git a/app/Http/Home/Views/user/console/subscribe.volt b/app/Http/Home/Views/user/console/subscribe.volt
index 196cf83e..fc2c1849 100644
--- a/app/Http/Home/Views/user/console/subscribe.volt
+++ b/app/Http/Home/Views/user/console/subscribe.volt
@@ -28,6 +28,6 @@
{% block include_js %}
- {{ js_include('home/js/user.console.subscribe.js') }}
+ {{ js_include('home/js/wechat.oa.subscribe.js') }}
{% endblock %}
\ No newline at end of file
diff --git a/app/Models/WeChatSubscribe.php b/app/Models/WeChatSubscribe.php
deleted file mode 100644
index b6b0234a..00000000
--- a/app/Models/WeChatSubscribe.php
+++ /dev/null
@@ -1,70 +0,0 @@
-create_time = time();
- }
-
- public function beforeUpdate()
- {
- $this->update_time = time();
- }
-
-}
diff --git a/app/Repos/WeChatSubscribe.php b/app/Repos/WeChatSubscribe.php
deleted file mode 100644
index bec577d5..00000000
--- a/app/Repos/WeChatSubscribe.php
+++ /dev/null
@@ -1,77 +0,0 @@
- 'user_id= ?1 AND open_id = ?2',
- 'bind' => [1 => $userId, 2 => $openId],
- ]);
- }
-
- /**
- * @param int $id
- * @return WeChatSubscribeModel|Model|bool
- */
- public function findById($id)
- {
- return WeChatSubscribeModel::findFirst([
- 'conditions' => 'id = :id:',
- 'bind' => ['id' => $id],
- ]);
- }
-
- /**
- * @param int $userId
- * @return WeChatSubscribeModel|Model|bool
- */
- public function findByUserId($userId)
- {
- return WechatSubscribeModel::findFirst([
- 'conditions' => 'user_id = :user_id:',
- 'bind' => ['user_id' => $userId],
- ]);
- }
-
- /**
- * @param string $openId
- * @return WeChatSubscribeModel|Model|bool
- */
- public function findByOpenId($openId)
- {
- return WeChatSubscribeModel::findFirst([
- 'conditions' => 'open_id = :open_id:',
- 'bind' => ['open_id' => $openId],
- ]);
- }
-
- /**
- * @param string $unionId
- * @return WeChatSubscribeModel|Model|bool
- */
- public function findByUnionId($unionId)
- {
- return WeChatSubscribeModel::findFirst([
- 'conditions' => 'union_id = :union_id:',
- 'bind' => ['union_id' => $unionId],
- ]);
- }
-
-}
diff --git a/app/Services/Logic/Account/OAuthProvider.php b/app/Services/Logic/Account/OAuthProvider.php
index 6b63763d..94ae5247 100644
--- a/app/Services/Logic/Account/OAuthProvider.php
+++ b/app/Services/Logic/Account/OAuthProvider.php
@@ -15,18 +15,20 @@ class OAuthProvider extends LogicService
public function handle()
{
$local = $this->getSettings('oauth.local');
+ $qq = $this->getSettings('oauth.qq');
$weixin = $this->getSettings('oauth.weixin');
$weibo = $this->getSettings('oauth.weibo');
- $qq = $this->getSettings('oauth.qq');
+ $wechatOA = $this->getSettings('wechat.oa');
return [
'local' => [
'register_with_phone' => $local['register_with_phone'],
'register_with_email' => $local['register_with_email'],
],
+ 'qq' => ['enabled' => $qq['enabled']],
'weixin' => ['enabled' => $weixin['enabled']],
'weibo' => ['enabled' => $weibo['enabled']],
- 'qq' => ['enabled' => $qq['enabled']],
+ 'wechat' => ['enabled' => $wechatOA['enabled']],
];
}
diff --git a/app/Services/Logic/Notice/External/WeChat/AccountLogin.php b/app/Services/Logic/Notice/External/WeChat/AccountLogin.php
index 6319492f..487c5c2c 100644
--- a/app/Services/Logic/Notice/External/WeChat/AccountLogin.php
+++ b/app/Services/Logic/Notice/External/WeChat/AccountLogin.php
@@ -7,7 +7,6 @@
namespace App\Services\Logic\Notice\External\WeChat;
-use App\Repos\WeChatSubscribe as WeChatSubscribeRepo;
use App\Services\WeChatNotice;
class AccountLogin extends WeChatNotice
@@ -21,9 +20,7 @@ class AccountLogin extends WeChatNotice
*/
public function handle(array $params)
{
- $subscribeRepo = new WeChatSubscribeRepo();
-
- $subscribe = $subscribeRepo->findByUserId($params['user']['id']);
+ $subscribe = $this->getConnect($params['user']['id']);
if (!$subscribe) return null;
diff --git a/app/Services/Logic/Notice/External/WeChat/ConsultReply.php b/app/Services/Logic/Notice/External/WeChat/ConsultReply.php
index 330dfbc2..a7d596dc 100644
--- a/app/Services/Logic/Notice/External/WeChat/ConsultReply.php
+++ b/app/Services/Logic/Notice/External/WeChat/ConsultReply.php
@@ -7,7 +7,6 @@
namespace App\Services\Logic\Notice\External\WeChat;
-use App\Repos\WeChatSubscribe as WeChatSubscribeRepo;
use App\Services\WeChatNotice;
class ConsultReply extends WeChatNotice
@@ -21,9 +20,7 @@ class ConsultReply extends WeChatNotice
*/
public function handle(array $params)
{
- $subscribeRepo = new WeChatSubscribeRepo();
-
- $subscribe = $subscribeRepo->findByUserId($params['user']['id']);
+ $subscribe = $this->getConnect($params['user']['id']);
if (!$subscribe) return null;
diff --git a/app/Services/Logic/Notice/External/WeChat/GoodsDeliver.php b/app/Services/Logic/Notice/External/WeChat/GoodsDeliver.php
index 6d336c33..e7b24460 100644
--- a/app/Services/Logic/Notice/External/WeChat/GoodsDeliver.php
+++ b/app/Services/Logic/Notice/External/WeChat/GoodsDeliver.php
@@ -7,7 +7,6 @@
namespace App\Services\Logic\Notice\External\WeChat;
-use App\Repos\WeChatSubscribe as WeChatSubscribeRepo;
use App\Services\WeChatNotice;
class GoodsDeliver extends WeChatNotice
@@ -21,9 +20,7 @@ class GoodsDeliver extends WeChatNotice
*/
public function handle($params)
{
- $subscribeRepo = new WeChatSubscribeRepo();
-
- $subscribe = $subscribeRepo->findByUserId($params['user']['id']);
+ $subscribe = $this->getConnect($params['user']['id']);
if (!$subscribe) return null;
diff --git a/app/Services/Logic/Notice/External/WeChat/LiveBegin.php b/app/Services/Logic/Notice/External/WeChat/LiveBegin.php
index 3db3d77f..8c03e22d 100644
--- a/app/Services/Logic/Notice/External/WeChat/LiveBegin.php
+++ b/app/Services/Logic/Notice/External/WeChat/LiveBegin.php
@@ -7,7 +7,6 @@
namespace App\Services\Logic\Notice\External\WeChat;
-use App\Repos\WeChatSubscribe as WeChatSubscribeRepo;
use App\Services\WeChatNotice;
class LiveBegin extends WeChatNotice
@@ -21,9 +20,7 @@ class LiveBegin extends WeChatNotice
*/
public function handle(array $params)
{
- $subscribeRepo = new WeChatSubscribeRepo();
-
- $subscribe = $subscribeRepo->findByUserId($params['user']['id']);
+ $subscribe = $this->getConnect($params['user']['id']);
if (!$subscribe) return null;
diff --git a/app/Services/Logic/Notice/External/WeChat/OrderFinish.php b/app/Services/Logic/Notice/External/WeChat/OrderFinish.php
index 2594bcd2..9563863c 100644
--- a/app/Services/Logic/Notice/External/WeChat/OrderFinish.php
+++ b/app/Services/Logic/Notice/External/WeChat/OrderFinish.php
@@ -7,7 +7,6 @@
namespace App\Services\Logic\Notice\External\WeChat;
-use App\Repos\WeChatSubscribe as WeChatSubscribeRepo;
use App\Services\WeChatNotice;
class OrderFinish extends WeChatNotice
@@ -21,9 +20,7 @@ class OrderFinish extends WeChatNotice
*/
public function handle($params)
{
- $subscribeRepo = new WeChatSubscribeRepo();
-
- $subscribe = $subscribeRepo->findByUserId($params['user']['id']);
+ $subscribe = $this->getConnect($params['user']['id']);
if (!$subscribe) return null;
diff --git a/app/Services/Logic/Notice/External/WeChat/RefundFinish.php b/app/Services/Logic/Notice/External/WeChat/RefundFinish.php
index f19d3c0c..0685311c 100644
--- a/app/Services/Logic/Notice/External/WeChat/RefundFinish.php
+++ b/app/Services/Logic/Notice/External/WeChat/RefundFinish.php
@@ -7,7 +7,6 @@
namespace App\Services\Logic\Notice\External\WeChat;
-use App\Repos\WeChatSubscribe as WeChatSubscribeRepo;
use App\Services\WeChatNotice;
class RefundFinish extends WeChatNotice
@@ -21,9 +20,7 @@ class RefundFinish extends WeChatNotice
*/
public function handle(array $params)
{
- $subscribeRepo = new WeChatSubscribeRepo();
-
- $subscribe = $subscribeRepo->findByUserId($params['user']['id']);
+ $subscribe = $this->getConnect($params['user']['id']);
if (!$subscribe) return null;
diff --git a/app/Services/WeChatNotice.php b/app/Services/WeChatNotice.php
index 7af1a140..30a9c88b 100644
--- a/app/Services/WeChatNotice.php
+++ b/app/Services/WeChatNotice.php
@@ -7,6 +7,8 @@
namespace App\Services;
+use App\Models\Connect as ConnectModel;
+use App\Repos\Connect as ConnectRepo;
use App\Services\WeChat as WeChatService;
use Phalcon\Logger\Adapter\File as FileLogger;
@@ -105,4 +107,11 @@ abstract class WeChatNotice extends Service
return $template[$code]['id'] ?? null;
}
+ protected function getConnect($userId)
+ {
+ $connectRepo = new ConnectRepo();
+
+ return $connectRepo->findByUserId($userId, ConnectModel::PROVIDER_WECHAT_OA);
+ }
+
}
diff --git a/db/migrations/20210324064239.php b/db/migrations/20210324064239.php
index 4320717a..04aa1e42 100644
--- a/db/migrations/20210324064239.php
+++ b/db/migrations/20210324064239.php
@@ -81,7 +81,6 @@ final class V20210324064239 extends AbstractMigration
$this->createUserSessionTable();
$this->createUserTokenTable();
$this->createVipTable();
- $this->createWechatSubscribeTable();
}
protected function createAccountTable()
@@ -7206,72 +7205,4 @@ final class V20210324064239 extends AbstractMigration
->create();
}
- protected function createWechatSubscribeTable()
- {
- $tableName = 'kg_wechat_subscribe';
-
- if ($this->table($tableName)->exists()) {
- return;
- }
-
- $this->table($tableName, [
- '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('open_id', 'string', [
- 'null' => false,
- 'default' => '',
- 'limit' => 64,
- 'collation' => 'utf8mb4_general_ci',
- 'encoding' => 'utf8mb4',
- 'comment' => '开放ID',
- 'after' => 'user_id',
- ])
- ->addColumn('create_time', 'integer', [
- 'null' => false,
- 'default' => '0',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'comment' => '创建时间',
- 'after' => 'open_id',
- ])
- ->addColumn('update_time', 'integer', [
- 'null' => false,
- 'default' => '0',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'comment' => '更新时间',
- 'after' => 'create_time',
- ])
- ->addIndex(['open_id'], [
- 'name' => 'open_id',
- 'unique' => false,
- ])
- ->addIndex(['user_id'], [
- 'name' => 'user_id',
- 'unique' => false,
- ])
- ->create();
- }
-
}
diff --git a/db/migrations/20210917093354.php b/db/migrations/20210917093354.php
index 0b68b55b..dcacacbf 100644
--- a/db/migrations/20210917093354.php
+++ b/db/migrations/20210917093354.php
@@ -17,7 +17,6 @@ class V20210917093354 extends Phinx\Migration\AbstractMigration
public function up()
{
$this->alterConnectTable();
- $this->alterWechatSubscribeTable();
$this->handleLocalAuthSettings();
}
@@ -50,52 +49,6 @@ class V20210917093354 extends Phinx\Migration\AbstractMigration
$table->save();
}
- protected function alterWechatSubscribeTable()
- {
- $table = $this->table('kg_wechat_subscribe');
-
- if (!$table->hasColumn('union_id')) {
- $table->addColumn('union_id', 'string', [
- 'null' => false,
- 'default' => '',
- 'limit' => 64,
- 'collation' => 'utf8mb4_general_ci',
- 'encoding' => 'utf8mb4',
- 'comment' => '联合ID',
- 'after' => 'open_id',
- ]);
- }
- if (!$table->hasColumn('deleted')) {
- $table->addColumn('deleted', 'integer', [
- 'null' => false,
- 'default' => '0',
- 'limit' => MysqlAdapter::INT_REGULAR,
- 'signed' => false,
- 'comment' => '删除标识',
- 'after' => 'union_id',
- ]);
- }
- if (!$table->hasIndexByName('user_id')) {
- $table->addIndex(['user_id'], [
- 'name' => 'user_id',
- 'unique' => false,
- ]);
- }
- if (!$table->hasIndexByName('open_id')) {
- $table->addIndex(['open_id'], [
- 'name' => 'open_id',
- 'unique' => false,
- ]);
- }
- if (!$table->hasIndexByName('union_id')) {
- $table->addIndex(['union_id'], [
- 'name' => 'union_id',
- 'unique' => false,
- ]);
- }
- $table->save();
- }
-
protected function handleLocalAuthSettings()
{
$rows = [
diff --git a/public/static/home/css/common.css b/public/static/home/css/common.css
index e8ca5767..f4e41425 100644
--- a/public/static/home/css/common.css
+++ b/public/static/home/css/common.css
@@ -1700,6 +1700,30 @@
color: red;
}
+.register-close-tips {
+ padding: 50px;
+ text-align: center;
+ color: #999;
+}
+
+.wechat-scan-box {
+ padding: 20px;
+ text-align: center;
+}
+
+.wechat-scan-box .qrcode {
+ margin-bottom: 20px;
+}
+
+.wechat-scan-box .qrcode img {
+ border: 3px solid #999;
+ padding: 3px;
+}
+
+.wechat-scan-box .tips {
+ color: #666;
+}
+
.user-profile {
display: flex;
align-items: center;
@@ -1934,6 +1958,10 @@
margin-right: 0;
}
+.my-content .section {
+ margin-bottom: 20px;
+}
+
.profile-form {
width: 95%;
}
diff --git a/public/static/home/js/user.console.subscribe.js b/public/static/home/js/user.console.subscribe.js
deleted file mode 100644
index 14dc9fd2..00000000
--- a/public/static/home/js/user.console.subscribe.js
+++ /dev/null
@@ -1,29 +0,0 @@
-layui.use(['jquery'], function () {
-
- var $ = layui.jquery;
- var subscribed = $('input[name=subscribed]').val();
- var interval = null;
-
- if (subscribed === '0') {
- showQrCode();
- interval = setInterval(function () {
- queryStatus();
- }, 5000);
- }
-
- function showQrCode() {
- $.get('/wechat/oa/subscribe/qrcode', function (res) {
- $('#sub-qrcode').html('

');
- });
- }
-
- function queryStatus() {
- $.get('/wechat/oa/subscribe/status', function (res) {
- if (res.status === 1) {
- clearInterval(interval);
- $('#sub-tips').addClass('success').html('关注公众号成功');
- }
- });
- }
-
-});
\ No newline at end of file
diff --git a/public/static/home/js/wechat.oa.subscribe.js b/public/static/home/js/wechat.oa.subscribe.js
new file mode 100644
index 00000000..a2f62122
--- /dev/null
+++ b/public/static/home/js/wechat.oa.subscribe.js
@@ -0,0 +1,34 @@
+layui.use(['jquery', 'layer'], function () {
+
+ var $ = layui.jquery;
+ var layer = layui.layer;
+ var interval = null;
+
+ var $qrcode = $('.wechat-scan-box > .qrcode');
+
+ if ($qrcode.length > 0) {
+ showQrCode();
+ }
+
+ function showQrCode() {
+ $.get('/wechat/oa/subscribe/qrcode', function (res) {
+ $qrcode.html('

');
+ interval = setInterval(function () {
+ queryStatus();
+ }, 1500);
+ });
+ }
+
+ function queryStatus() {
+ $.get('/wechat/oa/subscribe/status', function (res) {
+ if (res.status === 1) {
+ clearInterval(interval);
+ layer.msg('关注微信公众号成功', {icon: 1});
+ setTimeout(function () {
+ window.location.reload();
+ }, 1500);
+ }
+ });
+ }
+
+});