Browse Source

文章详情

master
ZLW-PC\Administrator 7 years ago
parent
commit
4dbc898a46
  1. 3
      .env.example
  2. 11
      app/Common/Helper.php
  3. 15
      app/Http/Controllers/Api/ArticleController.php
  4. 44
      app/Http/Controllers/Weixin/IndexController.php
  5. 17
      app/Http/Model/Article.php
  6. 12
      app/Http/Model/Goods.php
  7. 6
      resources/views/weixin/404.blade.php
  8. 13
      resources/views/weixin/index/index.blade.php
  9. 22
      routes/web.php

3
.env.example

@ -6,7 +6,8 @@ APP_LOG_LEVEL=debug
APP_URL=http://localhost
APP_DOMAIN=www.lqycms.com
APP_SUBDOMAIN=m.lqycms.com
APP_API_URL=http://localhost/dataapi
APP_API_URL=http://www.lqycms.com/dataapi
APP_WEIXIN_URL=http://www.lqycms.com/weixin
DB_CONNECTION=mysql
DB_HOST=127.0.0.1

11
app/Common/Helper.php

@ -274,4 +274,15 @@ class Helper
return $result;
}
//判断访问终端是否是微信浏览器
public static function isWechatBrowser()
{
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false)
{
return true;
}
return false;
}
}

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

@ -30,4 +30,19 @@ class ArticleController extends CommonController
return ReturnData::create(ReturnData::SUCCESS,$res);
}
public function articleDetail(Request $request)
{
//参数
$data['id'] = $request->input('id');
$data['ischeck'] = Article::IS_CHECK;
$res = Article::getOne($data);
if($res === false)
{
return ReturnData::create(ReturnData::SYSTEM_FAIL);
}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
}

44
app/Http/Controllers/Weixin/IndexController.php

@ -19,7 +19,7 @@ class IndexController extends CommonController
'limit' => 5,
'offset' => 0
);
$url = env('APP_API')."/slide_list";
$url = env('APP_API_URL')."/slide_list";
$slide_list = json_decode(http_request_post($url,$postdata,'GET'),true);
$data['slide_list'] = $slide_list['data']['list'];
@ -28,10 +28,19 @@ class IndexController extends CommonController
'limit' => 5,
'offset' => 0
);
$url = env('APP_API')."/article_list";
$url = env('APP_API_URL')."/article_list";
$article_list = json_decode(http_request_post($url,$postdata,'GET'),true);
$data['article_list'] = $article_list['data']['list'];
//商品列表
$postdata = array(
'limit' => 10,
'offset' => 0
);
$url = env('APP_API_URL')."/goods_list";
$goods_list = json_decode(http_request_post($url,$postdata,'GET'),true);
$data['goods_list'] = $goods_list['data']['list'];
return view('weixin.index.index',$data);
}
@ -75,26 +84,17 @@ class IndexController extends CommonController
//文章详情页
public function detail($id)
{
if(empty($id) || !preg_match('/[0-9]+/',$id)){return redirect()->route('page404');}
if(cache("detailid$id")){$post = cache("detailid$id");}else{$post = object_to_array(DB::table('article')->where('id', $id)->first(), 1);if(empty($post)){return redirect()->route('page404');}$post['name'] = DB::table('arctype')->where('id', $post['typeid'])->value('name');cache(["detailid$id"=>$post], \Carbon\Carbon::now()->addMinutes(2592000));}
if($post)
{
$cat = $post['typeid'];
$post['body'] = ReplaceKeyword($post['body']);
if(!empty($post['writer'])){$post['writertitle']=$post['title'].' '.$post['writer'];}
$data['post'] = $post;
$data['pre'] = get_article_prenext(array('aid'=>$post["id"],'typeid'=>$post["typeid"],'type'=>"pre"));
}
else
{
return redirect()->route('page404');
}
if(cache("catid$cat")){$post=cache("catid$cat");}else{$post = object_to_array(DB::table('arctype')->where('id', $cat)->first(), 1);cache(["catid$cat"=>$post], \Carbon\Carbon::now()->addMinutes(2592000));}
//文章详情
$postdata = array(
'id' => $id,
'aa' => 1
);
$url = env('APP_API_URL')."/article_detail";
$article_detail = json_decode(http_request_post($url,$postdata,'GET'),true);dd(http_request_post($url,$postdata,'GET'));
//if(empty($article_detail['data'])){return redirect()->route('weixin_page404');}
//$data['article_detail'] = $article_detail['data'];
return view('home.index.'.$post['temparticle'], $data);
return view('weixin.index.detail', $data);
}
//标签详情页,共有3种显示方式,1正常列表,2列表显示文章,3显示描述
@ -271,7 +271,7 @@ class IndexController extends CommonController
//404页面
public function page404()
{
return view('home.404');
return view('weixin.404');
}
//测试页面

17
app/Http/Model/Article.php

@ -86,6 +86,14 @@ class Article extends BaseModel
if($res['count']>0)
{
$res['list'] = $model->select(self::$common_field)->orderBy('id', 'desc')->skip($offset)->take($limit)->get();
if($res['list'])
{
foreach($res['list'] as $k=>$v)
{
$res['list'][$k]->article_detail_url = route('weixin_article_detail',array('id'=>$v->id));
}
}
}
else
{
@ -95,9 +103,14 @@ class Article extends BaseModel
return $res;
}
public static function getOne($id)
public static function getOne($param)
{
return self::where('id', $id)->first();
extract($param);
$where['id'] = $id;
if(isset($ischeck)){$where['ischeck'] = $ischeck;}
return self::where($where)->first();
}
public static function add(array $data)

12
app/Http/Model/Goods.php

@ -96,7 +96,15 @@ class Goods extends BaseModel
if($res['count']>0)
{
$res['list'] = $model->select(self::$common_field)->skip($offset)->take($limit)->orderBy('id','desc')->get()->toArray();
$res['list'] = $model->select(self::$common_field)->skip($offset)->take($limit)->orderBy('id','desc')->get();
if($res['list'])
{
foreach($res['list'] as $k=>$v)
{
$res['list'][$k]->goods_detail_url = route('weixin_goods_detail',array('id'=>$v->id));
}
}
}
return $res;
@ -107,7 +115,7 @@ class Goods extends BaseModel
if(isset($status)){$where['status'] = $status;}else{$where['status'] = self::STATUS;}
$where['id'] = $id;
$goods = self::where($where)->first()->toArray();
$goods = self::where($where)->first();
$goods['price'] = self::get_final_price($id);

6
resources/views/weixin/404.blade.php

@ -1,10 +1,12 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport">
<title>您访问的页面不存在或已被删除!</title>
<meta http-equiv="refresh" content="3;URL=<?php echo route('weixin'); ?>">
<style type="text/css">
*{padding:0;margin:0;}
body{background:#fff;font-family:'微软雅黑';color:#333;font-size:16px;}
.system-message{padding:24px 48px;margin:5% auto 0 auto;width:600px;}
.system-message{padding:24px 48px;margin:5% auto 0 auto;}
.system-message h1{font-size:100px;font-weight:normal;line-height:120px;margin-bottom:12px;}
.system-message .jump{padding-top:10px}
.system-message .jump a{color:#333;}
@ -15,6 +17,6 @@ body{background:#fff;font-family:'微软雅黑';color:#333;font-size:16px;}
<div class="system-message">
<h1>:(</h1>
<p class="error">您访问的页面不存在或已被删除!</p>
<p class="detail"><a href="<?php echo route('home');?>">返回首页</a></p>
<p class="detail"><a href="<?php echo route('weixin'); ?>">返回首页</a></p>
</div>
</body></html>

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

@ -1,7 +1,7 @@
<!DOCTYPE html><html><head><meta http-equiv="content-type" content="text/html;charset=utf-8"/>
<title>商城</title><meta content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport">
<link href="<?php echo env('APP_URL'); ?>/css/weixin/style.css" type="text/css" rel="stylesheet">
<script type="text/javascript" src="<?php echo env('APP_WEIXIN'); ?>/js/jquery.min.js"></script>
<script type="text/javascript" src="<?php echo env('APP_WEIXIN_URL'); ?>/js/jquery.min.js"></script>
<meta name="keywords" content="关键词"><meta name="description" content="描述"></head><body>
<!--顶部搜索栏-start-->
<div id="search-placeholder" class="search">
@ -127,7 +127,7 @@ var swiper = new Swiper('.swiper-nav', {
<div class="home_toutiao_box">
<ul>
<marquee id="mar1" scrollamount="1" direction="up" height="30" style="height: 30px;">
<?php foreach($article_list as $k=>$v){ ?><li><a href="/Weixin/index.php?m=Article&amp;a=arclist&amp;id=38"><?php echo $v['title']; ?></a></li><?php } ?>
<?php foreach($article_list as $k=>$v){ ?><li><a href="<?php echo $v['article_detail_url']; ?>"><?php echo $v['title']; ?></a></li><?php } ?>
</marquee>
</ul>
</div>
@ -140,12 +140,9 @@ var swiper = new Swiper('.swiper-nav', {
<div class="banner_tit"><img src="images/weixin/ind_52.jpg" alt="猜您喜欢"/></div>
<div class="likeshop">
<ul class="goods_list" id="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 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 echo $v['title']; ?></p><div class="goods_price">¥<b><?php echo $v['price']; ?></b></div></div></a></li>
<?php } ?>
</ul>
</div>
</div>

22
routes/web.php

@ -56,21 +56,19 @@ Route::group(['namespace' => 'Home'], function () {
//微信路由
Route::group(['prefix' => 'weixin', 'namespace' => 'Weixin'], function () {
Route::get('/', 'IndexController@index')->name('weixin');
Route::get('/page404', 'IndexController@page404')->name('page404'); //404页面
Route::get('/page404', 'IndexController@page404')->name('weixin_page404'); //404页面
Route::get('/tags', 'IndexController@tags')->name('weixin_tags');
Route::get('/search/{id}', 'IndexController@search')->name('weixin_search'); //搜过页面
Route::get('/p/{id}', 'IndexController@detail')->name('weixin_detail'); //详情页
Route::get('/cat{cat}/{page}', 'IndexController@category'); //分类页,分页
Route::get('/cat{cat}', 'IndexController@category')->name('weixin_category'); //分类页
Route::get('/tag{tag}/{page}', 'IndexController@tag'); //标签页,分页
Route::get('/p/{id}', 'IndexController@detail')->name('weixin_article_detail'); //文章详情页
Route::get('/cat{cat}', 'IndexController@category')->name('weixin_article_category'); //分类页
Route::get('/tag{tag}', 'IndexController@tag')->name('weixin_tag'); //标签页
Route::get('/page/{id}', 'IndexController@page')->name('weixin_singlepage'); //单页
Route::get('/goods/{id}', 'IndexController@goods')->name('weixin_goods'); //商品详情页
Route::get('/goods/{id}', 'IndexController@goods')->name('weixin_goods_detail'); //商品详情页
Route::get('/goodstype{cat}/{page}', 'IndexController@goodstype'); //产品分类页,分页
Route::get('/goodstype{cat}', 'IndexController@goodstype')->name('weixin_goodstype'); //产品分类页
Route::get('/sitemap.xml', 'IndexController@sitemap')->name('weixin_sitemap');//sitemap
Route::get('/test', 'IndexController@test')->name('weixin_test'); //测试
Route::get('/test', 'IndexController@test')->name('weixin_test'); //测试
});
@ -210,9 +208,14 @@ Route::group(['middleware' => ['web']], function () {
Route::group(['prefix' => 'dataapi', 'namespace' => 'Api', 'middleware' => ['web']], function () {
//轮播图
Route::get('/slide_list', 'SlideController@slideList');
//文章列表
//文章
Route::get('/article_list', 'ArticleController@articleList');
Route::get('/article_detail', 'ArticleController@articleDetail');
//商品
Route::get('/goods_list', 'GoodsController@goodsList'); //商品列表
Route::get('/goodstype_list', 'GoodsTypeController@goodsTypeList'); //商品分类列表
});
//API接口路由,需token验证
Route::group(['prefix' => 'dataapi', 'namespace' => 'Api', 'middleware' => ['web','token']], function () {
//用户中心
@ -224,9 +227,6 @@ Route::group(['prefix' => 'dataapi', 'namespace' => 'Api', 'middleware' => ['web
Route::get('/user_money_list', 'UserMoneyController@userMoneyList'); //用户余额明细
Route::post('/user_money_add', 'UserMoneyController@userMoneyAdd'); //添加余额明细
//浏览记录
//商品
Route::get('/goods_list', 'GoodsController@goodsList'); //商品列表
Route::get('/goodstype_list', 'GoodsTypeController@goodsTypeList'); //商品分类列表
//商品评价
Route::get('/goods_comment_list', 'CommentController@goodsCommentList'); //商品评价列表
Route::post('/goods_comment_add', 'CommentController@goodsCommentAdd'); //商品评价添加

Loading…
Cancel
Save