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
87ecfb5f
Commit
87ecfb5f
authored
Sep 04, 2018
by
zhuwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
获取三张图片
parent
5f44ef23
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
6 deletions
+29
-6
ImageDepot.php
application/index/controller/ImageDepot.php
+6
-1
ImageDepotService.php
application/index/service/ImageDepotService.php
+22
-4
route.php
application/route.php
+1
-1
No files found.
application/index/controller/ImageDepot.php
View file @
87ecfb5f
...
@@ -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
);
}
...
...
application/index/service/ImageDepotService.php
View file @
87ecfb5f
...
@@ -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
application/route.php
View file @
87ecfb5f
...
@@ -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'
]
],
//
]);
]);
...
...
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