diff --git a/app/api/controller/Content.php b/app/api/controller/Content.php
index 4dcd744..765ecf8 100644
--- a/app/api/controller/Content.php
+++ b/app/api/controller/Content.php
@@ -57,6 +57,7 @@ class Content extends Base
{
//广告
$_data['ad'] = Db::name('ad')->where('status', 1)->order('sort DESC,create_time DESC')->limit(6)->select();
+ $_data['ad'] = $this->replace_img_http($_data['ad']->toArray());
//三个产品分类
$field = 'id,create_time,sort,status,cate_id,title,author,source,image';
$_data['yinshidapeng'] = Db::name('product')->where('cate_id', 9)
@@ -67,6 +68,13 @@ class Content extends Base
->field($field)->order('sort DESC,create_time DESC')->limit(4)->select();
$_data['kepianxinshang'] = Db::name('product')->where('cate_id', 15)
->field($field)->order('sort DESC,create_time DESC')->limit(4)->select();
+
+ //替换CDN图片
+ $_data['yinshidapeng'] = $this->replace_img_http($_data['yinshidapeng']->toArray());
+ $_data['shijingpianchang'] = $this->replace_img_http($_data['shijingpianchang']->toArray());
+ $_data['peitaosheshi'] = $this->replace_img_http($_data['peitaosheshi']->toArray());
+ $_data['kepianxinshang'] = $this->replace_img_http($_data['kepianxinshang']->toArray());
+
return $this->result($_data, 1, '');
}
@@ -85,7 +93,7 @@ class Content extends Base
{
//联系我们
$_data = Db::name('page')->where('id', 1)->field('content')->find();
- $_data['content'] = strip_tags($_data['content']);
+ $_data['content'] = $_data['content'];
// $_data['map'] = Db::name('page')->where('id', 1)->field('content')->find();
$_system = Db::name('system')->where('id', 1)->find();
$_data['address'] = $_system['address'];
@@ -137,6 +145,7 @@ class Content extends Base
$_data = $_db->where('cate_id', $cate_id)->field('id,image,cate_id,title')
->where('status', 1)
->page($page, $limit)->select();
+ $_data = $this->replace_img_http($_data->toArray());
return $this->result($_data, 1, '');
}
@@ -153,18 +162,22 @@ class Content extends Base
*/
public function detail_product(int $id)
{
- $_db = Db::name('product');
- $_data['detail'] = $_db->field('id,title,create_time,source,cate_id,image,images,content,summary')
+ $_db = Db::name('product');
+ $_data['detail'] = $_db->field('id,title,create_time,source,cate_id,image,images,content,summary')
->where('status', 1)
->find($id);
// $_data['detail']['content'] = strip_tags($_data['detail']['content'], '
');
//替换img 标签
// $_data['detail']['content'] = $this->replace_img_alt($_data['detail']['content']);
//$_data['detail']['content'] = str_ireplace('
where('id', $_data['detail']['cate_id'])->find();
+ //替换cdn前缀
+ $_data['detail']['content'] = $this->replace_img_http($_data['detail']['content']);
+ $_data['detail']['image'] = $this->replace_img_http($_data['detail']['image']);
+ $_cate = Db::name('cate')->where('id', $_data['detail']['cate_id'])->find();
$_data['detail']['source'] = $_cate['cate_name'];
- $_data['postion']= Db::name('product')->field('id,title,image')->limit(4)
+ $_data['postion'] = Db::name('product')->field('id,title,image')->limit(4)
->order('sort DESC,create_time DESC')->select();
+ $_data['postion'] = $this->replace_img_http($_data['postion']->toArray());
return $this->result($_data, 1, '');
}
@@ -191,4 +204,24 @@ class Content extends Base
}
+ private function replace_img_http($http = '')
+ {
+ if (empty($http)) {
+ return;
+ }
+
+ $find_url = 'https://api.junfei.iiixo.com/uploads';
+ $replace_url = 'http://cdn.junfei.iiixo.com';
+
+ if (is_array($http)) {
+ array_walk($http, function (&$v, $k) use ($find_url, $replace_url) {
+ $v['image'] = str_replace($find_url, $replace_url, $v['image']);
+ });
+ return $http;
+ }
+ $http = str_replace($find_url, $replace_url, $http);
+ return $http;
+ }
+
+
}
diff --git a/public/uploads/20221101/2ef8fcf3d44ad36e75d227d34accdefa.png b/public/uploads/20221101/2ef8fcf3d44ad36e75d227d34accdefa.png
new file mode 100644
index 0000000..5d6186f
Binary files /dev/null and b/public/uploads/20221101/2ef8fcf3d44ad36e75d227d34accdefa.png differ
diff --git a/public/uploads/20221101/804ea1842bbdda00b59e97bd1456e712.png b/public/uploads/20221101/804ea1842bbdda00b59e97bd1456e712.png
new file mode 100644
index 0000000..d98ca4f
Binary files /dev/null and b/public/uploads/20221101/804ea1842bbdda00b59e97bd1456e712.png differ