lqmac 11 months ago
parent 00f64e915c
commit 6920331835
  1. 29
      app/api/controller/User.php
  2. 3
      app/common/service/qrcode/BaseQRcode.php

@ -350,6 +350,35 @@ class User extends Controller
UserModel::where('user_id', $user_id)->update($params); UserModel::where('user_id', $user_id)->update($params);
return $this->renderSuccess('ok'); 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));
}

@ -115,7 +115,8 @@ class BaseQRcode extends BaseService
private function getFilePath(int $storeId, string $scene, string $page = null, string $channel = 'H5'): string 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); !is_dir($dirPath) && mkdir($dirPath, 0755, true);
// 文件名称 // 文件名称
$fileName = 'qrcode_' . md5("{$storeId}{$scene}{$page}-{$channel}") . '.png'; $fileName = 'qrcode_' . md5("{$storeId}{$scene}{$page}-{$channel}") . '.png';

Loading…
Cancel
Save