123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use think\Db;
- /**
- * 首页接口
- */
- class Index extends Api
- {
- protected $noNeedLogin = ['info'];
- protected $noNeedRight = ['*'];
- //进行中的唯一一个投票活动
- public function info(){
- $find = Db::name('vote_subject')->where('id',1)->find();
- if(!$find){
- $this->error('没有进行中的投票活动');
- }
- $find = info_domain_image($find,['image','paihang_image']);
- $this->success(1,$find);
- }
- //结束后的首页
- public function index(){
- //活动详情
- $find = Db::name('vote_subject')->where('id',1)->find();
- if(!$find){
- $this->error('没有进行中的投票活动');
- }
- $find = info_domain_image($find,['image','paihang_image']);
- //中奖信息
- $zhongjiang = [
- 'zhongjiang_status' => 0,
- 'finish_title' => config('site.finish_title'),
- 'finish_info' => config('site.finish_info'),
- 'finish_iqiyi' => config('site.finish_iqiyi'),
- 'user_kami' => '',
- 'finish_content' => config('site.finish_content'),
- ];
- if($this->auth->isLogin()){
- $exam_user_top = Db::name('exam_user_top')->where('user_id',$this->auth->id)->order('id asc')->find();
- if(!empty($exam_user_top) && !empty($exam_user_top['info'])){
- $zhongjiang['zhongjiang_status'] = 1;
- $zhongjiang['user_kami'] = $exam_user_top['info'];
- }
- }
- $result = [
- 'subject' => $find,
- 'zhongjiang' => $zhongjiang,
- ];
- $this->success(1,$result);
- }
- //领取
- public function lingqu(){
- $exam_user_top = Db::name('exam_user_top')->where('user_id',$this->auth->id)->order('id asc')->find();
- if(!empty($exam_user_top) && !empty($exam_user_top['info'])){
- if($exam_user_top['status'] == 0){
- $update = [
- 'status' => 1,
- 'gettime' => time(),
- ];
- Db::name('exam_user_top')->where('id',$exam_user_top['id'])->update($update);
- }
- }
- $this->success('领取成功');
- }
- }
|