Baseconfig.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use think\Db;
  5. use Redis;
  6. /**
  7. * 基础配置接口
  8. */
  9. class Baseconfig extends Api
  10. {
  11. protected $noNeedLogin = ['*'];
  12. protected $noNeedRight = ['*'];
  13. public function index(){
  14. //默认不弹窗,登录了但是没有地址,就弹窗
  15. $add_address = 0;
  16. if($this->auth->isLogin()){
  17. $address = Db::name('unishop_address')->where('user_id',$this->auth->id)->find();
  18. if(empty($address)){
  19. $add_address = 1;
  20. }
  21. }
  22. //首页弹窗商品
  23. $index_show_product = null;
  24. $map = [
  25. 'id' => config('site.index_show_product'),
  26. 'switch' => 1,
  27. 'deletetime' => null,
  28. ];
  29. $index_show_product = Db::name('unishop_product')->field('id,image,title')->where($map)->find();
  30. //结果
  31. $config = [
  32. 'kefu_phone' => config('site.kefuphoneno'),//客服电话号
  33. 'index_add_address' => $add_address, //首页是否添加地址
  34. 'index_show_product' => $index_show_product,//首页弹窗商品
  35. ];
  36. $this->success('success',$config);
  37. }
  38. //自提点
  39. public function zitidian(){
  40. $list = Db::name('zitidian')->order('id desc')->select();
  41. $this->success('success',$list);
  42. }
  43. }