Commit b4ad1645 authored by clone's avatar clone

Merge branch '0830-v2.9.0' of https://gitee.com/zwyjjc/tl_estate into 0830-v2.9.0

parents 05b000ae d0dc84ed
...@@ -168,34 +168,7 @@ class ImageDepot extends Basic ...@@ -168,34 +168,7 @@ class ImageDepot extends Basic
} }
/**
* 获取随机图片
* @return \think\Response
*/
public function getImageWidthRand($img_type=0,$label='商场美食')
{
$params_['img_status'] = 0;
if (!empty($img_type)) {
$params_['img_type'] = $img_type;
}
if($img_type == 0 or $img_type == 1)
{
if (!empty($label)) {
$params_['label'] = [ 'LIKE', '%' . $label . '%' ];
}
}
$result = $this->imageDepot->getImageDepotIDList($params_);
if(!$result){
//TODO 返回一个默认图片
return $result;
}
$random_keys=array_rand($result,1);
$img_file_path= CURRENT_URL . 'static/shop_image_depot/' . $result[$random_keys]['img_name'];
return $img_file_path;
}
......
<?php
/**
* Created by PhpStorm.
* User: zhuwe
* Date: 2018-09-04
* Time: 10:30:34
*/
namespace app\index\service;
use app\model\GImageDepot;
class ImageDepotService
{
protected $imageDepot;
public function __construct()
{
$this->imageDepot = new GImageDepot();
}
/**
* 获取随机图片
* @param int $img_type 图片类型:0室外图 ,1室内图 ,2人群图
* @param string $label 标签
* @return array|false|\PDOStatement|string|\think\Collection
*/
public function getImageWidthRand($img_type=0,$label='商场美食')
{
$params_['img_status'] = 0;
if (!empty($img_type)) {
$params_['img_type'] = $img_type;
}
if($img_type == 0 or $img_type == 1)
{
//室外图、室内图有标签 ,人群图无标签
if (!empty($label)) {
$params_['label'] = [ 'LIKE', '%' . $label . '%' ];
}
}
$result = $this->imageDepot->getImageDepotIDList($params_);
if(!$result){
//TODO 返回一个默认图片
return $result;
}
$random_keys=array_rand($result,1);
$img_file_path= CURRENT_URL . 'static/shop_image_depot/' . $result[$random_keys]['img_name'];
return $img_file_path;
}
}
\ No newline at end of file
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