From 7e9547dc6a6a437a9f51605f48d47b8d4b08a73a Mon Sep 17 00:00:00 2001
From: macbook <418170129@qq.com>
Date: Sun, 7 Feb 2021 20:37:57 +0800
Subject: [PATCH] 1

---
 application/api/controller/User.php |  9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/application/api/controller/User.php b/application/api/controller/User.php
index c12c3b5..ce2fa2e 100644
--- a/application/api/controller/User.php
+++ b/application/api/controller/User.php
@@ -596,22 +596,21 @@ class User extends Base
         $avatar_url = !empty($user['avatar']) ? cdnurl($user['avatar']) : '';
         empty($avatar_url) && $this->error('请先上传头像');
         !url_exists($avatar_url) && $this->error('头像失效,请更新头像');
-        // // 本地路径
+        // 本地路径
         $dir = 'uploads/user';
         if (!file_exists($dir)){
             mkdir($dir,0777,true);
         }
 
         // 用户小程序码
-        $qrcode = $dir.'/qrcode_'.$user['id'].'.jpg';
+        $qrcode = $dir.'/qrcode_'.$user['id'].'.png';
         if(!file_exists($qrcode)){
-            $wechat = new Wechat('wxMiniProgram');
-            $response = $wechat->getApp()->app_code->getUnlimit($user['id'], [
+            $response = new Wechat('wxMiniProgram')->app_code->getUnlimit($user['id'], [
                'page'  => 'pages/vip/vip',
                'width' => 280, //最小宽度280
             ]);
             if ($response instanceof \EasyWeChat\Kernel\Http\StreamResponse) {
-               $response->save($qrcode);
+               $response->saveAs($dir, str_replace($dir.'/','',$qrcode));
             }
             // 280不满足,再缩小
             \think\Image::open($qrcode)->thumb(64,64)->save($qrcode);
--
libgit2 0.24.0