diff --git a/.env.example b/.env.example index e931227..740cabd 100644 --- a/.env.example +++ b/.env.example @@ -3,7 +3,7 @@ APP_ENV=local APP_KEY=base64:KcBF6sf3T6Pv8CsflCK93UT6j7Xh6Zdyj+/H1XG1WYc= APP_DEBUG=true APP_LOG_LEVEL=debug -APP_URL=http://localhost +APP_URL=http://www.lqycms.com APP_DOMAIN=www.lqycms.com APP_SUBDOMAIN=m.lqycms.com APP_API_URL=http://www.lqycms.com/dataapi diff --git a/app/Common/function.php b/app/Common/function.php index fa0c2f1..cf93616 100644 --- a/app/Common/function.php +++ b/app/Common/function.php @@ -2,7 +2,7 @@ // 公共函数文件 if (! function_exists('curl_request')) { - function curl_request($api, $method = 'GET', $params = array(), $headers = array()) + function curl_request($api, $params = array(), $method = 'GET', $headers = array()) { $curl = curl_init(); @@ -29,7 +29,7 @@ if (! function_exists('curl_request')) curl_setopt($curl, CURLOPT_POSTFIELDS, $params); break; } - + curl_setopt($curl, CURLOPT_URL, $api); curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); @@ -865,9 +865,7 @@ function http_request_post($url,$data,$type='POST') $options = array( 'http' => array( 'method' => $type, - 'header' => - "Content-type: application/x-www-form-urlencoded\r\n" . - "Content-length: $content_length\r\n", + 'header' => "Content-type: application/x-www-form-urlencoded\r\n" . "Content-length: $content_length\r\n", 'content' => $content ) ); diff --git a/app/Http/Controllers/Api/ArticleController.php b/app/Http/Controllers/Api/ArticleController.php index 4c10a8a..aec6265 100644 --- a/app/Http/Controllers/Api/ArticleController.php +++ b/app/Http/Controllers/Api/ArticleController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers\Api; use App\Http\Controllers\Api\CommonController; use Illuminate\Http\Request; +use Log; use App\Common\ReturnData; use App\Http\Model\Article; diff --git a/app/Http/Controllers/Weixin/IndexController.php b/app/Http/Controllers/Weixin/IndexController.php index 7111c12..e1a946a 100644 --- a/app/Http/Controllers/Weixin/IndexController.php +++ b/app/Http/Controllers/Weixin/IndexController.php @@ -20,7 +20,7 @@ class IndexController extends CommonController 'offset' => 0 ); $url = env('APP_API_URL')."/slide_list"; - $slide_list = json_decode(http_request_post($url,$postdata,'GET'),true); + $slide_list = json_decode(curl_request($url,$postdata,'GET'),true); $data['slide_list'] = $slide_list['data']['list']; //最新资讯 @@ -29,7 +29,7 @@ class IndexController extends CommonController 'offset' => 0 ); $url = env('APP_API_URL')."/article_list"; - $article_list = json_decode(http_request_post($url,$postdata,'GET'),true); + $article_list = json_decode(curl_request($url,$postdata,'GET'),true); $data['article_list'] = $article_list['data']['list']; //商品列表 @@ -38,7 +38,7 @@ class IndexController extends CommonController 'offset' => 0 ); $url = env('APP_API_URL')."/goods_list"; - $goods_list = json_decode(http_request_post($url,$postdata,'GET'),true); + $goods_list = json_decode(curl_request($url,$postdata,'GET'),true); $data['goods_list'] = $goods_list['data']['list']; return view('weixin.index.index',$data); @@ -84,15 +84,14 @@ class IndexController extends CommonController //文章详情页 public function detail($id) { - //文章详情 + //最新资讯 $postdata = array( - 'id' => $id, - 'aa' => 1 + 'id' => $id ); $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']; + $article_detail = curl_request($url,$postdata,'GET'); + if(empty($article_detail['data'])){return redirect()->route('weixin_page404');} + $data['post'] = $article_detail['data']; return view('weixin.index.detail', $data); } diff --git a/app/Http/Model/Article.php b/app/Http/Model/Article.php index 96394c9..ba2dcc7 100644 --- a/app/Http/Model/Article.php +++ b/app/Http/Model/Article.php @@ -103,7 +103,7 @@ class Article extends BaseModel return $res; } - public static function getOne($param) + public static function getOne(array $param) { extract($param); diff --git a/resources/views/weixin/index/index.blade.php b/resources/views/weixin/index/index.blade.php index da40e13..5f11a38 100644 --- a/resources/views/weixin/index/index.blade.php +++ b/resources/views/weixin/index/index.blade.php @@ -1,5 +1,5 @@ -商城 +微商城 diff --git a/routes/web.php b/routes/web.php index 250c490..49df997 100644 --- a/routes/web.php +++ b/routes/web.php @@ -16,7 +16,7 @@ Route::group(['domain' => env('APP_SUBDOMAIN'), 'namespace' => 'Wap'], function Route::get('/', 'IndexController@index')->name('wap_home'); Route::get('/page404', 'IndexController@page404')->name('wap_page404'); //404页面 Route::get('/tags', 'IndexController@tags')->name('wap_tags'); - Route::get('/search/{id}', 'IndexController@search')->name('wap_search'); //搜过页面 + Route::get('/search/{id}', 'IndexController@search')->name('wap_search'); //搜索页面 Route::get('/p/{id}', 'IndexController@detail')->name('wap_detail'); //详情页 Route::get('/cat{cat}/{page}', 'IndexController@category'); //分类页,分页 Route::get('/cat{cat}', 'IndexController@category')->name('wap_category'); //分类页 @@ -35,7 +35,7 @@ Route::group(['namespace' => 'Home'], function () { Route::get('/', 'IndexController@index')->name('home'); Route::get('/page404', 'IndexController@page404')->name('page404'); //404页面 Route::get('/tags', 'IndexController@tags')->name('home_tags'); - Route::get('/search/{id}', 'IndexController@search')->name('home_search'); //搜过页面 + Route::get('/search/{id}', 'IndexController@search')->name('home_search'); //搜索页面 Route::get('/p/{id}', 'IndexController@detail')->name('home_detail'); //详情页 Route::get('/cat{cat}/{page}', 'IndexController@category'); //分类页,分页 Route::get('/cat{cat}', 'IndexController@category')->name('home_category'); //分类页 @@ -58,7 +58,7 @@ Route::group(['prefix' => 'weixin', 'namespace' => 'Weixin'], function () { Route::get('/', 'IndexController@index')->name('weixin'); 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('/search/{id}', 'IndexController@search')->name('weixin_search'); //搜索页面 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'); //标签页