1
0

Building.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. declare (strict_types = 1);
  3. namespace app\index\controller;
  4. use app\model\BuildingLabel as ModelBuildingLabel;
  5. use app\model\BuildingProgress;
  6. use xiaohongwu\Vr;
  7. class Building
  8. {
  9. /**
  10. * 显示资源列表
  11. *
  12. * @return \think\Response
  13. */
  14. public function label($r)
  15. {
  16. $data = ModelBuildingLabel::where(['root_id' => $r])->field('id,name')->select();
  17. return json(['code'=>0, 'data'=>$data]);
  18. }
  19. /**
  20. * 进度
  21. */
  22. public function progress($id, $label_id=0)
  23. {
  24. $type = input('type','','trim');
  25. $where[]=['building_id', '=', $id];
  26. if($label_id)
  27. $where[]=['label_id','=',$label_id];
  28. if(!empty($type)){
  29. $where[]=['type', '=', $type];
  30. }
  31. $list = BuildingProgress::with(['label'=>function($query){
  32. $query->withField(['id','name']);
  33. }])->where($where)->order('addtime desc')->select();
  34. if (empty($list)) $list = [];
  35. else $list = $list->toArray();
  36. $vrObj = new Vr();
  37. foreach ($list as &$item) {
  38. $item['progress_cont_link'] = request()->domain() . '/index/index/progress_detail.html?r=' . $item['root_id'] . '&id=' . $item['id'];
  39. if (empty($item['vr'])) {
  40. $item['vr'] = [];
  41. continue;
  42. }
  43. $vrUrlList = explode(',', $item['vr']);
  44. $vrData = [];
  45. foreach ($vrUrlList as $url) {
  46. $vrData[] = [
  47. 'vrUrl' => $url,
  48. 'vrfirstImg' => $vrObj->getFirstImg($url)
  49. ];
  50. }
  51. $item['vr'] = $vrData;
  52. }
  53. return json(['code' => 0, 'data' => $list]);
  54. }
  55. }