Index.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use app\common\model\Config;
  5. use app\common\model\MoneyLog;
  6. use app\common\model\News;
  7. /**
  8. * 首页接口
  9. */
  10. class Index extends Api
  11. {
  12. protected $noNeedLogin = ['base'];
  13. protected $noNeedRight = ['*'];
  14. /**
  15. * 首页
  16. *
  17. */
  18. public function base()
  19. {
  20. $data['logo'] = (new Config())->getValue('logo');
  21. $data['app_name'] = (new Config())->getValue('name');
  22. $data['code'] = [
  23. ['code' => '86', 'country' => __('中国')],
  24. ['code' => '1', 'country' => __('美国')],
  25. ];
  26. $this->success('', $data);
  27. }
  28. /**
  29. * 首页
  30. *
  31. */
  32. public function index()
  33. {
  34. $user = $this->auth->getUser();
  35. $data = [];
  36. $data['notice'] = '滚动显示的公告信息';
  37. $data['banner_list'] = ['https://dapp-static.oss-cn-shenzhen.aliyuncs.com/jue-jin-lu/3.pnggS02ouwrJfiF65979ec74db73','https://dapp-static.oss-cn-shenzhen.aliyuncs.com/jue-jin-lu/intro.pngkSx1GTBiuFzY65979f0cd34e1'];
  38. $data['balance'] = $user['balance'];
  39. $data['bonus_sum'] = $user['bonus_sum'];
  40. $data['service_link'] = $user['service_link'];
  41. $data['icon_list'] = [
  42. 'https://www.estyzl38.com/static/img/binance.ebc27893.png',
  43. 'https://www.estyzl38.com/static/img/ibank.11f8808d.png',
  44. 'https://www.estyzl38.com/static/img/gate.ef718121.png',
  45. 'https://www.estyzl38.com/static/img/trustwallet.3e39f1f7.png',
  46. 'https://www.estyzl38.com/static/img/gemini.90d29b68.png',
  47. 'https://www.estyzl38.com/static/img/11.png',
  48. 'https://www.estyzl38.com/static/img/metamask.5cc72a6d.png',
  49. 'https://www.estyzl38.com/static/img/22.png',
  50. ];
  51. $this->success(__('请求成功'), $data);
  52. }
  53. /**
  54. * 团队
  55. * @return void
  56. */
  57. public function team()
  58. {
  59. $user = $this->auth->getUser();
  60. $info_list = (new \app\common\model\Users())
  61. ->alias('u')
  62. ->join('users_path p', 'p.user_id = u.id')
  63. ->where('p.parent_id', $user['id'])
  64. ->field('u.avatar,u.bonus_sum,u.mobile,u.nickname')
  65. ->order('u.bonus_sum DESC')
  66. ->paginate($this->pageSize);
  67. // foreach ($info_list as $k => $v) {
  68. // $paginator[$k]['status_name'] = (new OrderModel())->getStatusNames($v['status']);
  69. // }
  70. $res_data = $this->buildResp($info_list->total(), $info_list->currentPage(), $info_list->items());
  71. $res_data['bonus_today'] = MoneyLog::where('user_id', $user['id'])
  72. ->where('create_time', '>=', strtotime('today'))
  73. ->where('action', 'in', [1,2])
  74. ->sum('amount');
  75. $res_data['bonus_sum'] = $user['bonus_sum'];
  76. $res_data['team_num'] = $user['team_num'];
  77. $this->success('', $res_data);
  78. }
  79. public function news_list()
  80. {
  81. $info_list = (new News())
  82. ->field('img_url,content', true)
  83. ->where('type_id', 2)//常见问题
  84. ->order('id DESC')
  85. ->paginate($this->pageSize);
  86. // foreach ($info_list as $k => $v) {
  87. // $paginator[$k]['status_name'] = (new OrderModel())->getStatusNames($v['status']);
  88. // }
  89. $res_data = $this->buildResp($info_list->total(), $info_list->currentPage(), $info_list->items());
  90. $this->success('', $res_data);
  91. }
  92. public function news()
  93. {
  94. $news_id = $this->request->post('id');
  95. $type_id = $this->request->post('type_id');
  96. $where['type_id'] = $type_id;
  97. if(!empty($news_id)){
  98. $where['id'] = $news_id;
  99. }
  100. $info_list = (new News())
  101. //->field('title,content')
  102. ->where($where)
  103. ->order('id desc')
  104. ->find();
  105. $this->success('', $info_list);
  106. }
  107. }