QrcodeController.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace app\api\controller\scan;
  3. use app\model\SysDept;
  4. use support\Request;
  5. class QrcodeController{
  6. public function index(Request $request)
  7. {
  8. $tableId = $request->get('tid','');
  9. if (!empty($tableId)){
  10. $table = SysDept::where('dept_id',$tableId)->where('dept_category','桌台')->first();
  11. if (!$table){
  12. echo "桌台不存在";
  13. exit();
  14. }
  15. $qrcodeContent = [
  16. 'action'=>'scan-dishes',
  17. 'data'=>[
  18. 'premises'=>$table->dept_super_id,
  19. 'table'=>$table->dept_name,
  20. 'dept'=>$table->dept_id
  21. ]
  22. ];
  23. //https://h5.wanyuewellness.com.cn
  24. $url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc6274da7198e3eb4&redirect_uri=".getenv('QRCODE_SCAN_DOMAIN')."%2F%23%2Fpages%2Findex%2FWeChatGuide?scan="
  25. . urlencode(json_encode($qrcodeContent)).
  26. "&response_type=code&scope=snsapi_base&connect_redirect=1&state=#wechat_redirect";
  27. return redirect($url,302);
  28. }
  29. }
  30. }