HomeController.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\api\controller\pc;
  12. use app\Request;
  13. use app\services\pc\HomeServices;
  14. use app\services\other\QrcodeServices;
  15. /**
  16. * Class HomeController
  17. * @package app\api\controller\pc
  18. */
  19. class HomeController
  20. {
  21. /**
  22. *
  23. * @var HomeServices
  24. */
  25. protected $services;
  26. /**
  27. * HomeController constructor.
  28. * @param HomeServices $services
  29. */
  30. public function __construct(HomeServices $services)
  31. {
  32. $this->services = $services;
  33. }
  34. /**
  35. * PC端首页轮播图
  36. * @return mixed
  37. */
  38. public function getBanner()
  39. {
  40. $list = sys_data('pc_home_banner');
  41. return app('json')->success(compact('list'));
  42. }
  43. /**
  44. * 首页分类尚品
  45. * @return mixed
  46. */
  47. public function getCategoryProduct(Request $request)
  48. {
  49. $data = $this->services->getCategoryProduct((int)$request->uid());
  50. return app('json')->success($data);
  51. }
  52. /**
  53. * 获取手机购买跳转url配置
  54. * @return string
  55. */
  56. public function getProductPhoneBuy()
  57. {
  58. $phoneBuy = sys_config('product_phone_buy_url', 1);
  59. $siteUrl = sys_config('site_url');
  60. return app('json')->success(['phone_buy' => $phoneBuy, 'sit_url' => $siteUrl]);
  61. }
  62. /**
  63. * 付费会员购买二维码
  64. * @return mixed
  65. */
  66. public function getPayVipCode()
  67. {
  68. $type = sys_config('product_phone_buy_url', 1);
  69. $url = '/pages/annex/vip_paid/index';
  70. $name = "wechat_pay_vip_code.png";
  71. /** @var QrcodeServices $QrcodeService */
  72. $QrcodeService = app()->make(QrcodeServices::class);
  73. if ($type == 1) {
  74. $codeUrl = $QrcodeService->getWechatQrcodePath($name, $url, false, false);
  75. } else {
  76. //生成小程序地址
  77. $codeUrl = $QrcodeService->getRoutineQrcodePath(0, 0, 5, [], false);
  78. }
  79. return app('json')->success(['url' => $codeUrl ?: '']);
  80. }
  81. }