Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tl_estate
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hujun
tl_estate
Commits
b4ad1645
Commit
b4ad1645
authored
Sep 04, 2018
by
clone
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '0830-v2.9.0' of
https://gitee.com/zwyjjc/tl_estate
into 0830-v2.9.0
parents
05b000ae
d0dc84ed
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
27 deletions
+53
-27
ImageDepot.php
application/index/controller/ImageDepot.php
+0
-27
ImageDepotService.php
application/index/service/ImageDepotService.php
+53
-0
No files found.
application/index/controller/ImageDepot.php
View file @
b4ad1645
...
...
@@ -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
;
}
...
...
application/index/service/ImageDepotService.php
0 → 100644
View file @
b4ad1645
<?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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment