PublicController.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace app\api\controller;
  3. use app\models\page\PageModel;
  4. use app\Request;
  5. use think\db\exception\DataNotFoundException;
  6. use think\db\exception\DbException;
  7. use think\db\exception\ModelNotFoundException;
  8. /**
  9. * 公共类
  10. * Class PublicController
  11. * @package app\api\controller
  12. */
  13. class PublicController
  14. {
  15. /**
  16. * @param Request $request
  17. * @return mixed
  18. * @throws DataNotFoundException
  19. * @throws ModelNotFoundException
  20. * @throws DbException
  21. */
  22. public function index(Request $request)
  23. {
  24. $banner = sys_data('home_banner', 0, 1) ?: [];//TODO 首页轮播图
  25. $menus = sys_data('home_menus', 0, 1) ?: [];//TODO 首页导航
  26. $pics = sys_data('home_pis', 0, 1) ?: [];//TODO 首页展示图
  27. $tengxun_map_key = sys_config('tengxun_map_key', '');
  28. return app('json')->successful(compact('banner', 'menus', 'pics', 'tengxun_map_key'));
  29. }
  30. public function page($unique)
  31. {
  32. $info = PageModel::where('is_del', 0)->where('unique', $unique)->find()->toArray();
  33. return app('json')->successful($info);
  34. }
  35. /**
  36. * 获取分享配置
  37. * @param Request $request
  38. * @return mixed
  39. */
  40. public function share(Request $request)
  41. {
  42. $mer_id = $request->mer_id();
  43. $data['img'] = sys_config('wechat_share_img', '', $mer_id);
  44. if (strstr($data['img'], 'http') === false) $data['img'] = sys_config('site_url', '', $mer_id) . $data['img'];
  45. $data['img'] = str_replace('\\', '/', $data['img']);
  46. $data['title'] = sys_config('wechat_share_title', '', $mer_id);
  47. $data['synopsis'] = sys_config('wechat_share_synopsis', '', $mer_id);
  48. return app('json')->successful(compact('data'));
  49. }
  50. }