From 951f9d1dbf1f85c715cb473d844ccc8a9d218c12 Mon Sep 17 00:00:00 2001
From: Anyon <zoujingli@qq.com>
Date: Mon, 9 Dec 2019 18:51:25 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BE=AE=E4=BF=A1=E6=A8=A1?=
 =?UTF-8?q?=E5=9D=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 app/wechat/controller/api/Js.php       |  8 ++++----
 app/wechat/controller/api/Push.php     | 18 ++++++++----------
 app/wechat/view/fans/index_search.html | 17 +++++++----------
 app/wechat/view/keys/index_search.html | 15 ++++++---------
 4 files changed, 25 insertions(+), 33 deletions(-)

diff --git a/app/wechat/controller/api/Js.php b/app/wechat/controller/api/Js.php
index 20fdb5bc7..70e25ef83 100644
--- a/app/wechat/controller/api/Js.php
+++ b/app/wechat/controller/api/Js.php
@@ -39,11 +39,11 @@ class Js extends Controller
     public function index()
     {
         $url = $this->request->server('http_referer', $this->request->url(true));
-        $wechat = WechatService::instance()->getWebOauthInfo($url, $this->request->get('mode', 1), false);
-        $openid = isset($wechat['openid']) ? $wechat['openid'] : '';
-        $unionid = empty($wechat['fansinfo']['unionid']) ? '' : $wechat['fansinfo']['unionid'];
+        $user = WechatService::instance()->getWebOauthInfo($url, $this->request->get('mode', 1), false);
+        $openid = isset($user['openid']) ? $user['openid'] : '';
+        $unionid = empty($user['fansinfo']['unionid']) ? '' : $user['fansinfo']['unionid'];
         $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
 if(typeof wx === 'object'){
     wx.openid="{$openid}";
diff --git a/app/wechat/controller/api/Push.php b/app/wechat/controller/api/Push.php
index 197e71848..fa2876e96 100644
--- a/app/wechat/controller/api/Push.php
+++ b/app/wechat/controller/api/Push.php
@@ -145,6 +145,7 @@ class Push extends Controller
      * @throws \WeChat\Exceptions\LocalCacheException
      * @throws \think\Exception
      * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
      * @throws \think\db\exception\ModelNotFoundException
      */
     protected function text()
@@ -202,9 +203,8 @@ class Push extends Controller
      * @throws \WeChat\Exceptions\LocalCacheException
      * @throws \think\Exception
      * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
      * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
-     * @throws \think\exception\PDOException
      */
     private function keys($rule, $isLast = false, $isCustom = false)
     {
@@ -222,30 +222,30 @@ class Push extends Controller
             case 'customservice':
                 return $this->sendMessage('customservice', ['content' => $data['content']], false);
             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);
             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);
             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;
                 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'],
                 ]);
                 return $this->sendMessage('news', ['articles' => $articles], $isCustom);
             case 'music':
                 if (empty($data['music_url']) || empty($data['music_title']) || empty($data['music_desc'])) return false;
                 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'],
                     'hqmusicurl'     => $data['music_url'], 'musicurl' => $data['music_url'],
                 ], $isCustom);
             case 'video':
                 if (empty($data['video_url']) || empty($data['video_desc']) || empty($data['video_title'])) return false;
                 $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);
             default:
                 return false;
@@ -261,8 +261,6 @@ class Push extends Controller
      * @throws \WeChat\Exceptions\InvalidDecryptException
      * @throws \WeChat\Exceptions\InvalidResponseException
      * @throws \WeChat\Exceptions\LocalCacheException
-     * @throws \think\Exception
-     * @throws \think\exception\PDOException
      */
     private function sendMessage($type, $data, $isCustom = false)
     {
diff --git a/app/wechat/view/fans/index_search.html b/app/wechat/view/fans/index_search.html
index 23e5612fb..078c06906 100644
--- a/app/wechat/view/fans/index_search.html
+++ b/app/wechat/view/fans/index_search.html
@@ -5,7 +5,7 @@
         <div class="layui-form-item layui-inline">
             <label class="layui-form-label">微信昵称</label>
             <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>
 
@@ -14,11 +14,11 @@
             <div class="layui-input-inline">
                 <select class="layui-select" name="subscribe">
                     {foreach [''=>'-- 全部 --','0'=>'显示未关注的粉丝','1'=>'显示已关注的粉丝'] as $k=>$v}
-                    {eq name='Think.get.subscribe' value='$k.""'}
+                    {if $k.'' eq input('subscribe')}
                     <option selected value="{$k}">{$v}</option>
                     {else}
                     <option value="{$k}">{$v}</option>
-                    {/eq}
+                    {/if}
                     {/foreach}
                 </select>
             </div>
@@ -29,11 +29,11 @@
             <div class="layui-input-inline">
                 <select class="layui-select" name="is_black">
                     {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>
                     {else}
                     <option value="{$k}">{$v}</option>
-                    {/eq}
+                    {/if}
                     {/foreach}
                 </select>
             </div>
@@ -42,7 +42,7 @@
         <div class="layui-form-item layui-inline">
             <label class="layui-form-label">关注时间</label>
             <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>
 
@@ -53,7 +53,4 @@
 
 </fieldset>
 
-<script>
-    window.form.render();
-    window.laydate.render({range: true, elem: '[name="subscribe_at"]'});
-</script>
+<script>window.form.render()</script>
diff --git a/app/wechat/view/keys/index_search.html b/app/wechat/view/keys/index_search.html
index a716b9ba2..ad3ad7fff 100644
--- a/app/wechat/view/keys/index_search.html
+++ b/app/wechat/view/keys/index_search.html
@@ -13,11 +13,11 @@
                 <select class="layui-select" name="type">
                     <option value="">-- 全部 --</option>
                     {foreach $types as $k=>$v}
-                    {eq name='Think.get.type' value='$k.""'}
+                    {if $k.'' eq input('type')}
                     <option selected value="{$k}">{$v}</option>
                     {else}
                     <option value="{$k}">{$v}</option>
-                    {/eq}
+                    {/if}
                     {/foreach}
                 </select>
             </div>
@@ -27,11 +27,11 @@
             <div class="layui-input-inline">
                 <select class="layui-select" name="status">
                     {foreach [''=>'-- 全部 --','0'=>'显示使用的规则','1'=>'显示禁止的规则'] as $k=>$v}
-                    {eq name='Think.get.status' value='$k.""'}
+                    {if $k.'' eq input('status')}
                     <option selected value="{$k}">{$v}</option>
                     {else}
                     <option value="{$k}">{$v}</option>
-                    {/eq}
+                    {/if}
                     {/foreach}
                 </select>
             </div>
@@ -39,7 +39,7 @@
         <div class="layui-form-item layui-inline">
             <label class="layui-form-label">创建时间</label>
             <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 class="layui-form-item layui-inline">
@@ -48,7 +48,4 @@
     </form>
 </fieldset>
 
-<script>
-    window.form.render();
-    window.laydate.render({range: true, elem: '[name="create_at"]'});
-</script>
+<script>window.form.render()</script>