Index.php
1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
namespace addons\litestore\controller\api;
use app\common\controller\Api;
use addons\litestore\model\Wxlitestoregoods;
use addons\litestore\model\Litestorenews;
class Index extends Api
{
protected $noNeedLogin = ['*'];
public function _initialize()
{
parent::_initialize();
}
public function index()
{
$Temp_litestoregoods = new Wxlitestoregoods();
$banner = new Litestorenews();
$bannerdata = $banner->where('status', 'normal')->order('updatetime', 'desc')->limit(10)->select();
$bannerList = [];
foreach ($bannerdata as $index => $item) {
$bannerList[] = ['image' => cdnurl($item['image'], true), 'title' => $item['title'],'id'=> $item['id']];
}
$NewList = $Temp_litestoregoods->getNewList();
foreach ($NewList as $index => $item) {
$NewList[$index]['ImageFrist'] = cdnurl(explode(",",$item['images'])[0], true);
}
$Randomlist = $Temp_litestoregoods->getRandom8();
foreach ($Randomlist as $index => $item) {
$Randomlist[$index]['ImageFrist'] = cdnurl(explode(",",$item['images'])[0], true);
}
$this->success('', [
'NewList' => $NewList,
'Randomlist' => $Randomlist,
'bannerlist' => $bannerList
]);
}
public function getnew(){
$new_id = $this->request->request('new_id');
$newdata = Litestorenews::get($new_id);
$newdata['image'] = cdnurl($newdata['image'], true);
$newdata['updatetime'] = datetime($newdata['updatetime']);
$this->success('', [
'newdata' => $newdata
]);
}
}