Commit 87ecfb5f authored by zhuwei's avatar zhuwei

获取三张图片

parent 5f44ef23
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace app\index\controller; namespace app\index\controller;
use app\index\extend\Basic; use app\index\extend\Basic;
use app\index\service\ImageDepotService;
use app\model\GImageDepot; use app\model\GImageDepot;
/** /**
...@@ -168,7 +169,11 @@ class ImageDepot extends Basic ...@@ -168,7 +169,11 @@ class ImageDepot extends Basic
} }
public function ceshi(){
$ImageDepotService = new ImageDepotService();
$res = $ImageDepotService->getImage();
dump($res);
}
......
...@@ -39,14 +39,31 @@ class ImageDepotService ...@@ -39,14 +39,31 @@ class ImageDepotService
} }
$result = $this->imageDepot->getImageDepotIDList($params_); $result = $this->imageDepot->getImageDepotIDList($params_);
if(!$result){ if(!$result){
//TODO 返回一个默认图片 //查询不到相关数据返回0
return $result; return 0;
} }
$random_keys=array_rand($result,1); $random_keys=array_rand($result,1);
$img_file_path= CURRENT_URL . 'static/shop_image_depot/' . $result[$random_keys]['img_name']; //$img_file_path= CURRENT_URL . 'static/shop_image_depot/' . $result[$random_keys]['id'];
return $result[$random_keys]['id'];
}
/**
* 获取三张图片
* @param string $label 标签
* @return string
*/
public function getImage($label='商场美食')
{
//图片类型:0室外图 ,1室内图 ,2人群图
$indoor_img_id = $this->getImageWidthRand(0,$label);//图片类型:0室外图
$outdoor_img_id = $this->getImageWidthRand(1,$label);//图片类型:1室内图
$people_img_id = $this->getImageWidthRand(2,$label);//图片类型:2人群图
return $img_file_path; $return_arr =[$indoor_img_id,$outdoor_img_id,$people_img_id];
return implode(',',$return_arr);
} }
} }
\ No newline at end of file
...@@ -311,7 +311,7 @@ Route::group('index', [ ...@@ -311,7 +311,7 @@ Route::group('index', [
'getImageDepotList' => [ 'index/ImageDepot/getImageDepotList', [ 'method' => 'get | post' ] ],//获取图片列表 'getImageDepotList' => [ 'index/ImageDepot/getImageDepotList', [ 'method' => 'get | post' ] ],//获取图片列表
'getImageDepotById' => [ 'index/ImageDepot/getImageDepotById', [ 'method' => 'get | post' ] ],//根据ID获取记录 'getImageDepotById' => [ 'index/ImageDepot/getImageDepotById', [ 'method' => 'get | post' ] ],//根据ID获取记录
'delImageDepot' => [ 'index/ImageDepot/delImageDepot', [ 'method' => 'get | post' ] ],//删除 'delImageDepot' => [ 'index/ImageDepot/delImageDepot', [ 'method' => 'get | post' ] ],//删除
'getImageWidthRand' => [ 'index/ImageDepot/getImageWidthRand', [ 'method' => 'get | post' ] ],//删除 'ceshi' => [ 'index/ImageDepot/ceshi', [ 'method' => 'get | post' ] ],//
]); ]);
......
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