作者 开飞机的舒克

绑定后不出现头像昵称的问题

... ... @@ -3,6 +3,7 @@
namespace app\api\controller;
use app\common\controller\Api;
use app\common\model\ItemDetails;
/**
* 活动接口
... ... @@ -203,13 +204,9 @@ class Activity extends Api
'i.id'=> $id,
])
->find();
$images = db('item_details')->where('item_id',$id)->value('images');
if (!empty($images)){
$image = explode(',',$images);
foreach ($image as $k){
$data['images'] = cdnurl($image, true);
}
}
$model = new ItemDetails();
$list = $model->where('item_id',$id)->find()->toArray();
$data['images'] = $list['images'];
$data['holdtime'] = date('Y-m-d',$data['holdtime']);
$data['details'] = strip_tags($data['details']);
$this->success('获取项目详情成功', $data);
... ...
<?php
namespace app\common\model;
use think\Model;
class ItemDetails extends Model
{
// 表名
protected $name = 'item_details';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
// 追加属性
protected $append = [
];
public function getImagesAttr($value,$data){
if (!empty($data['images'])){
$image = explode(',',$data['images']);
foreach ($image as $k => $v){
$value = cdnurl($v, true);
}
return $value;
}
}
}
\ No newline at end of file
... ...