正在显示
2 个修改的文件
包含
35 行增加
和
7 行删除
@@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
3 | namespace app\api\controller; | 3 | namespace app\api\controller; |
4 | 4 | ||
5 | use app\common\controller\Api; | 5 | use app\common\controller\Api; |
6 | +use app\common\model\ItemDetails; | ||
6 | 7 | ||
7 | /** | 8 | /** |
8 | * 活动接口 | 9 | * 活动接口 |
@@ -203,13 +204,9 @@ class Activity extends Api | @@ -203,13 +204,9 @@ class Activity extends Api | ||
203 | 'i.id'=> $id, | 204 | 'i.id'=> $id, |
204 | ]) | 205 | ]) |
205 | ->find(); | 206 | ->find(); |
206 | - $images = db('item_details')->where('item_id',$id)->value('images'); | ||
207 | - if (!empty($images)){ | ||
208 | - $image = explode(',',$images); | ||
209 | - foreach ($image as $k){ | ||
210 | - $data['images'] = cdnurl($image, true); | ||
211 | - } | ||
212 | - } | 207 | + $model = new ItemDetails(); |
208 | + $list = $model->where('item_id',$id)->find()->toArray(); | ||
209 | + $data['images'] = $list['images']; | ||
213 | $data['holdtime'] = date('Y-m-d',$data['holdtime']); | 210 | $data['holdtime'] = date('Y-m-d',$data['holdtime']); |
214 | $data['details'] = strip_tags($data['details']); | 211 | $data['details'] = strip_tags($data['details']); |
215 | $this->success('获取项目详情成功', $data); | 212 | $this->success('获取项目详情成功', $data); |
application/common/model/ItemDetails.php
0 → 100644
1 | +<?php | ||
2 | + | ||
3 | +namespace app\common\model; | ||
4 | + | ||
5 | +use think\Model; | ||
6 | + | ||
7 | +class ItemDetails extends Model | ||
8 | +{ | ||
9 | + | ||
10 | + // 表名 | ||
11 | + protected $name = 'item_details'; | ||
12 | + // 自动写入时间戳字段 | ||
13 | + protected $autoWriteTimestamp = 'int'; | ||
14 | + // 定义时间戳字段名 | ||
15 | + protected $createTime = 'createtime'; | ||
16 | + protected $updateTime = 'updatetime'; | ||
17 | + // 追加属性 | ||
18 | + protected $append = [ | ||
19 | + ]; | ||
20 | + | ||
21 | + public function getImagesAttr($value,$data){ | ||
22 | + if (!empty($data['images'])){ | ||
23 | + $image = explode(',',$data['images']); | ||
24 | + foreach ($image as $k => $v){ | ||
25 | + $value = cdnurl($v, true); | ||
26 | + } | ||
27 | + return $value; | ||
28 | + } | ||
29 | + } | ||
30 | + | ||
31 | +} |
-
请 注册 或 登录 后发表评论