HomeController.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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\pc\HomeServices;
  14. use app\services\other\QrcodeServices;
  15. use crmeb\services\SystemConfigService;
  16. /**
  17. * Class HomeController
  18. * @package app\controller\api\pc
  19. */
  20. class HomeController
  21. {
  22. /**
  23. *
  24. * @var HomeServices
  25. */
  26. protected $services;
  27. /**
  28. * HomeController constructor.
  29. * @param HomeServices $services
  30. */
  31. public function __construct(HomeServices $services)
  32. {
  33. $this->services = $services;
  34. }
  35. /**
  36. * PC端首页轮播图
  37. * @return mixed
  38. */
  39. public function getBanner()
  40. {
  41. $list = sys_data('pc_home_banner');
  42. return app('json')->successful(compact('list'));
  43. }
  44. /**
  45. * 首页分类尚品
  46. * @return mixed
  47. */
  48. public function getCategoryProduct(Request $request)
  49. {
  50. $data = $this->services->getCategoryProduct((int)$request->uid());
  51. return app('json')->successful($data);
  52. }
  53. /**
  54. * 获取手机购买跳转url配置
  55. * @return string
  56. */
  57. public function getProductPhoneBuy()
  58. {
  59. $data = SystemConfigService::more(['product_phone_buy_url', 'site_url']);
  60. return app('json')->successful(['phone_buy' => $data['product_phone_buy_url'] ?? 1, 'sit_url' => $data['site_url'] ?? '']);
  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')->successful(['url' => $codeUrl ? $codeUrl : '']);
  80. }
  81. }