123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use app\common\model\CooperationConfiguration;
- use app\common\model\Document;
- use app\common\model\Cooperation;
- use app\common\model\DownloadLink;
- use app\common\model\VersionComparison;
- use app\common\model\Visit;
- use app\common\model\VisitConfiguration;
- /**
- * 社区接口
- */
- class Community extends Api
- {
- // protected $noNeedLogin = ['document,teaching_video'];
- protected $noNeedLogin = ['*'];
- /**
- * 教学视频
- */
- public function teaching_video(){}
- /**
- * 文档
- */
- public function document(){
- $type = 0;
- $data = Document::all();
- // {
- // $query->where(['ismenu'=>1,'pid'=>0,'belong'=>0])->field('id,pid,title,ismenu');
- // });
- // $data->array();
- foreach ($data as $key => &$value){
- $value = $value->toArray();
- $z = Document::all(['pid'=>$value['id']]);
- foreach ($z as $k => &$v) {
- $v = $v->toArray();
- array_push($value,$v);
- $x = Document::all(['pid'=>$v['id'],'ismenu'=>0]);
- foreach ($x as $ke=>&$va){
- $va = $va->toArray();
- array_push($v,$va);
- }
- }
- }
- // foreach ($z as $k=>&$v){
- // $res = Document::all(['pid'=>$v['id']]);
- //// if($res){
- //// foreach ($res as $va){
- //// echo "<pre>";
- //// print_r($va);
- //// exit;
- //// array_push($v,$va);
- //// }
- //// }
- // echo "<pre>";
- print_r($data);
- // }
- // array_push($value,$z);
- // }
- // $this->success('返回成功', $data['data']);
- }
- //
- /**
- * 成为合作伙伴
- * @ApiParams (name="token")
- * @ApiParams (name="name",description="姓名")
- * @ApiParams (name="phone",description="联系方式")
- * @ApiParams (name="company",description="公司名称")
- */
- public function become_cooperation(){
- $rule = [
- 'name|姓名'=>'require',
- 'phone|联系方式'=>'require',
- 'company|公司名称'=>'require',
- ];
- $data = $this->_validate($rule);
- $data['uid'] = $this->auth->id;
- Cooperation::create($data)?$this->success('提交成功'):$this->error('提交失败');
- }
- /**
- * 预约参观公司
- * @ApiParams (name="token")
- * @ApiParams (name="name",description="称呼")
- * @ApiParams (name="phone",description="手机号")
- * @ApiParams (name="visit_time",description="参观时间")
- */
- public function visit(){
- $rule = [
- 'name|称呼'=>'require',
- 'phone|手机号'=>'require',
- 'visit_time|参观时间'=>'require',
- ];
- $data = $this->_validate($rule);
- $data['uid'] = $this->auth->id;
- Visit::create($data)?$this->success('提交成功'):$this->error('提交失败');
- }
- /**
- * 下载地址
- */
- public function download_link(){
- $link = DownloadLink::all();
- foreach ($link as &$value){
- $value['image'] = explode(',',$value['image']);
- }
- $this->success('请求成功',$link);
- }
- /**
- * 版本对比
- */
- public function version_comparison(){
- $link = VersionComparison::all();
- foreach ($link as &$value){
- $value['image'] = explode(',',$value['image']);
- }
- $this->success('请求成功',$link);
- }
- /**
- * 版本更新
- */
- public function version_updating(){
- $res = VersionComparison::all();
- }
- /**
- * 论坛
- */
- public function luntan(){
- }
- /**
- * 成为合作伙伴
- */
- public function cooperation_configuration(){
- $res = CooperationConfiguration::all();
- foreach ($res as $k=>&$v){
- $v['image'] = explode(',',$v['image']);
- }
- $this->success('请求成功',$res);
- }
- /**
- * 参观公司
- */
- public function visit_configuration(){
- $res = VisitConfiguration::all();
- foreach ($res as $k=>&$v){
- $v['image'] = explode(',',$v['image']);
- }
- $this->success('请求成功',$res);
- }
- }
|