HomeController.php 2.5 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\api\controller\pc;
  12. use app\services\pc\HomeServices;
  13. use app\services\other\QrcodeServices;
  14. /**
  15. * Class HomeController
  16. * @package app\api\controller\pc
  17. */
  18. class HomeController
  19. {
  20. /**
  21. *
  22. * @var HomeServices
  23. */
  24. protected $services;
  25. /**
  26. * HomeController constructor.
  27. * @param HomeServices $services
  28. */
  29. public function __construct(HomeServices $services)
  30. {
  31. $this->services = $services;
  32. }
  33. /**
  34. * PC端首页轮播图
  35. * @return mixed
  36. */
  37. public function getBanner()
  38. {
  39. $list = sys_data('pc_home_banner');
  40. return app('json')->successful(compact('list'));
  41. }
  42. /**
  43. * 首页分类尚品
  44. * @return mixed
  45. */
  46. public function getCategoryProduct()
  47. {
  48. $data = $this->services->getCategoryProduct();
  49. return app('json')->successful($data);
  50. }
  51. /**
  52. * 获取手机购买跳转url配置
  53. * @return string
  54. */
  55. public function getProductPhoneBuy()
  56. {
  57. $phoneBuy = sys_config('product_phone_buy_url', 1);
  58. $siteUrl = sys_config('site_url');
  59. return app('json')->successful(['phone_buy' => $phoneBuy, 'sit_url' => $siteUrl]);
  60. }
  61. /**
  62. * 付费会员购买二维码
  63. * @return mixed
  64. */
  65. public function getPayVipCode()
  66. {
  67. $type = sys_config('product_phone_buy_url', 1);
  68. $url = '/pages/annex/vip_paid/index';
  69. $name = "wechat_pay_vip_code.png";
  70. /** @var QrcodeServices $QrcodeService */
  71. $QrcodeService = app()->make(QrcodeServices::class);
  72. if ($type == 1) {
  73. $codeUrl = $QrcodeService->getWechatQrcodePath($name, $url, false, false);
  74. } else {
  75. //生成小程序地址
  76. $codeUrl = $QrcodeService->getRoutineQrcodePath(0, 0, 5, [], false);
  77. }
  78. return app('json')->successful(['url' => $codeUrl ?: '']);
  79. }
  80. }