Index.php
2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
namespace app\reservoir\controller;
use app\common\controller\Frontend;
use think\Lang;
use think\Db;
class Index extends Frontend
{
protected $noNeedLogin = '*';
protected $noNeedRight = '*';
public function index(){
$this->reservoir_list();
return $this->view->fetch();
}
public function gallery(){
return $this->view->fetch();
}
public function introduction(){
return $this->view->fetch();
}
public function getTree(){
$list = $this->reservoir_list();
if($list){
$this->success('获取列表成功','',$list);
}
else{
$this->error('该用户没有权限');
}
}
//根据水库id获取图片列表
public function getImage(){
$id = input('get.id');
$level = input('get.level');
$page = input('get.page')?:1;
$limit = input('get.limit')?:10;
if($level == '0'){
$ids = Db::name('reservoir_list')->where('province_id','=',$id)->field('id')->select();
$arr = [];
foreach ($ids as $k => $v){
$arr[] = $v['id'];
}
}
elseif($level == '1'){
$ids = Db::name('reservoir_list')->where('state_id','=',$id)->field('id')->select();
$arr = [];
foreach ($ids as $k => $v){
$arr[] = $v['id'];
}
}
elseif($level == '2'){
$ids = Db::name('reservoir_list')->where('county_id','=',$id)->field('id')->select();
$arr = [];
foreach ($ids as $k => $v){
$arr[] = $v['id'];
}
}
else{
$arr = $id;
}
$list = Db::name('reservoir_image')->where('reservoir_id','in',$arr)->where('type','=','image')->field('image,id,name')->page($page,$limit)->select();
$count = Db::name('reservoir_image')->where('reservoir_id','in',$arr)->where('type','=','image')->field('image,id,name')->count();
$this->success('成功','',['list'=>$list,'count'=>$count]);
}
}