diff --git a/app/api/controller/User.php b/app/api/controller/User.php index f12da732..2a0edac7 100644 --- a/app/api/controller/User.php +++ b/app/api/controller/User.php @@ -15,6 +15,7 @@ namespace app\api\controller; use app\api\model\Agreement as AgreementModel; use app\api\model\User as UserModel; use app\api\model\Invite\InviteLog; +use app\common\service\qrcode\BaseQRcode; use app\store\model\User as StoreUserModel; use app\api\model\user\BalanceLog; use app\api\model\user\GoodSource as GoodsSourceModel; @@ -398,6 +399,8 @@ class User extends Controller public function maintenance() { + + $qrObj = new BaseQRcode(); $storeId = request()->header()['storeid']; $list = Db::table('yoshop_maintenance_category') ->where(['store_id' => $storeId, 'status' => 1,]) @@ -409,8 +412,10 @@ class User extends Controller ->select() ->toArray(); } + foreach ($list['tags'] ?? [] as &$item) { + $item['url'] = $qrObj->getOtherQrcode($storeId, $item['url']); + } + return $this->renderSuccess($list); } - - } diff --git a/app/common/service/qrcode/BaseQRcode.php b/app/common/service/qrcode/BaseQRcode.php index b2f3883e..4733661f 100644 --- a/app/common/service/qrcode/BaseQRcode.php +++ b/app/common/service/qrcode/BaseQRcode.php @@ -48,6 +48,16 @@ class BaseQRcode extends BaseService return $this->getH5Qrcode($storeId, $scene, $page, $channel); } + public function getOtherQrcode(int $storeId, string $url, string $channel = 'H5'): string + { + // 根据指定渠道生成不同的二维码 + $savePath = $this->getFilePath($storeId, $url, "", $channel); + if (file_exists($savePath)) return $savePath; + // 生成二维码 + \PHPQRCode\QRcode::png($url, $savePath, 'L', 15, 1); + return $savePath; + } + /** * 保存微二维码到文件 (微信小程序码) * @param int $storeId 商城ID @@ -137,4 +147,4 @@ class BaseQRcode extends BaseService $Download = new Download; return $Download->saveTempImage($storeId, $url, $prefix); } -} \ No newline at end of file +}