Browse Source

no message

master
林一峰 7 years ago
parent
commit
ae6ae01796
  1. 2
      app/Http/Controllers/Api/ArticleController.php
  2. 4
      app/Http/Controllers/Api/GoodsController.php
  3. 24
      app/Http/Controllers/Weixin/CartController.php
  4. 14
      app/Http/Controllers/Weixin/GoodsController.php
  5. 32
      app/Http/Model/Cart.php
  6. 2
      app/Http/Model/UserGoodsHistory.php
  7. 27
      public/css/weixin/style.css
  8. 219
      resources/views/weixin/cart/index.blade.php
  9. 29
      resources/views/weixin/goods/goodsDetail.blade.php
  10. 4
      resources/views/weixin/index/index.blade.php
  11. 1
      routes/web.php

2
app/Http/Controllers/Api/ArticleController.php

@ -54,6 +54,8 @@ class ArticleController extends CommonController
$res->pubdate = date('Y-m-d H:i',$res->pubdate);
$res->addtime = date('Y-m-d H:i',$res->addtime);
\DB::table('article')->where(array('id'=>$data['id']))->increment('click', 1);
return ReturnData::create(ReturnData::SUCCESS,$res);
}
}

4
app/Http/Controllers/Api/GoodsController.php

@ -18,10 +18,14 @@ class GoodsController extends CommonController
{
//参数
$data['id'] = $request->input('id','');
$user_id = $request->input('user_id','');
if($data['id']==''){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$res = Goods::goodsDetail($data);
if($user_id){$res->is_collect = \DB::table('collect_goods')->where(array('user_id'=>$user_id,'goods_id'=>$data['id']))->count();}
\DB::table('goods')->where(array('id'=>$data['id']))->increment('click', 1);
return ReturnData::create(ReturnData::SUCCESS,$res);
}

24
app/Http/Controllers/Weixin/CartController.php

@ -14,23 +14,23 @@ class CartController extends CommonController
//商品列表
public function index(Request $request)
{
if($request->input('typeid', '') != ''){$data['typeid'] = $request->input('typeid');}
if($request->input('tuijian', '') != ''){$data['tuijian'] = $request->input('tuijian');}
if($request->input('keyword', '') != ''){$data['keyword'] = $request->input('keyword');}
if($request->input('status', '') != ''){$data['status'] = $request->input('status');}
if($request->input('is_promote', '') != ''){$data['is_promote'] = $request->input('is_promote');}
if($request->input('orderby', '') != ''){$data['orderby'] = $request->input('orderby');}
if($request->input('max_price', '') != ''){$data['max_price'] = $request->input('max_price');}else{$data['max_price'] = 99999;}
if($request->input('min_price', '') != ''){$data['min_price'] = $request->input('min_price');}else{$data['min_price'] = 0;}
//购物车列表
$postdata = array(
'access_token' => $_SESSION['weixin_user_info']['access_token']
);
$url = env('APP_API_URL')."/cart_list";
$res = curl_request($url,$postdata,'GET');
$data['list'] = $res['data']['list'];
//商品列表
//猜你喜欢商品列表
$postdata = array(
'limit' => 10,
'limit' => 4,
'orderby'=> 1,
'offset' => 0
);
$url = env('APP_API_URL')."/goods_list";
$goods_list = curl_request($url,$postdata,'GET');
$data['goods_list'] = $goods_list['data']['list'];
$res = curl_request($url,$postdata,'GET');
$data['like_goods_list'] = $res['data']['list'];
return view('weixin.cart.index', $data);
}

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

@ -15,16 +15,26 @@ class GoodsController extends CommonController
//商品详情
public function goodsDetail($id)
{
//商品列表
$postdata = array(
'id' => $id
);
if(isset($_SESSION['weixin_user_info'])){$postdata['user_id']=$_SESSION['weixin_user_info']['id'];}
$url = env('APP_API_URL')."/goods_detail";
$res = curl_request($url,$postdata,'GET');
$data['post'] = $res['data'];
if(!$data['post']){$this->error_jump(ReturnCode::NO_FOUND,route('weixin'),3);}
//添加浏览记录
if(isset($_SESSION['weixin_user_info']))
{
$postdata = array(
'goods_id' => $id,
'access_token' => $_SESSION['weixin_user_info']['access_token']
);
$url = env('APP_API_URL')."/user_goods_history_add";
curl_request($url,$postdata,'POST');
}
return view('weixin.goods.goodsDetail', $data);
}

32
app/Http/Model/Cart.php

@ -26,31 +26,40 @@ class Cart extends BaseModel
{
extract($param); //参数:limit,offset
$goods = self::join('goods', 'goods.id', '=', 'cart.goods_id')
$model = self::join('goods', 'goods.id', '=', 'cart.goods_id')
->where('cart.user_id', $user_id)
->where('goods.status', Goods::STATUS)
->select('cart.*','goods.id as goods_id','goods.title','goods.sn','goods.price as goods_price','goods.market_price','goods.litpic as goods_thumb_img','goods.goods_number as stock','goods.promote_start_date','goods.promote_price','goods.promote_end_date')
->get();
->select('cart.*','goods.id as goods_id','goods.title','goods.sn','goods.price as goods_price','goods.market_price','goods.litpic','goods.goods_number as stock','goods.promote_start_date','goods.promote_price','goods.promote_end_date');
$res['count'] = $model->count();
$res['list'] = array();
if($goods)
if($res['count']>0)
{
foreach ($goods as $k => $v)
$res['list'] = $model->get();
foreach ($res['list'] as $k => $v)
{
$goods[$k]->is_promote = 0;
if(Goods::bargain_price($v->goods_price,$v->promote_start_date,$v->promote_end_date) > 0){$goods[$k]->is_promote = 1;}
$res['list'][$k]->is_promote = 0;
if(Goods::bargain_price($v->goods_price,$v->promote_start_date,$v->promote_end_date) > 0){$res['list'][$k]->is_promote = 1;}
//订货数量大于0
if ($v->goods_number > 0)
{
$goods[$k]->final_price = Goods::get_final_price($v->goods_id); //商品最终价格
$res['list'][$k]->final_price = Goods::get_final_price($v->goods_id); //商品最终价格
$res['list'][$k]->goods_detail_url = route('weixin_goods_detail',array('id'=>$v->goods_id));
//更新购物车中的商品数量
//self::where('id', $v->id)->update(array('price' => $goods_price));
}
}
}
else
{
return false;
}
return $goods;
return $res;
}
public static function getOne($where)
@ -83,7 +92,8 @@ class Cart extends BaseModel
//删除一条记录
public static function remove($id,$user_id)
{
if (self::whereIn('id', explode(',', $id))->where('user_id',$user_id)->delete() === false)
if(!is_array($id)){$id = explode(',', $id);}
if (self::whereIn('id', $id)->where('user_id',$user_id)->delete() === false)
{
return false;
}

2
app/Http/Model/UserGoodsHistory.php

@ -66,6 +66,8 @@ class UserGoodsHistory extends BaseModel
public static function add(array $data)
{
if(self::where($data)->first()){return false;}
if (!self::where($data)->first())
{
$data['add_time'] = time();

27
public/css/weixin/style.css

@ -292,29 +292,10 @@ margin:5px 0
.banner_headline .tit{border-top:1px dashed #dedede;text-align:center;margin:25px 0;}
.banner_headline .tit h4{color:#666666;background-color:#f1f1f1;font-size:18px;font-weight:normal;position:relative;top:-12px;display:inline;padding:0 20px;}
.radio .che span {
margin-left: .21333rem;
vertical-align: sub
}
.radio .check_t i {
background-position: -.768rem 0
}
.radio .check_t i {background-position: -30px 0}
.radio i {
width:22px;
height:22px;
display: block;
float: left;
background-image: url("../../images/weixin/check.png");
background-repeat: no-repeat;
background-size: cover;
background-position: 0
}
.signup-find span,.radio span {
font-size:24px;
cursor: pointer
}
.radio i {width:22px;height:22px;display: block;float: left;background-image: url("../../images/weixin/check.png");background-repeat: no-repeat;background-size: cover;background-position: 0}
.signup-find span,.radio span {font-size:24px;cursor: pointer}
.sc_list {
padding:10px;
@ -886,7 +867,7 @@ color: #666;
border-left: 3px solid #FF0036;border-bottom: 1px solid #f4f4f4;}
.goods-content .module-content{padding:10px;}
.bottom_tool_black{ width:100%; display:block; position:fixed; bottom:0;background-color:#fff;border-top:1px solid #f1f1f1;}
.bottom_tool_black{ width:100%; display:block; position:fixed; bottom:0;background-color:#fff;border-top:1px solid #f1f1f1;z-index:2;}
.bottom_tool_white { width:40%; float:left;}
.bottom_tool_white li { width:50%; float:left; text-align:center; position:relative;}
.bottom_tool_white ul li img{ margin:0 auto; display:block; margin-top:2px; width:32px; height:32px;}

219
resources/views/weixin/cart/index.blade.php

@ -24,93 +24,49 @@
<div class="cart_list">
<!--商品列表-s-->
<div class="sc_list" id="cart_list_13">
<?php if($list){foreach($list as $k=>$v){ ?>
<div class="sc_list" id="cart_list_<?php echo $v['id']; ?>">
<div class="radio-img">
<div class="radio fl ">
<!--商品勾选按钮-->
<span onclick="checkGoods(this)" class="che">
<i>
<input name="checkItem" type="checkbox" style="display:none;" value="13">
<input name="checkItem" type="checkbox" style="display:none;" data-goods-id="<?php echo $v['goods_id']; ?>">
</i>
</span>
</div>
<div class="shopimg fl">
<a href="/index.php/Mobile/Goods/goodsInfo/id/135.html">
<!--商品图片-->
<img src="<?php echo env('APP_URL'); ?>/images/weixin/goods_thumb_135_200_200.jpeg">
<a href="<?php echo $v['goods_detail_url']; ?>">
<img src="<?php echo $v['litpic']; ?>">
</a>
</div>
</div>
<div class="deleshow">
<div class="deletes">
<!--商品名-->
<p class="tit">重庆电信手机卡电话卡语音卡选靓号3G4G卡内部5折卡低资费(飞)</p>
<p class="tit"><?php echo $v['title']; ?></p>
<!--删除按钮-->
<a href="javascript:void(0);" class="delescj deleteGoods" data-cart-id="13"><img src="<?php echo env('APP_URL'); ?>/images/weixin/dele.png"></a>
<a href="javascript:void(0);" class="delescj deleteGoods" data-cart-id="<?php echo $v['id']; ?>"><img src="<?php echo env('APP_URL'); ?>/images/weixin/dele.png"></a>
</div>
<!--商品属性,规格-->
<p class="weight">合约套餐:乐享4G套餐59元</p>
<p class="weight"></p>
<div class="prices">
<p class="sc_pri fl">
<!--商品单价-->
<span></span><span>54.28</span>
<span></span><span id="goods_price<?php echo $v['goods_id']; ?>"><?php echo $v['final_price']; ?></span>
</p>
<!--加减数量-->
<div class="plus fr get_mp">
<span class="mp_minous disable">-</span>
<span class="mp_mp">
<input name="changeQuantity_13" type="text" id="changeQuantity_13" value="1" onkeyup="this.value=this.value.replace(/[^\d]/g,'')" class="input-num">
</span>
<span class="mp_plus">+</span>
</div>
</div>
</div>
</div>
<!--商品列表-e-->
<!--商品列表-s-->
<div class="sc_list" id="cart_list_13">
<div class="radio-img">
<div class="radio fl ">
<!--商品勾选按钮-->
<span onclick="checkGoods(this)" class="che">
<i>
<input name="checkItem" type="checkbox" style="display:none;" value="13">
</i>
</span>
</div>
<div class="shopimg fl">
<a href="/index.php/Mobile/Goods/goodsInfo/id/135.html">
<!--商品图片-->
<img src="<?php echo env('APP_URL'); ?>/images/weixin/goods_thumb_135_200_200.jpeg">
</a>
</div>
</div>
<div class="deleshow">
<div class="deletes">
<!--商品名-->
<p class="tit">重庆电信手机卡电话卡语音卡选靓号3G4G卡内部5折卡低资费(飞)</p>
<!--删除按钮-->
<a href="javascript:void(0);" class="delescj deleteGoods" data-cart-id="13"><img src="<?php echo env('APP_URL'); ?>/images/weixin/dele.png"></a>
</div>
<!--商品属性,规格-->
<p class="weight">合约套餐:乐享4G套餐59元</p>
<div class="prices">
<p class="sc_pri fl">
<!--商品单价-->
<span></span><span>54.28</span>
</p>
<!--加减数量-->
<div class="plus fr get_mp">
<span class="mp_minous disable">-</span>
<span class="mp_mp">
<input name="changeQuantity_13" type="text" id="changeQuantity_13" value="1" onkeyup="this.value=this.value.replace(/[^\d]/g,'')" class="input-num">
</span>
<span class="mp_plus">+</span>
<span class="mp_minous" onClick="change_goods_number(1,<?php echo $v['goods_id']; ?>)">-</span>
<span class="mp_mp"><input name="goods_number<?php echo $v['goods_id']; ?>" type="text" id="goods_number<?php echo $v['goods_id']; ?>" value="<?php echo $v['goods_number']; ?>" onkeyup="this.value=this.value.replace(/[^\d]/g,'')" autocomplete="off" value="1" onblur="change_goods_number(2,<?php echo $v['goods_id']; ?>)" class="input-num"></span>
<span class="mp_plus" onClick="change_goods_number(3,<?php echo $v['goods_id']; ?>)">+</span>
</div>
</div>
</div>
</div>
<?php }} ?>
<!--商品列表-e-->
<!--提交栏-s-->
<div class="foohi foohiext">
<div class="payit ma-to-20 payallb">
@ -124,25 +80,20 @@
<a href="javascript:void(0);" onclick="cart_submit();">去结算</a>
</div>
<div class="youbia">
<p><span class="pmo">总计:</span><span></span><span id="total_fee">919.08</span></p>
<p><span class="pmo">总计:</span><span></span><span id="total_fee">0</span></p>
</div>
</div>
</div>
<!--提交栏-e-->
<script type="text/javascript">
$(document).ready(function(){
initDecrement();
initCheckBox();
});
</script>
</div>
<?php if(!$list){ ?>
<!--购物车没有商品-start-->
<div class="cart_list">
<div class="nonenothing">
<img src="<?php echo env('APP_URL'); ?>/images/weixin/nothing.png">
<p>购物车暂无商品</p>
<a href="/index.php/Mobile/Index/index.html">去逛逛</a>
<a href="<?php echo route('weixin'); ?>">去逛逛</a>
</div>
</div>
<br><br>
@ -155,15 +106,139 @@
</div>
<div class="likeshop">
<ul class="goods_list">
<li><a href="detail.html"><img alt="1" src="images/weixin/goods_thumb_400_400.jpeg"><div class="goods_info"><p class="goods_tit">美女真空凸点诱惑</p><div class="goods_price"><b>100.00</b></div></div></a></li>
<li><a href="detail.html"><img alt="2" src="images/weixin/goods_thumb_400_400.jpeg"><div class="goods_info"><p class="goods_tit">性感小骚货在床上</p><div class="goods_price"><b>100.00</b></div></div></a></li>
<li><a href="detail.html"><img alt="3" src="images/weixin/goods_thumb_400_400.jpeg"><div class="goods_info"><p class="goods_tit">小野猫嫩模大尺度写真</p><div class="goods_price"><b>100.00</b></div></div></a></li>
<li><a href="detail.html"><img alt="4" src="images/weixin/goods_thumb_400_400.jpeg"><div class="goods_info"><p class="goods_tit">韩国嫩模的逆天身材</p><div class="goods_price"><b>100.00</b></div></div></a></li>
<li><a href="detail.html"><img alt="5" src="images/weixin/goods_thumb_400_400.jpeg"><div class="goods_info"><p class="goods_tit">推女郎林夕图片</p><div class="goods_price"><b>100.00</b></div></div></a></li>
<li><a href="detail.html"><img alt="6" src="images/weixin/goods_thumb_400_400.jpeg"><div class="goods_info"><p class="goods_tit">性感闺蜜艺术照</p><div class="goods_price"><b>100.00</b></div></div></a></li>
<?php if($like_goods_list){foreach($like_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 echo $v['title']; ?></p><div class="goods_price">¥<b><?php echo $v['price']; ?></b></div></div></a></li>
<?php }} ?>
</ul>
</div>
</div>
<!--购物车没有商品-end-->
<?php } ?>
<br><br>
<script type="text/javascript" src="<?php echo env('APP_URL'); ?>/js/layer/mobile/layer.js"></script>
<script>
function change_goods_number(type, id)
{
var goods_number = document.getElementById('goods_number'+id).value;
if(type != 2)
{
var goods_number = document.getElementById('goods_number'+id).value;
document.getElementById('goods_number'+id).value = goods_number;
}
if(type == 1){goods_number--;}
if(type == 3){goods_number++;}
if(goods_number <= 0){goods_number=1;}
if(!/^[0-9]*$/.test(goods_number)){goods_number = document.getElementById('goods_number'+id).value;}
document.getElementById('goods_number'+id).value = goods_number;
var access_token = '<?php echo $_SESSION['weixin_user_info']['access_token']; ?>';
var url = '<?php echo env('APP_API_URL').'/cart_add'; ?>';
$.post(url,{access_token:access_token,goods_id:id,goods_number:goods_number},function(res)
{
if (res.code == 0)
{
changeCartTotalPrice();
}
else if (res.msg != '')
{
//提示
layer.open({
content: '姓名不能为空'
,skin: 'msg'
,time: 2 //2秒后自动关闭
});
var goods_number = document.getElementById('goods_number'+id).value;
document.getElementById('goods_number'+id).value = goods_number;
}
}, 'json');
}
//删除购物车商品
$(function () {
//删除购物车商品事件
$(document).on("click", '.deleteGoods', function (e) {
var access_token = '<?php echo $_SESSION['weixin_user_info']['access_token']; ?>';
var cart_ids = new Array();
cart_ids.push($(this).attr('data-cart-id'));
layer.open({
content: '确定要删除此商品吗'
,btn: ['确定', '取消']
,yes: function(index){
layer.close(index);
$.ajax({
type : "POST",
url:"<?php echo env('APP_API_URL').'/cart_delete'; ?>",
dataType:'json',
data: {access_token:access_token,id:cart_ids},
success: function(res){
layer.open({
content: res.msg
,skin: 'msg'
,time: 2 //2秒后自动关闭
});
window.location.reload();
}
});
}
});
})
});
//勾选商品
function checkGoods(obj)
{
if($(obj).hasClass('check_t'))
{
//改变颜色
$(obj).removeClass('check_t');
//取消选中
$(obj).find('input').attr('checked',false);
}
else
{
//改变颜色
$(obj).addClass('check_t');
//勾选选中
$(obj).find('input').attr('checked',true);
}
//选中全选多选框
if($(obj).hasClass('checkFull'))
{
if($(obj).hasClass('check_t'))
{
$(".che").each(function(i,o){
$(this).addClass('check_t');
$(this).find('input').attr('checked',true);
});
}
else
{
$(".che").each(function(i,o){
$(this).removeClass('check_t');
$(this).find('input').attr('checked',false);
});
}
}
changeCartTotalPrice();
}
//修改选中商品总价
function changeCartTotalPrice()
{
var total_price = 0;
$('[name="checkItem"][checked]').each(function(){
var goods_id = $(this).attr('data-goods-id');
total_price = total_price + $('#goods_number'+goods_id).val() * $('#goods_price'+goods_id).text();
});
$('#total_fee').text(total_price);
}
</script>
</body></html>

29
resources/views/weixin/goods/goodsDetail.blade.php

@ -58,11 +58,11 @@ var swiper = new Swiper('.swiper-container', {
<!--顶部滚动广告栏-end-->
<div class="goods-header">
<span class="wish-add fr wish-add-activate">收藏</span><h1 class="title"><?php echo $post['title']; ?></h1>
<span class="wish-add fr<?php if(isset($post['is_collect']) && $post['is_collect']>=1){echo ' wish-add-activate';} ?>" onclick="collect_goods()">收藏</span><h1 class="title"><?php echo $post['title']; ?></h1>
<div class="goods-price">
<div class="current-price">
<span>¥</span><i class="price"><?php echo $post['price']; ?></i>
<span></span><i class="price"><?php echo $post['price']; ?></i>
</div>
<span class="btn-retail">门店有售</span>
@ -222,6 +222,31 @@ function dosubmit()
$("#master").hide();
}
function collect_goods()
{
var url = '<?php if(isset($post['is_collect']) && $post['is_collect']>=1){echo env('APP_API_URL').'/collect_goods_delete';}else{echo env('APP_API_URL').'/collect_goods_add';} ?>';
var access_token = '<?php echo $_SESSION['weixin_user_info']['access_token']; ?>';
var goods_id = $("#id").val();
$.post(url,{access_token:access_token,goods_id:goods_id},function(res)
{
if(res.code==0)
{
window.location.reload();
}
else
{
}
layer.open({
content: res.msg
,skin: 'msg'
,time: 2 //2秒后自动关闭
});
},'json');
}
</script>
<!-- 底部按钮开始 -->

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

@ -108,11 +108,11 @@ var swiper = new Swiper('.swiper-nav', {
<img src="images/weixin/icon_16.png" alt="我的订单" />
<span>我的订单</span>
</a>
<a href="http://www.shop.com/index.php/mobile/Cart/index.html">
<a href="<?php echo route('weixin_cart'); ?>">
<img src="images/weixin/icon_17.png" alt="购物车" />
<span>购物车</span>
</a>
<a href="http://www.shop.com/index.php/mobile/User/index.html">
<a href="<?php echo route('weixin_user'); ?>">
<img src="images/weixin/icon_19.png" alt="个人中心" />
<span>个人中心</span>
</a>

1
routes/web.php

@ -145,6 +145,7 @@ Route::group(['prefix' => 'dataapi', 'namespace' => 'Api', 'middleware' => ['web
Route::get('/user_goods_history_list', 'UserGoodsHistoryController@userGoodsHistoryList'); //我的足迹列表
Route::post('/user_goods_history_delete', 'UserGoodsHistoryController@userGoodsHistoryDelete'); //我的足迹删除一条
Route::post('/user_goods_history_clear', 'UserGoodsHistoryController@userGoodsHistoryClear'); //我的足迹清空
Route::post('/user_goods_history_add', 'UserGoodsHistoryController@userGoodsHistoryAdd'); //我的足迹添加
//商品评价
Route::get('/goods_comment_list', 'CommentController@goodsCommentList'); //商品评价列表

Loading…
Cancel
Save