Index.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2017 https://www.sapixx.com All rights reserved.
  4. * @license Licensed (http://www.apache.org/licenses/LICENSE-2.0).
  5. * @author pillar<ltmn@qq.com>
  6. * 小程序公共API服务
  7. */
  8. namespace app\popupshop\controller\api\v1;
  9. use app\popupshop\controller\api\Base;
  10. use app\popupshop\model\Article;
  11. use app\popupshop\model\Config;
  12. use app\popupshop\model\Store;
  13. use think\facade\Request;
  14. class Index extends Base{
  15. /**
  16. * 获取配置
  17. */
  18. public function config(){
  19. $config = Config::where(['member_miniapp_id' => $this->miniapp_id])->find();
  20. if($this->user){
  21. $config['is_reg_store'] = Store::where(['uid' => $this->user->id ])->count();
  22. }else{
  23. $config['is_reg_store'] = 0;
  24. }
  25. $config['set_tab_style'] = 1;
  26. return json(['code'=>200,'msg'=>'成功','data' => $config]);
  27. }
  28. /**
  29. * 获得首页公告
  30. */
  31. public function notice(){
  32. $data['signkey'] = Request::param('signkey');
  33. $data['sign'] = Request::param('sign');
  34. $rel = $this->apiSign($data);
  35. if($rel['code'] == 200){
  36. $condition[] = ['member_miniapp_id','=',$this->miniapp_id];
  37. $condition[] = ['types','=',2];
  38. $result = Article::where($condition)->field('id,title')->order('id desc')->find();
  39. if(!empty($result)){
  40. return enjson(200,'成功',$result->toArray());
  41. }
  42. }
  43. return enjson(204,'未输入关键字');
  44. }
  45. }