bill 3 years ago
parent
commit
320e2d6441
  1. 5
      app/Http/Controllers/Home/IndexController.php
  2. 14
      resources/views/home/index/index.blade.php

5
app/Http/Controllers/Home/IndexController.php

@ -28,6 +28,7 @@ class IndexController extends BaseController
$url = env('APP_API_URL') . "/goods_list"; $url = env('APP_API_URL') . "/goods_list";
$res = curl_request($url, $postdata, 'GET'); $res = curl_request($url, $postdata, 'GET');
$data['tjlist'] = $res['data']['list']; $data['tjlist'] = $res['data']['list'];
// $data['tjlist'] = [];
//列表 //列表
@ -42,7 +43,7 @@ class IndexController extends BaseController
} }
} }
$data['article_list'] =collect($res['list'])->toArray();
$data['article_list'] =$res['list'];
$data['article_count'] = intval($res['count']); $data['article_count'] = intval($res['count']);
//banner轮播图 //banner轮播图
@ -60,7 +61,7 @@ class IndexController extends BaseController
if(!empty($res['list'][$k]->pic)){$res['list'][$k]->pic = http_host().$v->pic;} if(!empty($res['list'][$k]->pic)){$res['list'][$k]->pic = http_host().$v->pic;}
} }
} }
$data['slide_list'] = collect($res['list'])->toArray();
$data['slide_list'] = $res['list'];
return view('home.index.index', $data); return view('home.index.index', $data);
} }

14
resources/views/home/index/index.blade.php

@ -29,7 +29,7 @@
<section class="bg"> <section class="bg">
<?php if ($slide_list) { ?> <?php if ($slide_list) { ?>
<?php foreach ($slide_list as $k=>$v) { ?> <?php foreach ($slide_list as $k=>$v) { ?>
<img src="<?php echo $v['pic']; ?>" alt="<?php echo $v['title']; ?>">
<img src="<?php echo data_get($v, 'pic'); ?>" alt="<?php echo data_get($v, 'title'); ?>">
<?php } ?> <?php } ?>
<?php } ?> <?php } ?>
@ -67,7 +67,7 @@
<ul id="ajlist"> <ul id="ajlist">
@if($article_list) @if($article_list)
@foreach($article_list as $row) @foreach($article_list as $row)
<li><span class="group">[{{date("Y-m-d",$row['pubdate'])}}]</span> <a href="{{get_wap_front_url(array("id"=>$row['id'],"catid"=>$row['typeid'],"type"=>'content'))}}" target="_blank">{{$row['title']}}</a></li>
<li><span class="group">[{{date("Y-m-d",data_get($row, 'pubdate'))}}]</span> <a href="{{get_wap_front_url(array("id"=>data_get($row,'id'),"catid"=>data_get($row,'typeid'),"type"=>'content'))}}" target="_blank">{{data_get($row,'title')}}</a></li>
@endforeach @endforeach
@endif @endif
</ul> </ul>
@ -141,7 +141,7 @@
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script> <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script> <script>
var page =1;
new Vue({ new Vue({
el: '#app', el: '#app',
data: function () { data: function () {
@ -153,17 +153,17 @@
handleCurrentChange(e){ handleCurrentChange(e){
console.log(e,'---eeee'); console.log(e,'---eeee');
$.ajax({ $.ajax({
url: {{env('APP_API_URL')}} + "/article_list",
url: "{{env('APP_API_URL')}}" + "/article_list",
dataType: "json", dataType: "json",
type: "POST",
type: "get",
data: { data: {
'limit' : 10, 'limit' : 10,
'offset' : e * 10
'offset' : (e-1) * 10
}, },
success: function(data){ success: function(data){
if(data.code==0) if(data.code==0)
{ {
var json = data.data; //数组
var json = data.data.list; //数组
var str = ''; var str = '';
$.each(json, function (index) { $.each(json, function (index) {
//循环获取数据 //循环获取数据

Loading…
Cancel
Save