diff --git a/app/api/controller/User.php b/app/api/controller/User.php index 71572f14..a7df8240 100644 --- a/app/api/controller/User.php +++ b/app/api/controller/User.php @@ -350,6 +350,35 @@ class User extends Controller UserModel::where('user_id', $user_id)->update($params); return $this->renderSuccess('ok'); } + /** + * 生成会员码 + * [getMembershipInviteQrcode description] + * @return [type] [description] + */ + public function getMembershipInviteQrcode(){ + $user_id = $userInfo = UserService::getCurrentLoginUserId(true); + $obj = new \app\common\service\qrcode\BaseQRcode(); + // 小程序码参数 + $scene = "refereeId:" . $user_id; + $storeId = request()->header()['storeid']; + // 下载小程序码 + $page = 'pages/login/index'; + $qrcode = $obj->getQrcode((int)$storeId, $scene, $page, 'MP-WEIXIN'); + return $this->renderSuccess(str_replace(root_path()."public/", base_url(), $qrcode)); + } + /** + * 生成分销商码 + * [getDealerInviteQrcode description] + * @return [type] [description] + */ + public function getDealerInviteQrcode(){ + $storeId = request()->header()['storeid']; + $user_id = $userInfo = UserService::getCurrentLoginUserId(true); + $obj = new \app\common\service\qrcode\BaseQRcode(); + $scene = 'uid:' . $user_id; + $qrcode = $obj->getQrcode((int)$storeId, $scene, null, 'MP-WEIXIN'); + return $this->renderSuccess(str_replace(root_path()."public/", base_url(), $qrcode)); + } diff --git a/app/common/service/qrcode/BaseQRcode.php b/app/common/service/qrcode/BaseQRcode.php index 68ecb9c9..b2f3883e 100644 --- a/app/common/service/qrcode/BaseQRcode.php +++ b/app/common/service/qrcode/BaseQRcode.php @@ -115,7 +115,8 @@ class BaseQRcode extends BaseService private function getFilePath(int $storeId, string $scene, string $page = null, string $channel = 'H5'): string { // 文件目录 - $dirPath = runtime_root_path() . "image/{$storeId}"; + //$dirPath = runtime_root_path() . "image/{$storeId}"; + $dirPath = root_path()."public/" . "temp/{$storeId}"; !is_dir($dirPath) && mkdir($dirPath, 0755, true); // 文件名称 $fileName = 'qrcode_' . md5("{$storeId}{$scene}{$page}-{$channel}") . '.png';