天天看点

EasyWeChat生成小程序码

//生成小程序支付码
  $path='pages/user/u_getcar/u_getcar';
  $param='type=0&id='.$id.'&p='.$proofnumber;//订单id    
  
private function  getcode($param,$path)
    {
         $response = $this->app->app_code->getUnlimit($param, [
                'page'  => $path,
                'width' => 800,
            ]);
        //二维码
        $filename=time().'_wx.jpg';
        //判断file文件中是否存在数据库当中
        $qr_path = './uploads/qrcode';
        // if(!is_dir('.'.$qr_path)){								//	./Public/Qrcode/
        //     mkdir(iconv("GBK","UTF-8",'.'.$qr_path),0777,true);
        // }
        // 保存小程序码到文件
        $resfilename='';
          if ($response instanceof \EasyWeChat\Kernel\Http\StreamResponse) {
            $resfilename = $response->saveAs($qr_path,$filename);
            $resfilename=trim($qr_path.'/'.$resfilename,'.');
        }
        return $resfilename;
    }


           

继续阅读