Ajax.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | A3Mall
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2020 http://www.a3-mall.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: xzncit <158373108@qq.com>
  8. // +----------------------------------------------------------------------
  9. namespace app\api\controller;
  10. use Endroid\QrCode\QrCode;
  11. use think\facade\Request;
  12. use app\common\models\Setting as SettingModel;
  13. use app\api\service\Version as VersionService;
  14. class Ajax {
  15. /**
  16. * 返回备案信息
  17. * @return \think\response\Json
  18. */
  19. public function copy(){
  20. return json([
  21. "status"=>1,"info"=>"ok",
  22. "data"=>SettingModel::getArrayData("copyright")["copyright"]??[]
  23. ]);
  24. }
  25. /**
  26. * 获取二维码
  27. * @throws \Endroid\QrCode\Exceptions\ImageFunctionFailedException
  28. * @throws \Endroid\QrCode\Exceptions\ImageFunctionUnknownException
  29. * @throws \Endroid\QrCode\Exceptions\ImageTypeInvalidException
  30. */
  31. public function qrcode(){
  32. $data = trim(Request::param("data","","urldecode"));
  33. $content = empty($data) ? "text" : $data;
  34. $qr = new QrCode();
  35. $qr->setText($content)->setSize(300)->setPadding(10)->setImageType('png');
  36. return \think\Response::create($qr->get(),"html", 200, [
  37. 'Content-Type' => $qr->getContentType()
  38. ])->send();
  39. }
  40. /**
  41. * APP升级
  42. * @return \think\response\Json
  43. */
  44. public function update(){
  45. try {
  46. return json(VersionService::getData(Request::param()));
  47. }catch (\Exception $ex){
  48. return json(["status"=>0,"info"=>"ok"]);
  49. }
  50. }
  51. }