PublicController.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\controller\api\pc;
  12. use app\Request;
  13. use app\services\other\CityAreaServices;
  14. use app\services\pc\PublicServices;
  15. use crmeb\services\SystemConfigService;
  16. class PublicController
  17. {
  18. protected $services;
  19. public function __construct(PublicServices $services)
  20. {
  21. $this->services = $services;
  22. }
  23. /**
  24. * 获取城市数据
  25. * @param Request $request
  26. * @return mixed
  27. */
  28. public function getCity(Request $request, CityAreaServices $services)
  29. {
  30. [$pid] = $request->getMore([
  31. [['pid', 'd'], 0],
  32. ], true);
  33. return app('json')->success($services->getCityTreeList((int)$pid));
  34. }
  35. /**
  36. * 获取公司信息
  37. * @return mixed
  38. */
  39. public function getCompanyInfo()
  40. {
  41. $data = SystemConfigService::more(['contact_number', 'links_open', 'links_list', 'company_address', 'copyright', 'record_No', 'site_name', 'site_keywords', 'site_description', 'pc_logo', 'filing_list']);
  42. $logoUrl = $data['pc_logo'] ?? '';
  43. if (strstr($logoUrl, 'http') === false && $logoUrl) {
  44. $logoUrl = sys_config('site_url') . $logoUrl;
  45. }
  46. $logoUrl = str_replace('\\', '/', $logoUrl);
  47. $data['logoUrl'] = $logoUrl;
  48. if ($data['links_open']) {
  49. $linksList = $data['links_list'];
  50. $linksList = is_array($linksList) ? $linksList : [];
  51. $edition = $volume = [];
  52. foreach ($linksList as $key => $row) {
  53. $volume[$key] = $row['sort'];
  54. $edition[$key] = $row['url'];
  55. }
  56. array_multisort($volume, SORT_DESC, $edition, SORT_ASC, $linksList);
  57. $data['links_list'] = $linksList;
  58. } else {
  59. $data['links_list'] = [];
  60. }
  61. if ($data['filing_list']) {
  62. $filingList = $data['filing_list'];
  63. $filingList = is_array($filingList) ? $filingList : [];
  64. $edition = $volume = [];
  65. foreach ($filingList as $key => $row) {
  66. $volume[$key] = $row['sort'];
  67. $edition[$key] = $row['url'];
  68. }
  69. array_multisort($volume, SORT_DESC, $edition, SORT_ASC, $filingList);
  70. $data['filing_list'] = $filingList;
  71. } else {
  72. $data['filing_list'] = [];
  73. }
  74. return app('json')->successful($data);
  75. }
  76. /**
  77. * 获取关注微信二维码
  78. * @return mixed
  79. */
  80. public function getWechatQrcode()
  81. {
  82. $data['wechat_qrcode'] = sys_config('wechat_qrcode');
  83. return app('json')->successful($data);
  84. }
  85. }