Community.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use app\common\model\CooperationConfiguration;
  5. use app\common\model\Document;
  6. use app\common\model\Cooperation;
  7. use app\common\model\DownloadLink;
  8. use app\common\model\VersionComparison;
  9. use app\common\model\Visit;
  10. use app\common\model\VisitConfiguration;
  11. /**
  12. * 社区接口
  13. */
  14. class Community extends Api
  15. {
  16. // protected $noNeedLogin = ['document,teaching_video'];
  17. protected $noNeedLogin = ['*'];
  18. /**
  19. * 教学视频
  20. */
  21. public function teaching_video(){}
  22. /**
  23. * 文档
  24. */
  25. public function document(){
  26. $type = 0;
  27. $data = Document::all();
  28. // {
  29. // $query->where(['ismenu'=>1,'pid'=>0,'belong'=>0])->field('id,pid,title,ismenu');
  30. // });
  31. // $data->array();
  32. foreach ($data as $key => &$value){
  33. $value = $value->toArray();
  34. $z = Document::all(['pid'=>$value['id']]);
  35. foreach ($z as $k => &$v) {
  36. $v = $v->toArray();
  37. array_push($value,$v);
  38. $x = Document::all(['pid'=>$v['id'],'ismenu'=>0]);
  39. foreach ($x as $ke=>&$va){
  40. $va = $va->toArray();
  41. array_push($v,$va);
  42. }
  43. }
  44. }
  45. // foreach ($z as $k=>&$v){
  46. // $res = Document::all(['pid'=>$v['id']]);
  47. //// if($res){
  48. //// foreach ($res as $va){
  49. //// echo "<pre>";
  50. //// print_r($va);
  51. //// exit;
  52. //// array_push($v,$va);
  53. //// }
  54. //// }
  55. // echo "<pre>";
  56. print_r($data);
  57. // }
  58. // array_push($value,$z);
  59. // }
  60. // $this->success('返回成功', $data['data']);
  61. }
  62. //
  63. /**
  64. * 成为合作伙伴
  65. * @ApiParams (name="token")
  66. * @ApiParams (name="name",description="姓名")
  67. * @ApiParams (name="phone",description="联系方式")
  68. * @ApiParams (name="company",description="公司名称")
  69. */
  70. public function become_cooperation(){
  71. $rule = [
  72. 'name|姓名'=>'require',
  73. 'phone|联系方式'=>'require',
  74. 'company|公司名称'=>'require',
  75. ];
  76. $data = $this->_validate($rule);
  77. $data['uid'] = $this->auth->id;
  78. Cooperation::create($data)?$this->success('提交成功'):$this->error('提交失败');
  79. }
  80. /**
  81. * 预约参观公司
  82. * @ApiParams (name="token")
  83. * @ApiParams (name="name",description="称呼")
  84. * @ApiParams (name="phone",description="手机号")
  85. * @ApiParams (name="visit_time",description="参观时间")
  86. */
  87. public function visit(){
  88. $rule = [
  89. 'name|称呼'=>'require',
  90. 'phone|手机号'=>'require',
  91. 'visit_time|参观时间'=>'require',
  92. ];
  93. $data = $this->_validate($rule);
  94. $data['uid'] = $this->auth->id;
  95. Visit::create($data)?$this->success('提交成功'):$this->error('提交失败');
  96. }
  97. /**
  98. * 下载地址
  99. */
  100. public function download_link(){
  101. $link = DownloadLink::all();
  102. foreach ($link as &$value){
  103. $value['image'] = explode(',',$value['image']);
  104. }
  105. $this->success('请求成功',$link);
  106. }
  107. /**
  108. * 版本对比
  109. */
  110. public function version_comparison(){
  111. $link = VersionComparison::all();
  112. foreach ($link as &$value){
  113. $value['image'] = explode(',',$value['image']);
  114. }
  115. $this->success('请求成功',$link);
  116. }
  117. /**
  118. * 版本更新
  119. */
  120. public function version_updating(){
  121. $res = VersionComparison::all();
  122. }
  123. /**
  124. * 论坛
  125. */
  126. public function luntan(){
  127. }
  128. /**
  129. * 成为合作伙伴
  130. */
  131. public function cooperation_configuration(){
  132. $res = CooperationConfiguration::all();
  133. foreach ($res as $k=>&$v){
  134. $v['image'] = explode(',',$v['image']);
  135. }
  136. $this->success('请求成功',$res);
  137. }
  138. /**
  139. * 参观公司
  140. */
  141. public function visit_configuration(){
  142. $res = VisitConfiguration::all();
  143. foreach ($res as $k=>&$v){
  144. $v['image'] = explode(',',$v['image']);
  145. }
  146. $this->success('请求成功',$res);
  147. }
  148. }