Browse Source

goodslist分页

master
ZLW-PC\Administrator 6 years ago
parent
commit
7141d8bc60
  1. 52
      app/Http/Controllers/Weixin/GoodsController.php
  2. 8
      lqycms.sql
  3. 9
      public/css/weixin/style.css
  4. BIN
      public/images/weixin/ad_tit.png
  5. 45
      public/js/js.js
  6. 102
      resources/views/weixin/goods/categoryGoodsList.blade.php
  7. 36
      resources/views/weixin/index/index.blade.php
  8. 2
      resources/views/weixin/order/orderList.blade.php

52
app/Http/Controllers/Weixin/GoodsController.php

@ -70,25 +70,55 @@ class GoodsController extends CommonController
$data['typeid'] = 0;
if($request->input('typeid', '') != ''){$data['typeid'] = $request->input('typeid');}
//商品分类列表
$pagesize = 10;
$offset = 0;
if(isset($_REQUEST['page'])){$offset = ($_REQUEST['page']-1)*$pagesize;}
//商品列表
$postdata = array(
'pid' => 0,
'limit' => 100,
'offset' => 0
'typeid' => $data['typeid'],
'limit' => $pagesize,
'offset' => $offset
);
$url = env('APP_API_URL')."/goodstype_list";
$url = env('APP_API_URL')."/goods_list";
$res = curl_request($url,$postdata,'GET');
$data['goodstype_list'] = $res['data']['list'];
$data['list'] = $res['data']['list'];
$data['totalpage'] = ceil($res['data']['count']/$pagesize);
//商品列表
if(isset($_REQUEST['page_ajax']) && $_REQUEST['page_ajax']==1)
{
$html = '';
if($res['data']['list'])
{
foreach($res['data']['list'] as $k => $v)
{
$html .= '<li>';
$html .= '<a href="'.$v['goods_detail_url'].'"><img alt="'.$v['title'].'" src="'.$v['litpic'].'"><div class="goods_info"><p class="goods_tit">';
if($v['is_promote_goods']>0)
{
$html .= '<span class="badge_comm" style="background-color:#f23030;">Hot</span>';
}
$html .= $v['title'].'</p><div class="goods_price">¥<b>'.$v['price'].'</b><span class="fr">'.$v['sale'].'人付款</span></div></div></a>';
$html .= '</li>';
}
}
exit(json_encode($html));
}
//商品分类列表
$postdata = array(
'typeid' => $data['typeid'],
'limit' => 100,
'pid' => 0,
'limit' => 15,
'offset' => 0
);
$url = env('APP_API_URL')."/goods_list";
$url = env('APP_API_URL')."/goodstype_list";
$res = curl_request($url,$postdata,'GET');
$data['goods_list'] = $res['data']['list'];
$data['goodstype_list'] = $res['data']['list'];
return view('weixin.goods.categoryGoodsList', $data);
}

8
lqycms.sql
File diff suppressed because it is too large
View File

9
public/css/weixin/style.css

@ -75,7 +75,7 @@ background:none;
.goods_list_small li img{width:100%;height:auto;}.goods_list_small li .goods_price{color:#f23030;}.goods_list_small li .goods_price b{font-size:1rem;font-weight:normal;}.goods_list_small li .goods_price span{color:#999;font-size:14px;}
.goods_list_small li:nth-child(even) a{margin-right:0;margin-left:2px;}
.goods_list_s li{color:#333;border-bottom:1px solid #eee;overflow:hidden;margin-left:10px;margin-right:10px;padding:15px 5px 15px 5px;}
.goods_list_s li{color:#333;border-bottom:1px solid #eee;overflow:hidden;margin-left:10px;margin-right:10px;padding:15px 5px 15px 5px;}.goods_list_s li:last-child {border-bottom:0;}
.goods_list_s li .btn{color:#333;display:block;font-size:1rem;cursor:pointer;}.goods_list_s a:last-child li{border-bottom:0}
.goods_list_s .goods_thumb{width:100px;height:100px;float:left;margin-right:10px;display:block;}.goods_list_s .goods_thumb img{width:100px;height:100px;border:none;}
.goods_list_s .goods_tit{line-height:24px;overflow:hidden;}
@ -83,6 +83,13 @@ background:none;
.goods_list_s .goods_des{color:#999999;font-size:0.875rem;}
.goods_list_s .buy{border:1px solid #f23030;border-radius:2px;padding:0 3px;color:#fff;background-color:#f23030;}
.goodslist_limg li{border-bottom:10px solid #f0f0f0;}
.goodslist_limg li img{width:100%;height: auto;display: block;}
.goodslist_limg li .goods_info{padding:10px;background-color:#fff;border-top:1px solid #f9f9f9;}
.goodslist_limg li .goods_tit{line-height:1.5;font-size:16px;color:#333;}
.goodslist_limg li .goods_price{font-size:18px;color:#fe3939;line-height:1.5em;}.goodslist_limg li .goods_price b{font-weight:normal;}
.goodslist_limg li .fr{font-size:14px;color:#999;}
.classreturn{background-color:#f8f8f8;border-bottom:1px solid #dedede;position:relative;text-align:center;line-height:50px;padding:0 10px;}
.classreturn .return{position:absolute;left:15px}
.classreturn .return a{overflow:hidden;display:block}

BIN
public/images/weixin/ad_tit.png

Binary file not shown.

Before

Width: 140  |  Height: 90  |  Size: 3.0 KiB

After

Width: 140  |  Height: 90  |  Size: 23 KiB

45
public/js/js.js

@ -0,0 +1,45 @@
//常用JS函数
// 时间戳转换普通日期格式
function add0(m){return m<10?'0'+m:m;}
function timestamp_to_date(timestamp)
{
//timestamp是整数,否则要parseInt转换,不会出现少个0的情况
var time = new Date(timestamp * 1000); //时间戳为10位需*1000,时间戳为13位的话不需乘1000
var year = time.getFullYear();
var month = time.getMonth()+1;
var date = time.getDate();
var hours = time.getHours();
var minutes = time.getMinutes();
var seconds = time.getSeconds();
var res = new Array();
res['Y'] = year;
res['m'] = add0(month);
res['d'] = add0(date);
res['H'] = add0(hours);
res['i'] = add0(minutes);
res['s'] = add0(seconds);
return res;
//return year+'-'+add0(month)+'-'+add0(date)+' '+add0(hours)+':'+add0(minutes)+':'+add0(seconds);
}
// 日期转时间戳
function date_to_timestamp(stringTime)
{
//var stringTime = "2014-07-10 10:21:12";
var timestamp = Date.parse(new Date(stringTime));
timestamp = timestamp / 1000;
return timestamp;
}

102
resources/views/weixin/goods/categoryGoodsList.blade.php

@ -12,7 +12,38 @@
@include('weixin.common.headerNav')
<div class="flool classlist" style="margin-top:4px;">
<!--导航左右滑动-start-->
<link rel="stylesheet" href="<?php echo env('APP_URL'); ?>/css/swiper.min.css">
<script type="text/javascript" src="<?php echo env('APP_URL'); ?>/js/swiper.min.js"></script>
<div class="swiper-nav">
<div class="swiper-wrapper">
<div class="swiper-slide"><a<?php if(0==$typeid){echo ' style="color:#ee5b03;border-bottom:1px solid #ee5b03;"';} ?> href="<?php echo route('weixin_category_goods_list'); ?>" data-id="0">全部</a></div>
<?php if($goodstype_list){foreach($goodstype_list as $k=>$v){ ?>
<div class="swiper-slide"><a style="<?php if($v['id']==$typeid){echo 'color:#ee5b03;border-bottom:1px solid #ee5b03;';} ?>" href="<?php echo route('weixin_category_goods_list',array('typeid'=>$v['id'])); ?>" data-id="<?php echo $v['id']; ?>"><?php echo $v['name']; ?></a></div>
<?php }} ?>
</div>
</div>
<style>
.swiper-nav{width:100%;height:50px;line-height:50px;border-bottom:1px solid #f0f0f0;background-color:#fff;}
.swiper-slide{text-align:center;font-size:18px;background:#fff;}
.swiper-slide a{display:block;}
</style>
<script>
var swiper = new Swiper('.swiper-nav', {
slidesPerView: 4 //一行4列显示
});
</script>
<!--导航左右滑动-end-->
<div class="floor guesslike">
<?php if($list){ ?>
<ul class="goodslist_limg mt10" id="goods_list">
<?php foreach($list as $k=>$v){ ?>
<li><a href="<?php echo $v['goods_detail_url']; ?>"><img alt="<?php echo $v['title']; ?>" src="<?php echo $v['litpic']; ?>"><div class="goods_info"><p class="goods_tit"><?php if($v['is_promote_goods']>0){ ?><span class="badge_comm" style="background-color:#f23030;">Hot</span> <?php } ?><?php echo $v['title']; ?></p><div class="goods_price">¥<b><?php echo $v['price']; ?></b><span class="fr"><?php echo $v['sale']; ?>人付款</span></div></div></a></li>
<?php } ?>
</ul><?php }else{ ?><div style="text-align:center;line-height:40px;color:#999;">暂无记录</div><?php } ?>
</div>
<!-- <div class="flool classlist" style="margin-top:4px;">
<div class="fl category1">
<ul>
<li<?php if(0==$typeid){echo ' class="on"';} ?>>
@ -26,9 +57,9 @@
</ul>
</div>
<div class="fr category2">
<?php if($goods_list){ ?>
<ul class="goods_list_small">
<?php foreach($goods_list as $k=>$v){ ?>
<?php if($list){ ?>
<ul class="goods_list_small" id="goods_list">
<?php foreach($list as $k=>$v){ ?>
<li><a href="<?php echo $v['goods_detail_url']; ?>"><img class="imgzsy" alt="<?php echo $v['title']; ?>" src="<?php echo $v['litpic']; ?>"><div class="goods_info"><p class="goods_tit"><?php if($v['is_promote_goods']>0){ ?><span class="badge_comm" style="background-color:#f23030;">Hot</span> <?php } ?><?php echo $v['title']; ?></p><div class="goods_price">¥<b><?php echo $v['price']; ?></b></div></div></a></li>
<?php } ?>
</ul>
@ -36,7 +67,68 @@
<div style="text-align:center;line-height:40px;color:#999;">暂无记录</div>
<?php } ?>
</div>
</div>
</div> -->
<script>
$(function(){
var ajaxload = false;
var maxpage = false;
var startpage = 1;
var totalpage = <?php echo $totalpage; ?>;
var tmp_url = window.location.href;
msg = tmp_url.split("#");
tmp_url = msg[0];
$(window).scroll(function ()
{
var listheight = $("#goods_list").outerHeight();
if ($(document).scrollTop() + $(window).height() >= listheight)
{
if(startpage >= totalpage)
{
//$("#submit_bt_one").html("已是最后一页,没有更多数据!");
return false;
}
if(!ajaxload && !maxpage)
{
ajaxload = true;
//$("#submit_bt_one").html("努力加载中...");
var url = tmp_url;
var nextpage = startpage+1;
$.get(url,{page_ajax:1,page:nextpage},function(res)
{
if(res)
{
$("#goods_list").append(res);
startpage++;
if(startpage >= totalpage)
{
maxpage = true;
//$("#submit_bt_one").html("已是最后一页,没有更多数据!");
}
else
{
//$("#submit_bt_one").html("点击加载更多");
}
ajaxload = false;
}
else
{
//$("#submit_bt_one").html("请求失败,请稍候再试!");
ajaxload = false;
}
},'json');
}
}
});
});
</script>
@include('weixin.common.footer')
</body></html>

36
resources/views/weixin/index/index.blade.php

@ -14,6 +14,7 @@
<!--顶部搜索栏-end-->
<!--顶部滚动广告栏-start-->
<?php if($slide_list){ ?>
<div class="tbanner">
<!-- Swiper -->
<div class="swiper-container">
@ -26,13 +27,14 @@
<div class="swiper-pagination swiper-pagination-white"></div>
</div>
</div>
<?php } ?>
<link rel="stylesheet" href="<?php echo env('APP_URL'); ?>/css/swiper.min.css">
<script type="text/javascript" src="<?php echo env('APP_URL'); ?>/js/swiper.min.js"></script>
<style>
.swiper-container{width:100%;height:auto;}
.swiper-slide{text-align:center;font-size:18px;background:#fff;}
.swiper-slide img{width:100%;height:40vw;}
</style>
<script type="text/javascript" src="<?php echo env('APP_URL'); ?>/js/swiper.min.js"></script>
<script>
//Swiper轮播
var swiper = new Swiper('.swiper-container', {
@ -58,22 +60,9 @@ var swiper = new Swiper('.swiper-container', {
<div class="swiper-slide">Slide 3</div>
<div class="swiper-slide">Slide 4</div>
<div class="swiper-slide">Slide 5</div>
<div class="swiper-slide">Slide 6</div>
<div class="swiper-slide">Slide 7</div>
<div class="swiper-slide">Slide 8</div>
<div class="swiper-slide">Slide 9</div>
<div class="swiper-slide">Slide 10</div>
<div class="swiper-slide">Slide 3</div>
<div class="swiper-slide">Slide 4</div>
<div class="swiper-slide">Slide 5</div>
<div class="swiper-slide">Slide 6</div>
<div class="swiper-slide">Slide 7</div>
<div class="swiper-slide">Slide 8</div>
<div class="swiper-slide">Slide 9</div>
<div class="swiper-slide">Slide 10</div>
</div>
</div>
<style>.swiper-nav {width: 100%;height: 50px;line-height:50px;border-bottom:1px solid #efefef;}</style>
<style>.swiper-nav{width: 100%;height: 50px;line-height:50px;border-bottom:1px solid #efefef;background-color:#fff;}</style>
<script>
var swiper = new Swiper('.swiper-nav', {
slidesPerView: 4 //一行4列显示
@ -186,23 +175,6 @@ var swiper = new Swiper('.swiper-nav', {
</div>
<!--猜您喜欢-end-->
<!--猜您喜欢-start-->
<!-- <div class="floor guesslike">
<ul class="goodslist_limg" id="goods_list">
<?php if($goods_list){foreach($goods_list as $k=>$v){ ?>
<li><a href="<?php echo $v['goods_detail_url']; ?>"><img alt="<?php echo $v['title']; ?>" src="<?php echo $v['litpic']; ?>"><div class="goods_info"><p class="goods_tit"><?php if($v['is_promote_goods']>0){ ?><span class="badge_comm" style="background-color:#f23030;">Hot</span> <?php } ?><?php echo $v['title']; ?></p><div class="goods_price">¥<b><?php echo $v['price']; ?></b><span class="fr"><?php echo $v['sale']; ?>人付款</span></div></div></a></li>
<?php }} ?>
</ul>
</div> -->
<style>
.goodslist_limg li{border-bottom:10px solid #f0f0f0;}
.goodslist_limg li img{width: 100%;height: auto;display: block;}
.goodslist_limg li .goods_info{padding:15px;}
.goodslist_limg li .goods_tit{line-height:1.5;font-size:20px;color:#333;}
.goodslist_limg li .goods_price{font-size:24px;color:#fe3939;}
.goodslist_limg li .fr{font-size:16px;color:#999;}
</style>
<!--猜您喜欢-end-->
<style>
.banner_tit{font-size:18px;font-weight:400;background-color:#fff;color:#f23030;height:46px;line-height:46px;padding-left:10px;padding-right:10px;border-bottom:1px solid #eee;text-align:center;}
</style>

2
resources/views/weixin/order/orderList.blade.php

@ -27,7 +27,7 @@
<style>
.swiper-nav{width:100%;height:46px;line-height:46px;border-bottom:1px solid #efefef;background:#fff;}
.swiper-slide{text-align:center;font-size:18px;background:#fff;}.swiper-slide a{color:#666;}
.swiper-slide-activate{color:#f23030;border-bottom:2px solid #f23030;}.swiper-slide-activate a{color:#f23030;}
.swiper-slide-activate{color:#f23030;border-bottom:1px solid #f23030;}.swiper-slide-activate a{color:#f23030;}
</style>
<script>
var swiper = new Swiper('.swiper-nav', {

Loading…
Cancel
Save