mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
[更新]优化微信关键字二维码生成显示
This commit is contained in:
parent
d30f2c0423
commit
91c8d3a1bb
@ -38,14 +38,23 @@ class Keys extends BasicAdmin
|
||||
/**
|
||||
* 显示关键字列表
|
||||
* @return array|string
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws \think\Exception
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
* @throws \think\Exception
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->assign('title', '微信关键字');
|
||||
// 关键字二维码显示
|
||||
if ($this->request->get('action') === 'qrc') {
|
||||
$wechat = WechatService::qrcode();
|
||||
$result = $wechat->create($this->request->get('keys', ''));
|
||||
$this->redirect($wechat->url($result['ticket']));
|
||||
}
|
||||
// 显示关键字列表
|
||||
$this->title = '微信关键字管理';
|
||||
$db = Db::name($this->table)->whereNotIn('keys', ['subscribe', 'default']);
|
||||
return $this->_list($db->order('sort asc,id desc'));
|
||||
}
|
||||
@ -56,15 +65,13 @@ class Keys extends BasicAdmin
|
||||
*/
|
||||
protected function _index_data_filter(&$data)
|
||||
{
|
||||
$types = [
|
||||
'keys' => '关键字', 'image' => '图片', 'news' => '图文',
|
||||
'music' => '音乐', 'text' => '文字', 'video' => '视频', 'voice' => '语音',
|
||||
];
|
||||
try {
|
||||
$wechat = WechatService::qrcode();
|
||||
$types = [
|
||||
'keys' => '关键字', 'image' => '图片', 'news' => '图文',
|
||||
'music' => '音乐', 'text' => '文字', 'video' => '视频', 'voice' => '语音',
|
||||
];
|
||||
foreach ($data as &$vo) {
|
||||
$result = $wechat->create($vo['keys']);
|
||||
$vo['qrc'] = $wechat->url($result['ticket']);
|
||||
$vo['qrc'] = url('@wechat/keys/index') . "?action=qrc&keys={$vo['keys']}";
|
||||
$vo['type'] = isset($types[$vo['type']]) ? $types[$vo['type']] : $vo['type'];
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
|
@ -616,7 +616,7 @@ $(function () {
|
||||
|
||||
/*! 注册 data-tips-image 事件行为 */
|
||||
$body.on('click', '[data-tips-image]', function () {
|
||||
var img = new Image(), src = this.getAttribute('data-tips-image') || this.src;
|
||||
var img = new Image(), index = $.msg.loading();
|
||||
var imgWidth = this.getAttribute('data-width') || '480px';
|
||||
img.onload = function () {
|
||||
var $content = $(img).appendTo('body').css({background: '#fff', width: imgWidth, height: 'auto'});
|
||||
@ -625,10 +625,13 @@ $(function () {
|
||||
skin: 'layui-layer-nobg', shadeClose: true, content: $content,
|
||||
end: function () {
|
||||
$(img).remove();
|
||||
},
|
||||
success: function () {
|
||||
$.msg.close(index);
|
||||
}
|
||||
});
|
||||
};
|
||||
img.src = src;
|
||||
img.src = this.getAttribute('data-tips-image') || this.src;
|
||||
});
|
||||
|
||||
/*! 注册 data-tips-text 事件行为 */
|
||||
|
Loading…
x
Reference in New Issue
Block a user