Index.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace app\api\controller;
  3. use app\api\model\CommodityModel;
  4. use app\common\controller\Api;
  5. use think\Cache;
  6. use think\Db;
  7. /**
  8. * 首页接口
  9. */
  10. class Index extends Api
  11. {
  12. protected $noNeedLogin = ['*'];
  13. protected $noNeedRight = ['*'];
  14. /**
  15. * 首页轮播图
  16. *
  17. */
  18. public function Chart()
  19. {
  20. $data = Db::name('chart')->select();
  21. if ($data) {
  22. return $this->result('', $data, 200);
  23. } else {
  24. return $this->result('暂无图片',[],100);
  25. }
  26. }
  27. /**
  28. * 首页推荐商品
  29. *
  30. */
  31. public function indexRecommend () {
  32. $where = array(
  33. 'c_state_switch' => 1,
  34. 'c_recommodity' => 1,
  35. );
  36. $data = CommodityModel::where($where)->select();
  37. if ($data) {
  38. return $this->result('', $data, 200);
  39. } else {
  40. return $this->result('暂无商品',[],100);
  41. }
  42. }
  43. public function index()
  44. {
  45. $params = input();
  46. Cache::set('aaa',$params);
  47. }
  48. public function aa()
  49. {
  50. halt(Cache::get('aaa'));
  51. }
  52. }