Browse Source

product->goods

master
林一峰 7 years ago
parent
commit
f616cd6b07
  1. 69
      app/Http/Controllers/Api/IndexController.php
  2. 2
      app/Http/Controllers/Api/WechatAuthController.php
  3. 899
      lqycms.sql
  4. 2
      resources/views/wap/index/index.blade.php
  5. 1
      routes/web.php

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

@ -34,5 +34,72 @@ class IndexController extends CommonController
return ReturnData::create(ReturnData::SUCCESS,array('url'=>'http://www.baidu.com'));
}
//文章列表页
public function listarc()
{
$res["code"] = 0;
$res["msg"] = "success";
$res["data"] = "";
$where = array();
$result = "";
$PageIndex = request('PageIndex',1);
$PageSize = request('PageSize', sysconfig('CMS_PAGESIZE'));
$skip = ($PageIndex-1)*$PageSize;
$typeid = request('typeid');if(!empty($typeid)){ $where['typeid']=$typeid; }
$tuijian = request('tuijian');if(!empty($tuijian)){ $where['tuijian']=$tuijian; }
$field = array('field','id,typeid,click,title,writer,litpic,pubdate');
$orderby = request('orderby',['pubdate','desc']);
$mname = request('mname','article');
$model = \DB::table($mname);
if($where){$model = $model->where($where);}
if($orderby == 'rand()'){$model = $model->orderBy(\DB::raw('rand()'));}else{$model = $model->orderBy($orderby[0], $orderby[1]);}
$count = $model->count();
$list = object_to_array($model->skip($skip)->take($PageSize)->get());
if(!empty($list) && $PageIndex<=10)
{
/* foreach($list as $key=>$row)
{
//$list[$key]["pubdate"] = date("Y-m-d", $list[$key]["pubdate"]);
$result .= '<div class="list">';
if(!empty($row['litpic']) && file_exists($_SERVER['DOCUMENT_ROOT'].$row['litpic']))
{
$result .= '<a class="';
//判断图片长宽
if(getimagesize($row['litpic'])[0]>getimagesize($row['litpic'])[1])
{
$result .= 'limg';
}
else
{
$result .= 'simg';
}
$result .= '" href="'.WEBHOST.'/p/'.$row['id'].'"><img alt="'.$row['title'].'" src="'.$row['litpic'].'"></a>';
}
$result .= '<strong class="tit"><a href="'.WEBHOST.'/p/'.$row['id'].'">'.$row['title'].'</a></strong><p>'.mb_strcut(strip_tags($row['description']),0,126,'UTF-8').'..<a href="'.WEBHOST.'/p/'.$row['id'].'" class="more">[详情]</a></p>';
$result .= '<div class="info"><span class="fl"><i class="pub-v"></i><em>'.date("Y-m-d H:i",$row['pubdate']).'</em></span><span class="fr"><em>'.$row['click'].'</em>人阅读</span></div><div class="cl"></div></div>';
} */
foreach($list as $key=>$row)
{
$list[$key]["url"] = get_front_url(array("id"=>$row['id'],"type"=>'content'));
$list[$key]["pubdate"] = date("Y-m-d", $list[$key]["pubdate"]);
}
$res["data"] = $list;
}
/* $result['List']=$list;
$result['Count']=$count>0?$count:0; */
//return $res;
exit(json_encode($res));
}
}

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

@ -3,7 +3,7 @@ namespace App\Http\Controllers\Api;
use App\Http\Controllers\Api\CommonController;
//微信auth2.0
//微信auth2.0
class WechatAuthController extends CommonController
{
public $appid = 'wxba09d9f0fed4b84b'; //微信APPID,公众平台获取

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

2
resources/views/wap/index/index.blade.php

@ -8,7 +8,7 @@
<article class="mbanner-b mb10"><a href=""><img src="/images/banner.jpg"></a></article>
<article class="mbox"><h3 class="tit"><i class="tit_icon"></i>产品中心</h3><div class="mpicshow-b">
<ul class="mnewpic2"><?php $posts=arclist(array("table"=>"product","row"=>4,"typeid"=>1,"expression"=>[["litpic","<>","''"]]));if($posts){foreach($posts as $row){ ?>
<ul class="mnewpic2"><?php $posts=arclist(array("table"=>"goods","row"=>4,"typeid"=>1,"expression"=>[["litpic","<>","''"]]));if($posts){foreach($posts as $row){ ?>
<li><a href="<?php echo get_wap_front_url(array("id"=>$row['id'],"catid"=>$row['typeid'],"type"=>'content')); ?>"><img src="<?php echo sysconfig('CMS_BASEHOST'); echo $row['litpic']; ?>" alt="<?php echo $row['title']; ?>"></a></li><?php }} ?>
</ul><div class="more"><a href="<?php echo get_wap_front_url(array('catid'=>1,'type'=>'productlist')); ?>">查看更多<i class="mico"></i></a></div>
</div></article>

1
routes/web.php

@ -181,6 +181,7 @@ Route::group(['prefix' => 'fladmin', 'namespace' => 'Admin', 'middleware' => ['w
//接口路由,无需token验证
Route::group(['middleware' => ['web']], function () {
Route::post('/dataapi/listarc', 'Api\IndexController@listarc')->name('api_listarc');
Route::post('/dataapi/customer_login', 'Api\WechatAuthController@customerLogin');
Route::post('/dataapi/', 'Api\UserController@signin'); //签到
});

Loading…
Cancel
Save