Browse Source

1、去年首页的猜你喜欢,改成ProductController分页瀑布流调用;2、增加home_ad1广告图调用;

dev
李可松 4 years ago
parent
commit
154814b166
  1. 18
      app/Http/Controllers/Api/IndexController.php

18
app/Http/Controllers/Api/IndexController.php

@ -2,6 +2,7 @@
namespace App\Http\Controllers\Api; namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Models\Advertising;
use App\Models\Channel; use App\Models\Channel;
use App\Models\Notice; use App\Models\Notice;
use App\Models\Product; use App\Models\Product;
@ -19,27 +20,32 @@ class IndexController extends Controller
public function index() public function index()
{ {
# 轮播图 # 轮播图
$slide = Slide::where('status', 1)->orderBy('sort')->orderBy('id', 'DESC')->limit(2)->get(['title','url']);
$slide = Slide::where('agent_id', $this->agent_id)->where('status', 1)
->orderBy('sort')->orderBy('id', 'DESC')->limit(2)->get(['title','url']);
# 公告 # 公告
$notice = Notice::limit(10)->get(['title', 'updated_at']);
$notice = Notice::where('agent_id', $this->agent_id)->limit(10)->get(['title', 'updated_at']);
# 我的频道 # 我的频道
$channel_ids = UserChannel::where('uid', $this->user_id)->value('channels');
$channel_ids = UserChannel::where('user_id', $this->user_id)->value('channels');
$my_channels = Channel::whereIn('id', $channel_ids)->get(['id', 'pid', 'name', 'icon']); $my_channels = Channel::whereIn('id', $channel_ids)->get(['id', 'pid', 'name', 'icon']);
# 广告图
$home_ad1 = Advertising::where('agent_id', $this->agent_id)->value('picture');
# 人气爆款 # 人气爆款
$hots = Product::get(['title', 'price', 'original_price', 'pictures', 'sales']);
$hots = Product::get(['title', 'price', 'original_price', 'pictures', 'sale']);
# 猜你喜欢 # 猜你喜欢
$guess = Product::get(['title', 'price', 'original_price', 'pictures', 'sales']);
// $guess = Product::get(['title', 'price', 'original_price', 'pictures', 'sale']);
return $this->success([ return $this->success([
'slide' => $slide, 'slide' => $slide,
'notice' => $notice, 'notice' => $notice,
'my_channels' => $my_channels, 'my_channels' => $my_channels,
'home_ad1' => $home_ad1,
'hots' => $hots, 'hots' => $hots,
'guess' => $guess,
// 'guess' => $guess,
]); ]);
} }
} }
Loading…
Cancel
Save