mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-10-08 18:00:00 +08:00
修改微信菜单
This commit is contained in:
parent
e9c36078dc
commit
e7bcba6d86
@ -30,7 +30,7 @@ class Menu extends Controller
|
|||||||
* 微信菜单的类型
|
* 微信菜单的类型
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $menuType = [
|
protected $menuTypes = [
|
||||||
'click' => '匹配规则',
|
'click' => '匹配规则',
|
||||||
'view' => '跳转网页',
|
'view' => '跳转网页',
|
||||||
'miniprogram' => '打开小程序',
|
'miniprogram' => '打开小程序',
|
||||||
@ -54,12 +54,11 @@ class Menu extends Controller
|
|||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
if ($this->request->get('output') === 'json') {
|
if ($this->request->get('output') === 'json') {
|
||||||
$where = [['keys', 'notin', ['subscribe', 'default']], ['status', 'eq', '1']];
|
$where = [['keys', 'notin', ['subscribe', 'default']], ['status', '=', '1']];
|
||||||
$keys = $this->app->db->name('WechatKeys')->where($where)->order('sort desc,id desc')->select();
|
$keys = $this->app->db->name('WechatKeys')->where($where)->order('sort desc,id desc')->select();
|
||||||
$this->success('获取数据成功!', ['menudata' => sysdata('menudata'), 'keysdata' => $keys]);
|
$this->success('获取数据成功!', ['menudata' => sysdata('menudata'), 'keysdata' => $keys]);
|
||||||
} else {
|
} else {
|
||||||
$this->title = '微信菜单定制';
|
$this->title = '微信菜单定制';
|
||||||
$this->menuTypes = $this->menuType;
|
|
||||||
$this->fetch();
|
$this->fetch();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -68,7 +67,7 @@ class Menu extends Controller
|
|||||||
* 编辑微信菜单
|
* 编辑微信菜单
|
||||||
* @auth true
|
* @auth true
|
||||||
*/
|
*/
|
||||||
public function edit()
|
public function push()
|
||||||
{
|
{
|
||||||
if ($this->request->isPost()) {
|
if ($this->request->isPost()) {
|
||||||
$data = $this->request->post('data');
|
$data = $this->request->post('data');
|
||||||
@ -85,7 +84,7 @@ class Menu extends Controller
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
sysdata('menudata', $this->_buildMenuData($menudata = json_decode($data, true)));
|
sysdata('menudata', $this->_buildMenuData(json_decode($data, true)));
|
||||||
WechatService::WeChatMenu()->create(['button' => sysdata('menudata')]);
|
WechatService::WeChatMenu()->create(['button' => sysdata('menudata')]);
|
||||||
sysoplog('微信管理', '发布微信菜单成功');
|
sysoplog('微信管理', '发布微信菜单成功');
|
||||||
$this->success('保存发布菜单成功!', '');
|
$this->success('保存发布菜单成功!', '');
|
||||||
@ -104,7 +103,7 @@ class Menu extends Controller
|
|||||||
* @param array $list
|
* @param array $list
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private function _buildMenuData(array $list)
|
private function _buildMenuData(array $list): array
|
||||||
{
|
{
|
||||||
foreach ($list as &$vo) {
|
foreach ($list as &$vo) {
|
||||||
unset($vo['active'], $vo['show']);
|
unset($vo['active'], $vo['show']);
|
||||||
@ -155,12 +154,12 @@ class Menu extends Controller
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
WechatService::WeChatMenu()->delete();
|
WechatService::WeChatMenu()->delete();
|
||||||
$this->success('菜单取消成功,重新关注可立即生效!', '');
|
$this->success('菜单取消成功,重新关注可立即生效!');
|
||||||
} catch (HttpResponseException $exception) {
|
} catch (HttpResponseException $exception) {
|
||||||
sysoplog('微信管理', '取消微信菜单成功');
|
sysoplog('微信管理', '取消微信菜单成功');
|
||||||
throw $exception;
|
throw $exception;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $exception) {
|
||||||
$this->error("菜单取消失败,请稍候再试!<br> {$e->getMessage()}");
|
$this->error("菜单取消失败,请稍候再试!<br> {$exception->getMessage()}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="text-center margin-top-20">
|
<div class="text-center margin-top-20">
|
||||||
{if auth("edit")}
|
{if auth("push")}
|
||||||
<button class="layui-btn menu-submit" ng-click="submit()">保存发布</button>
|
<button class="layui-btn menu-submit" ng-click="submit()">保存发布</button>
|
||||||
{/if}
|
{/if}
|
||||||
{if auth("cancel")}
|
{if auth("cancel")}
|
||||||
@ -194,7 +194,7 @@
|
|||||||
$rootScope.submit = function () {
|
$rootScope.submit = function () {
|
||||||
$vali.checkAllInput();
|
$vali.checkAllInput();
|
||||||
if ($form.find('.validate-error').size() > 0) return false;
|
if ($form.find('.validate-error').size() > 0) return false;
|
||||||
$.form.load('{:url("edit")}', {data: angular.toJson($rootScope.list)}, 'post');
|
$.form.load('{:url("push")}', {data: angular.toJson($rootScope.list)}, 'post');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
8
composer.lock
generated
8
composer.lock
generated
@ -909,12 +909,12 @@
|
|||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/zoujingli/ThinkLibrary.git",
|
"url": "https://github.com/zoujingli/ThinkLibrary.git",
|
||||||
"reference": "1246ce655df8db112a60bf57037a9a17f4b11d77"
|
"reference": "030a60c13c6d8d15a6ce507edaf47ee384835983"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/1246ce655df8db112a60bf57037a9a17f4b11d77",
|
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/030a60c13c6d8d15a6ce507edaf47ee384835983",
|
||||||
"reference": "1246ce655df8db112a60bf57037a9a17f4b11d77",
|
"reference": "030a60c13c6d8d15a6ce507edaf47ee384835983",
|
||||||
"shasum": "",
|
"shasum": "",
|
||||||
"mirrors": [
|
"mirrors": [
|
||||||
{
|
{
|
||||||
@ -958,7 +958,7 @@
|
|||||||
],
|
],
|
||||||
"description": "ThinkPHP v6.0 Development Library",
|
"description": "ThinkPHP v6.0 Development Library",
|
||||||
"homepage": "http://framework.thinkadmin.top",
|
"homepage": "http://framework.thinkadmin.top",
|
||||||
"time": "2019-12-09T10:17:25+00:00"
|
"time": "2019-12-10T02:15:54+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "zoujingli/wechat-developer",
|
"name": "zoujingli/wechat-developer",
|
||||||
|
5
vendor/composer/autoload_classmap.php
vendored
5
vendor/composer/autoload_classmap.php
vendored
@ -202,6 +202,11 @@ return array(
|
|||||||
'app\\admin\\controller\\api\\Update' => $baseDir . '/app/admin/controller/api/Update.php',
|
'app\\admin\\controller\\api\\Update' => $baseDir . '/app/admin/controller/api/Update.php',
|
||||||
'app\\admin\\controller\\api\\Upload' => $baseDir . '/app/admin/controller/api/Upload.php',
|
'app\\admin\\controller\\api\\Upload' => $baseDir . '/app/admin/controller/api/Upload.php',
|
||||||
'app\\index\\controller\\Index' => $baseDir . '/app/index/controller/Index.php',
|
'app\\index\\controller\\Index' => $baseDir . '/app/index/controller/Index.php',
|
||||||
|
'app\\wechat\\command\\Fans' => $baseDir . '/app/wechat/command/Fans.php',
|
||||||
|
'app\\wechat\\command\\fans\\FansAll' => $baseDir . '/app/wechat/command/fans/FansAll.php',
|
||||||
|
'app\\wechat\\command\\fans\\FansBlack' => $baseDir . '/app/wechat/command/fans/FansBlack.php',
|
||||||
|
'app\\wechat\\command\\fans\\FansList' => $baseDir . '/app/wechat/command/fans/FansList.php',
|
||||||
|
'app\\wechat\\command\\fans\\FansTags' => $baseDir . '/app/wechat/command/fans/FansTags.php',
|
||||||
'app\\wechat\\controller\\Config' => $baseDir . '/app/wechat/controller/Config.php',
|
'app\\wechat\\controller\\Config' => $baseDir . '/app/wechat/controller/Config.php',
|
||||||
'app\\wechat\\controller\\Fans' => $baseDir . '/app/wechat/controller/Fans.php',
|
'app\\wechat\\controller\\Fans' => $baseDir . '/app/wechat/controller/Fans.php',
|
||||||
'app\\wechat\\controller\\Keys' => $baseDir . '/app/wechat/controller/Keys.php',
|
'app\\wechat\\controller\\Keys' => $baseDir . '/app/wechat/controller/Keys.php',
|
||||||
|
5
vendor/composer/autoload_static.php
vendored
5
vendor/composer/autoload_static.php
vendored
@ -342,6 +342,11 @@ class ComposerStaticInitada0e677dd8f1307ba83d0cf07626e6c
|
|||||||
'app\\admin\\controller\\api\\Update' => __DIR__ . '/../..' . '/app/admin/controller/api/Update.php',
|
'app\\admin\\controller\\api\\Update' => __DIR__ . '/../..' . '/app/admin/controller/api/Update.php',
|
||||||
'app\\admin\\controller\\api\\Upload' => __DIR__ . '/../..' . '/app/admin/controller/api/Upload.php',
|
'app\\admin\\controller\\api\\Upload' => __DIR__ . '/../..' . '/app/admin/controller/api/Upload.php',
|
||||||
'app\\index\\controller\\Index' => __DIR__ . '/../..' . '/app/index/controller/Index.php',
|
'app\\index\\controller\\Index' => __DIR__ . '/../..' . '/app/index/controller/Index.php',
|
||||||
|
'app\\wechat\\command\\Fans' => __DIR__ . '/../..' . '/app/wechat/command/Fans.php',
|
||||||
|
'app\\wechat\\command\\fans\\FansAll' => __DIR__ . '/../..' . '/app/wechat/command/fans/FansAll.php',
|
||||||
|
'app\\wechat\\command\\fans\\FansBlack' => __DIR__ . '/../..' . '/app/wechat/command/fans/FansBlack.php',
|
||||||
|
'app\\wechat\\command\\fans\\FansList' => __DIR__ . '/../..' . '/app/wechat/command/fans/FansList.php',
|
||||||
|
'app\\wechat\\command\\fans\\FansTags' => __DIR__ . '/../..' . '/app/wechat/command/fans/FansTags.php',
|
||||||
'app\\wechat\\controller\\Config' => __DIR__ . '/../..' . '/app/wechat/controller/Config.php',
|
'app\\wechat\\controller\\Config' => __DIR__ . '/../..' . '/app/wechat/controller/Config.php',
|
||||||
'app\\wechat\\controller\\Fans' => __DIR__ . '/../..' . '/app/wechat/controller/Fans.php',
|
'app\\wechat\\controller\\Fans' => __DIR__ . '/../..' . '/app/wechat/controller/Fans.php',
|
||||||
'app\\wechat\\controller\\Keys' => __DIR__ . '/../..' . '/app/wechat/controller/Keys.php',
|
'app\\wechat\\controller\\Keys' => __DIR__ . '/../..' . '/app/wechat/controller/Keys.php',
|
||||||
|
8
vendor/composer/installed.json
vendored
8
vendor/composer/installed.json
vendored
@ -935,12 +935,12 @@
|
|||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/zoujingli/ThinkLibrary.git",
|
"url": "https://github.com/zoujingli/ThinkLibrary.git",
|
||||||
"reference": "1246ce655df8db112a60bf57037a9a17f4b11d77"
|
"reference": "030a60c13c6d8d15a6ce507edaf47ee384835983"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/1246ce655df8db112a60bf57037a9a17f4b11d77",
|
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/030a60c13c6d8d15a6ce507edaf47ee384835983",
|
||||||
"reference": "1246ce655df8db112a60bf57037a9a17f4b11d77",
|
"reference": "030a60c13c6d8d15a6ce507edaf47ee384835983",
|
||||||
"shasum": "",
|
"shasum": "",
|
||||||
"mirrors": [
|
"mirrors": [
|
||||||
{
|
{
|
||||||
@ -956,7 +956,7 @@
|
|||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
"topthink/framework": "^6.0"
|
"topthink/framework": "^6.0"
|
||||||
},
|
},
|
||||||
"time": "2019-12-09T10:17:25+00:00",
|
"time": "2019-12-10T02:15:54+00:00",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"think": {
|
"think": {
|
||||||
|
2
vendor/services.php
vendored
2
vendor/services.php
vendored
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
// This file is automatically generated at:2019-12-09 18:41:34
|
// This file is automatically generated at:2019-12-10 10:17:59
|
||||||
declare (strict_types = 1);
|
declare (strict_types = 1);
|
||||||
return array (
|
return array (
|
||||||
0 => 'think\\app\\Service',
|
0 => 'think\\app\\Service',
|
||||||
|
@ -100,9 +100,9 @@ if (!function_exists('sysdata')) {
|
|||||||
function sysdata($name, $value = null)
|
function sysdata($name, $value = null)
|
||||||
{
|
{
|
||||||
if (is_null($value)) {
|
if (is_null($value)) {
|
||||||
return SystemService::instance()->get($name);
|
return SystemService::instance()->getData($name);
|
||||||
} else {
|
} else {
|
||||||
return SystemService::instance()->set($name, $value);
|
return SystemService::instance()->setData($name, $value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ class TokenService extends Service
|
|||||||
// 读取缓存并检查是否有效
|
// 读取缓存并检查是否有效
|
||||||
$cache = $this->app->session->get($token, []);
|
$cache = $this->app->session->get($token, []);
|
||||||
if (empty($cache['node']) || empty($cache['time']) || empty($cache['token'])) return false;
|
if (empty($cache['node']) || empty($cache['time']) || empty($cache['token'])) return false;
|
||||||
if ($cache['token'] !== $token || $cache['time'] + 600 < time() || $cache['node'] !== $node) return false;
|
if ($cache['time'] + 600 < time() || strtolower($cache['node']) !== strtolower($node)) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user