ProductController.php
5.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
<?php
namespace app\portal\controller;
use cmf\controller\HomeBaseController;
use EasyWeChat\Foundation\Application;
use think\Db;
class ProductController extends HomeBaseController{
public function _initialize(){
parent::_initialize();
$data = Db::name('slide_item') -> where('slide_id',3) -> find();
$this -> assign('logo',$data);
$shuju = Db::name('nav_menu') -> select();
$data2 = $this -> daohang($shuju);
$this -> assign('data2',$data2);
}
public function daohang($data,$pid=0){
$arr = [];
foreach ($data as $key => $value) {
if($value['parent_id'] == $pid){
$value['son'] = $this -> daohang($data,$value['id']);
$arr[] = $value;
}
}
return $arr;
}
//显示产品页
public function product(){
$data = Db::name('portal_category') -> select();
$shuju = $this -> wuxian($data);
$this -> assign('shuju',$shuju);
$cpid = Db::name('portal_category_post') -> where('category_id',12) -> find();
$cpdata = Db::name('portal_post') -> where('id',$cpid['post_id']) -> find();
$cpdata['post_content'] = cmf_replace_content_file_url(htmlspecialchars_decode($cpdata['post_content']));
$this -> assign('zuixin',$cpdata);
/* $shuju2 = $this -> wuxianx($data);
foreach ($shuju2 as $key => $value) {
$arr[] = $value['id'];
}
foreach ($arr as $key => $value) {
$arr1[] = Db::name('portal_category_post') -> where('category_id',$value) -> select();
}
foreach ($arr1 as $key => $value) {
foreach ($value as $k => $va) {
$arr3[] = $va['post_id'];
}
}
$zuixin = Db::name('portal_post') -> where('id','in',$arr3) -> where('delete_time',0) -> order('create_time desc') -> limit(1) -> select();
$zzz = $zuixin[0];
$zzz['post_content'] = cmf_replace_content_file_url(htmlspecialchars_decode($zzz['post_content']));
$this -> assign('zuixin',$zzz);
//将最新文章的说明文献coa显示
$post_data = Db::name('portal_category_post') -> where('post_id',$zzz['id']) -> find();
$cos_data = Db::name('docu_coa') -> where('post_id',$post_data['category_id']) -> select();
$this -> assign('cos_data',$cos_data);*/
return $this -> fetch();
}
public function wuxian($data,$pid=12){
$arr = [];
foreach ($data as $key => $value) {
if($value['parent_id'] == $pid){
$value['son'] = $this -> daohang($data,$value['id']);
$arr[] = $value;
}
}
return $arr;
}
public function wuxianx($data,$pid=12){
static $arr=[];
foreach ($data as $key => $value) {
if($value['parent_id'] == $pid){
$arr[] = $value;
$this -> wuxianx($data,$value['id']);
}
}
return $arr;
}
//查询所有文章
/* public function wenzhang(){
$id = input('post.id');
$data = Db::name('portal_category_post') -> where('category_id',$id) -> select();
foreach ($data as $key => $value) {
$wzs = Db::name('portal_post') -> where('id',$value['post_id']) -> where('delete_time',0) -> find();
if($wzs != null){
$arr[] = $wzs;
}
}
return json_encode($arr);
}*/
//查询单个文章
public function danwz(){
$id = input('post.id');
$shuju = Db::name('portal_category_post') -> where('category_id',$id) ->find();
$data = Db::name('portal_post') -> where('id',$shuju['post_id']) -> find();
$data['post_content'] = cmf_replace_content_file_url(htmlspecialchars_decode($data['post_content']));
return json_encode($data);
}
//详情页
public function details(){
$id = input('get.id');
$data = Db::name('portal_post') -> where('id',$id) -> find();
$data['post_content'] = cmf_replace_content_file_url(htmlspecialchars_decode($data['post_content']));
$this -> assign('data',$data);
$cid = Db::name('portal_category_post') -> where('post_id',$id) -> find();
$shuju = Db::name('portal_category') -> where('id',$cid['category_id']) -> find();
$this -> assign('shuju',$shuju);
$pshuju = Db::name('portal_category') -> where('id',$shuju['parent_id']) -> find();
$this -> assign('pshuju',$pshuju);
return $this -> fetch();
}
//coa 说明 文献
public function commp(){
$id = $this -> request -> param();
$data = Db::name('docu_coa') -> where('id',$id['id']) -> find();
$data['content'] = cmf_replace_content_file_url(htmlspecialchars_decode($data['content']));
$this -> assign('data',$data);
return $this -> fetch();
}
public function commps(){
$id = input('post.id');
$data = Db::name('docu_coa') -> where('post_id',$id) -> select();
foreach ($data as $key => $value) {
$value['content'] = cmf_replace_content_file_url(htmlspecialchars_decode($value['content']));
}
return json_encode($data);
}
//显示产品中心
public function chanpins(){
$data = Db::name('portal_category_post') -> where('category_id',15) -> find();
$shuju = Db::name('portal_post') -> where('id',$data['post_id']) -> find();
$shuju['post_content'] = cmf_replace_content_file_url(htmlspecialchars_decode($shuju['post_content']));
return json_encode($shuju);
}
}
?>