mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
修改微信模块
This commit is contained in:
parent
37bc7f8a96
commit
951f9d1dbf
@ -39,11 +39,11 @@ class Js extends Controller
|
|||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$url = $this->request->server('http_referer', $this->request->url(true));
|
$url = $this->request->server('http_referer', $this->request->url(true));
|
||||||
$wechat = WechatService::instance()->getWebOauthInfo($url, $this->request->get('mode', 1), false);
|
$user = WechatService::instance()->getWebOauthInfo($url, $this->request->get('mode', 1), false);
|
||||||
$openid = isset($wechat['openid']) ? $wechat['openid'] : '';
|
$openid = isset($user['openid']) ? $user['openid'] : '';
|
||||||
$unionid = empty($wechat['fansinfo']['unionid']) ? '' : $wechat['fansinfo']['unionid'];
|
$unionid = empty($user['fansinfo']['unionid']) ? '' : $user['fansinfo']['unionid'];
|
||||||
$configJson = json_encode(WechatService::instance()->getWebJssdkSign($url), JSON_UNESCAPED_UNICODE);
|
$configJson = json_encode(WechatService::instance()->getWebJssdkSign($url), JSON_UNESCAPED_UNICODE);
|
||||||
$fansinfoJson = json_encode(isset($wechat['fansinfo']) ? $wechat['fansinfo'] : [], JSON_UNESCAPED_UNICODE);
|
$fansinfoJson = json_encode(isset($user['fansinfo']) ? $user['fansinfo'] : [], JSON_UNESCAPED_UNICODE);
|
||||||
$html = <<<EOF
|
$html = <<<EOF
|
||||||
if(typeof wx === 'object'){
|
if(typeof wx === 'object'){
|
||||||
wx.openid="{$openid}";
|
wx.openid="{$openid}";
|
||||||
|
@ -145,6 +145,7 @@ class Push extends Controller
|
|||||||
* @throws \WeChat\Exceptions\LocalCacheException
|
* @throws \WeChat\Exceptions\LocalCacheException
|
||||||
* @throws \think\Exception
|
* @throws \think\Exception
|
||||||
* @throws \think\db\exception\DataNotFoundException
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
* @throws \think\db\exception\ModelNotFoundException
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
*/
|
*/
|
||||||
protected function text()
|
protected function text()
|
||||||
@ -202,9 +203,8 @@ class Push extends Controller
|
|||||||
* @throws \WeChat\Exceptions\LocalCacheException
|
* @throws \WeChat\Exceptions\LocalCacheException
|
||||||
* @throws \think\Exception
|
* @throws \think\Exception
|
||||||
* @throws \think\db\exception\DataNotFoundException
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
* @throws \think\db\exception\ModelNotFoundException
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
* @throws \think\exception\DbException
|
|
||||||
* @throws \think\exception\PDOException
|
|
||||||
*/
|
*/
|
||||||
private function keys($rule, $isLast = false, $isCustom = false)
|
private function keys($rule, $isLast = false, $isCustom = false)
|
||||||
{
|
{
|
||||||
@ -222,30 +222,30 @@ class Push extends Controller
|
|||||||
case 'customservice':
|
case 'customservice':
|
||||||
return $this->sendMessage('customservice', ['content' => $data['content']], false);
|
return $this->sendMessage('customservice', ['content' => $data['content']], false);
|
||||||
case 'voice':
|
case 'voice':
|
||||||
if (empty($data['voice_url']) || !($mediaId = MediaService::upload($data['voice_url'], 'voice'))) return false;
|
if (empty($data['voice_url']) || !($mediaId = MediaService::instance()->upload($data['voice_url'], 'voice'))) return false;
|
||||||
return $this->sendMessage('voice', ['media_id' => $mediaId], $isCustom);
|
return $this->sendMessage('voice', ['media_id' => $mediaId], $isCustom);
|
||||||
case 'image':
|
case 'image':
|
||||||
if (empty($data['image_url']) || !($mediaId = MediaService::upload($data['image_url'], 'image'))) return false;
|
if (empty($data['image_url']) || !($mediaId = MediaService::instance()->upload($data['image_url'], 'image'))) return false;
|
||||||
return $this->sendMessage('image', ['media_id' => $mediaId], $isCustom);
|
return $this->sendMessage('image', ['media_id' => $mediaId], $isCustom);
|
||||||
case 'news':
|
case 'news':
|
||||||
list($news, $articles) = [MediaService::news($data['news_id']), []];
|
list($news, $articles) = [MediaService::instance()->news($data['news_id']), []];
|
||||||
if (empty($news['articles'])) return false;
|
if (empty($news['articles'])) return false;
|
||||||
foreach ($news['articles'] as $vo) array_push($articles, [
|
foreach ($news['articles'] as $vo) array_push($articles, [
|
||||||
'url' => url("@wechat/api.review/view", '', false, true) . "?id={$vo['id']}",
|
'url' => url("@wechat/api.review/view", [], false, true) . "?id={$vo['id']}",
|
||||||
'title' => $vo['title'], 'picurl' => $vo['local_url'], 'description' => $vo['digest'],
|
'title' => $vo['title'], 'picurl' => $vo['local_url'], 'description' => $vo['digest'],
|
||||||
]);
|
]);
|
||||||
return $this->sendMessage('news', ['articles' => $articles], $isCustom);
|
return $this->sendMessage('news', ['articles' => $articles], $isCustom);
|
||||||
case 'music':
|
case 'music':
|
||||||
if (empty($data['music_url']) || empty($data['music_title']) || empty($data['music_desc'])) return false;
|
if (empty($data['music_url']) || empty($data['music_title']) || empty($data['music_desc'])) return false;
|
||||||
return $this->sendMessage('music', [
|
return $this->sendMessage('music', [
|
||||||
'thumb_media_id' => empty($data['music_image']) ? '' : MediaService::upload($data['music_image'], 'image'),
|
'thumb_media_id' => empty($data['music_image']) ? '' : MediaService::instance()->upload($data['music_image'], 'image'),
|
||||||
'description' => $data['music_desc'], 'title' => $data['music_title'],
|
'description' => $data['music_desc'], 'title' => $data['music_title'],
|
||||||
'hqmusicurl' => $data['music_url'], 'musicurl' => $data['music_url'],
|
'hqmusicurl' => $data['music_url'], 'musicurl' => $data['music_url'],
|
||||||
], $isCustom);
|
], $isCustom);
|
||||||
case 'video':
|
case 'video':
|
||||||
if (empty($data['video_url']) || empty($data['video_desc']) || empty($data['video_title'])) return false;
|
if (empty($data['video_url']) || empty($data['video_desc']) || empty($data['video_title'])) return false;
|
||||||
$videoData = ['title' => $data['video_title'], 'introduction' => $data['video_desc']];
|
$videoData = ['title' => $data['video_title'], 'introduction' => $data['video_desc']];
|
||||||
if (!($mediaId = MediaService::upload($data['video_url'], 'video', $videoData))) return false;
|
if (!($mediaId = MediaService::instance()->upload($data['video_url'], 'video', $videoData))) return false;
|
||||||
return $this->sendMessage('video', ['media_id' => $mediaId, 'title' => $data['video_title'], 'description' => $data['video_desc']], $isCustom);
|
return $this->sendMessage('video', ['media_id' => $mediaId, 'title' => $data['video_title'], 'description' => $data['video_desc']], $isCustom);
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
@ -261,8 +261,6 @@ class Push extends Controller
|
|||||||
* @throws \WeChat\Exceptions\InvalidDecryptException
|
* @throws \WeChat\Exceptions\InvalidDecryptException
|
||||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||||
* @throws \WeChat\Exceptions\LocalCacheException
|
* @throws \WeChat\Exceptions\LocalCacheException
|
||||||
* @throws \think\Exception
|
|
||||||
* @throws \think\exception\PDOException
|
|
||||||
*/
|
*/
|
||||||
private function sendMessage($type, $data, $isCustom = false)
|
private function sendMessage($type, $data, $isCustom = false)
|
||||||
{
|
{
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<div class="layui-form-item layui-inline">
|
<div class="layui-form-item layui-inline">
|
||||||
<label class="layui-form-label">微信昵称</label>
|
<label class="layui-form-label">微信昵称</label>
|
||||||
<div class="layui-input-inline">
|
<div class="layui-input-inline">
|
||||||
<input name="nickname" value="{$Think.get.nickname|default=''}" placeholder="请输入微信昵称" class="layui-input">
|
<input name="nickname" value="{:input('nickname')}" placeholder="请输入微信昵称" class="layui-input">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -14,11 +14,11 @@
|
|||||||
<div class="layui-input-inline">
|
<div class="layui-input-inline">
|
||||||
<select class="layui-select" name="subscribe">
|
<select class="layui-select" name="subscribe">
|
||||||
{foreach [''=>'-- 全部 --','0'=>'显示未关注的粉丝','1'=>'显示已关注的粉丝'] as $k=>$v}
|
{foreach [''=>'-- 全部 --','0'=>'显示未关注的粉丝','1'=>'显示已关注的粉丝'] as $k=>$v}
|
||||||
{eq name='Think.get.subscribe' value='$k.""'}
|
{if $k.'' eq input('subscribe')}
|
||||||
<option selected value="{$k}">{$v}</option>
|
<option selected value="{$k}">{$v}</option>
|
||||||
{else}
|
{else}
|
||||||
<option value="{$k}">{$v}</option>
|
<option value="{$k}">{$v}</option>
|
||||||
{/eq}
|
{/if}
|
||||||
{/foreach}
|
{/foreach}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@ -29,11 +29,11 @@
|
|||||||
<div class="layui-input-inline">
|
<div class="layui-input-inline">
|
||||||
<select class="layui-select" name="is_black">
|
<select class="layui-select" name="is_black">
|
||||||
{foreach [''=>'-- 全部 --','0'=>'显示未拉黑的粉丝','1'=>'显示已拉黑的粉丝'] as $k=>$v}
|
{foreach [''=>'-- 全部 --','0'=>'显示未拉黑的粉丝','1'=>'显示已拉黑的粉丝'] as $k=>$v}
|
||||||
{eq name='Think.get.is_black' value='$k.""'}
|
{if $k.'' eq input('is_black')}
|
||||||
<option selected value="{$k}">{$v}</option>
|
<option selected value="{$k}">{$v}</option>
|
||||||
{else}
|
{else}
|
||||||
<option value="{$k}">{$v}</option>
|
<option value="{$k}">{$v}</option>
|
||||||
{/eq}
|
{/if}
|
||||||
{/foreach}
|
{/foreach}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@ -42,7 +42,7 @@
|
|||||||
<div class="layui-form-item layui-inline">
|
<div class="layui-form-item layui-inline">
|
||||||
<label class="layui-form-label">关注时间</label>
|
<label class="layui-form-label">关注时间</label>
|
||||||
<div class="layui-input-inline">
|
<div class="layui-input-inline">
|
||||||
<input name="subscribe_at" value="{$Think.get.subscribe_at|default=''}" placeholder="请选择关注时间" class="layui-input">
|
<input data-date-range name="subscribe_at" value="{:input('subscribe_at')}" placeholder="请选择关注时间" class="layui-input">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -53,7 +53,4 @@
|
|||||||
|
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<script>
|
<script>window.form.render()</script>
|
||||||
window.form.render();
|
|
||||||
window.laydate.render({range: true, elem: '[name="subscribe_at"]'});
|
|
||||||
</script>
|
|
||||||
|
@ -13,11 +13,11 @@
|
|||||||
<select class="layui-select" name="type">
|
<select class="layui-select" name="type">
|
||||||
<option value="">-- 全部 --</option>
|
<option value="">-- 全部 --</option>
|
||||||
{foreach $types as $k=>$v}
|
{foreach $types as $k=>$v}
|
||||||
{eq name='Think.get.type' value='$k.""'}
|
{if $k.'' eq input('type')}
|
||||||
<option selected value="{$k}">{$v}</option>
|
<option selected value="{$k}">{$v}</option>
|
||||||
{else}
|
{else}
|
||||||
<option value="{$k}">{$v}</option>
|
<option value="{$k}">{$v}</option>
|
||||||
{/eq}
|
{/if}
|
||||||
{/foreach}
|
{/foreach}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@ -27,11 +27,11 @@
|
|||||||
<div class="layui-input-inline">
|
<div class="layui-input-inline">
|
||||||
<select class="layui-select" name="status">
|
<select class="layui-select" name="status">
|
||||||
{foreach [''=>'-- 全部 --','0'=>'显示使用的规则','1'=>'显示禁止的规则'] as $k=>$v}
|
{foreach [''=>'-- 全部 --','0'=>'显示使用的规则','1'=>'显示禁止的规则'] as $k=>$v}
|
||||||
{eq name='Think.get.status' value='$k.""'}
|
{if $k.'' eq input('status')}
|
||||||
<option selected value="{$k}">{$v}</option>
|
<option selected value="{$k}">{$v}</option>
|
||||||
{else}
|
{else}
|
||||||
<option value="{$k}">{$v}</option>
|
<option value="{$k}">{$v}</option>
|
||||||
{/eq}
|
{/if}
|
||||||
{/foreach}
|
{/foreach}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@ -39,7 +39,7 @@
|
|||||||
<div class="layui-form-item layui-inline">
|
<div class="layui-form-item layui-inline">
|
||||||
<label class="layui-form-label">创建时间</label>
|
<label class="layui-form-label">创建时间</label>
|
||||||
<div class="layui-input-inline">
|
<div class="layui-input-inline">
|
||||||
<input name="create_at" value="{$Think.get.create_at|default=''}" placeholder="请选择创建时间" class="layui-input">
|
<input data-date-range name="create_at" value="{$Think.get.create_at|default=''}" placeholder="请选择创建时间" class="layui-input">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-form-item layui-inline">
|
<div class="layui-form-item layui-inline">
|
||||||
@ -48,7 +48,4 @@
|
|||||||
</form>
|
</form>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<script>
|
<script>window.form.render()</script>
|
||||||
window.form.render();
|
|
||||||
window.laydate.render({range: true, elem: '[name="create_at"]'});
|
|
||||||
</script>
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user