/**
* 司机专属推广码
*/
public function qrcode()
{
$user = $this->auth->getUser();
if(empty($user['qrcode'])){
$thirdConfig = get_addon_config('litestore');
$config = [
'app_id' => $thirdConfig['AppID'], // 小程序ID
'secret' => $thirdConfig['AppSecret'], // 密码
// 下面为可选项
// 指定 API 调用返回结果的类型:array(default)/collection/object/raw/自定义类名
'response_type' => 'array',
'log' => [
'level' => 'debug',
'file' => __DIR__.'/wechat.log',
],
];
$app = Factory::miniProgram($config);
$response = $app->app_code->getUnlimit('driving_id-'.$this->auth->id, [
'page' => 'pages/login/login_driver',
'width' => 600,
]);
// var_dump($response);die;
// 司机码保存到本地
if ($response instanceof \EasyWeChat\Kernel\Http\StreamResponse) {
$filename = $response->save(ROOT_PATH.'public/uploads/drivingcode');
\app\common\model\User::where('id',$this->auth->id)->update(['qrcode'=>'/uploads/drivingcode/'.$filename]);
}
$this->success('',config('site.siteurl').'/uploads/drivingcode/'.$filename);
} else {
$this->success('',config('site.siteurl').$user['qrcode']);
}
}
fastadmin使用esaywechat生成带参数小程序码
于 2023-12-28 16:07:11 首次发布