Commit 830899a9 by lizhilin

更新

parent 97e375f2
......@@ -32,9 +32,12 @@ public function deletePublicOssFile()
{
$ossPath = request()->post('key') ?? '';
$aliOss = new AilOss();
$res = $aliOss->delete($ossPath); //, 'OSS_BUCKET'
return $res ? $this->responseDeleted() : $this->responseDeleteFailed('文件删除失败');
if (strstr($ossPath, 'aliyuncs') !== false) {
$res = $aliOss->delete($ossPath); //, 'OSS_BUCKET'
return $res ? $this->responseDeleted() : $this->responseDeleteFailed('文件删除失败');
} else {
return $this->deleteFileAndResponse();
}
}
public function merchantUpload()
......
......@@ -34,6 +34,7 @@ public function upload($object, $filepath, $bucket = 'OSS_BUCKET')
{
$res = false;
$bucket = env($bucket); //获取阿里云oss的bucket
if (self::$oss->uploadFile($bucket, $object, $filepath)) { //调用uploadFile方法把服务器文件上传到阿里云oss
$res = true;
}
......
......@@ -31,3 +31,14 @@ function generateRandomString($length = 10)
}
return $randomString;
}
function togetherFilePath($path = '')
{
if ($path) {
if (strstr($path, 'aliyuncs') === false) {
$path = env('IMAGE_URL') . $path;
}
}
return $path;
}
......@@ -127,7 +127,7 @@ public function getList(Request $request)
'market_price' => sprintf("%.2f", $market_price),
'goods_price' => $mer_id ? sprintf("%.2f", $cg_price) : sprintf("%.2f", $market_price),
'tags' => $tags,
'cover_img' => (isset($goodsObj->cover_img) ? env('IMAGE_URL') . $goodsObj->cover_img : ''),
'cover_img' => (isset($goodsObj->cover_img) ? togetherFilePath($goodsObj->cover_img) : ''),
];
}
}
......@@ -185,6 +185,7 @@ public function getIndexGoods(Request $request)
}
//标签
$tags = $datum->tags ? json_decode($datum->tags, true) : [];
$data['list'][] = [
'id' => $datum->id,
'goods_name' => $datum->goods_name,
......@@ -193,7 +194,7 @@ public function getIndexGoods(Request $request)
'market_price' => floor($market_price),
'goods_price' => $mer_id ? floor($dg_price) : floor($market_price),
'tags' => $tags,
'cover_img' => ($datum->cover_img) ? env('IMAGE_URL') . $datum->cover_img : '',
'cover_img' => togetherFilePath($datum->cover_img),
];
}
}
......@@ -228,7 +229,7 @@ public function getDetail(Request $request)
$cover = [];
if (!empty($cover_arr)) {
foreach ($cover_arr as $item) {
$cover[] = env('IMAGE_URL') . $item;
$cover[] = togetherFilePath($item);
}
}
......@@ -321,7 +322,7 @@ public function getAttrKey(Request $request)
// 'dg_price' => sprintf('%.2f', $cg_price),
'goods_price' => $mer_id ? sprintf('%.2f', $cg_price) : sprintf('%.2f', $market_price),
'stock' => $stock,
'pic' => $attrObj->pic ? env('IMAGE_URL') . $attrObj->pic : ''
'pic' => $attrObj->pic ? togetherFilePath($attrObj->pic) : ''
];
return $this->JsonResponse($data);
}
......
......@@ -70,7 +70,7 @@ public function collectList(Request $request)
'attr' => $attrRowObj ? $attrRowObj->attr_val : '',
'tags' => $tags,
'goods_price' => $merchant_id ? sprintf("%.2f", $attrRowObj->cg_price) : sprintf("%.2f", $attrRowObj->market_price),
'cover_img' => ($goodObj->cover_img ? env('IMAGE_URL') . $goodObj->cover_img : ''),
'cover_img' => ($goodObj->cover_img ? togetherFilePath($goodObj->cover_img) : ''),
'addtime' => date('Y-m-d H:i:s', strtotime($datum->created_at))
];
}
......
......@@ -262,8 +262,8 @@
'upload' => [
// Disk in `config/filesystem.php`.
'disk' => 'public_oss', //admin
'disk' => 'admin', //admin
'extra_disk' => 'public_oss', //扩展oss,原系统不兼容
// Image and file upload path under the disk above.
'directory' => [
'image' => 'images',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment