From db466238a0226645e0387657aab9207da3c02ccb Mon Sep 17 00:00:00 2001 From: "ZLW-PC\\Administrator" <374861669@qq.com> Date: Thu, 28 Sep 2017 17:47:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8F=E8=A7=88=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Admin/GoodsController.php | 16 +++- .../Api/UserGoodsHistoryController.php | 86 +++++++++++++++++++ .../Controllers/Weixin/ArticleController.php | 53 ++++++++++++ .../Controllers/Weixin/CommonController.php | 54 ++++++++++++ .../Controllers/Weixin/GoodsController.php | 3 +- .../Controllers/Weixin/IndexController.php | 44 ++-------- .../Controllers/Weixin/UserController.php | 20 ++--- app/Http/Model/Goods.php | 17 ++-- app/Http/Model/UserGoodsHistory.php | 14 ++- resources/views/admin/goods/edit.blade.php | 1 + .../{index => article}/category.blade.php | 0 .../{index => article}/detail.blade.php | 2 +- .../weixin/{index => goods}/goods.blade.php | 0 .../{index => goods}/goodslist.blade.php | 0 resources/views/weixin/index/index.blade.php | 4 +- resources/views/weixin/index/jump.blade.php | 47 ++++++++++ .../weixin/user/userGoodsHistory.blade.php | 29 ++----- routes/web.php | 14 ++- 18 files changed, 313 insertions(+), 91 deletions(-) create mode 100644 app/Http/Controllers/Api/UserGoodsHistoryController.php create mode 100644 app/Http/Controllers/Weixin/ArticleController.php rename resources/views/weixin/{index => article}/category.blade.php (100%) rename resources/views/weixin/{index => article}/detail.blade.php (94%) rename resources/views/weixin/{index => goods}/goods.blade.php (100%) rename resources/views/weixin/{index => goods}/goodslist.blade.php (100%) create mode 100644 resources/views/weixin/index/jump.blade.php diff --git a/app/Http/Controllers/Admin/GoodsController.php b/app/Http/Controllers/Admin/GoodsController.php index c1adc72..b7912ab 100644 --- a/app/Http/Controllers/Admin/GoodsController.php +++ b/app/Http/Controllers/Admin/GoodsController.php @@ -77,7 +77,10 @@ class GoodsController extends CommonController unset($_POST["_token"]); if(isset($_POST['editorValue'])){unset($_POST['editorValue']);} - + if(isset($_POST['promote_start_date'])){$_POST['promote_start_date'] = strtotime($_POST['promote_start_date']);} + if(isset($_POST['promote_end_date'])){$_POST['promote_end_date'] = strtotime($_POST['promote_end_date']);} + if(empty($_POST['promote_price'])){unset($_POST['promote_price']);} + if(DB::table('goods')->insert(array_filter($_POST))) { success_jump('添加成功!', route('admin_goods')); @@ -93,7 +96,11 @@ class GoodsController extends CommonController if(!empty($_GET["id"])){$id = $_GET["id"];}else {$id="";}if(preg_match('/[0-9]*/',$id)){}else{exit;} $data['id'] = $id; - $data['post'] = object_to_array(DB::table('goods')->where('id', $id)->first(), 1); + $goods = DB::table('goods')->where('id', $id)->first(); + if($goods->promote_start_date != 0){$goods->promote_start_date = date('Y-m-d H:i:s',$goods->promote_start_date);} + if($goods->promote_end_date != 0){$goods->promote_end_date = date('Y-m-d H:i:s',$goods->promote_end_date);} + + $data['post'] = object_to_array($goods, 1); return view('admin.goods.edit', $data); } @@ -125,7 +132,10 @@ class GoodsController extends CommonController unset($_POST["_token"]); if(isset($_POST['editorValue'])){unset($_POST['editorValue']);} - + if(isset($_POST['promote_start_date'])){$_POST['promote_start_date'] = strtotime($_POST['promote_start_date']);} + if(isset($_POST['promote_end_date'])){$_POST['promote_end_date'] = strtotime($_POST['promote_end_date']);} + if(empty($_POST['promote_price'])){unset($_POST['promote_price']);} + if(DB::table('goods')->where('id', $id)->update($_POST)) { success_jump('修改成功!', route('admin_goods')); diff --git a/app/Http/Controllers/Api/UserGoodsHistoryController.php b/app/Http/Controllers/Api/UserGoodsHistoryController.php new file mode 100644 index 0000000..8fae967 --- /dev/null +++ b/app/Http/Controllers/Api/UserGoodsHistoryController.php @@ -0,0 +1,86 @@ +input('limit', 10); + $data['offset'] = $request->input('offset', 0); + + $data['user_id'] = Token::$uid; + + $res = UserGoodsHistory::getList($data); + if($res === false) + { + return ReturnData::create(ReturnData::SYSTEM_FAIL); + } + + return ReturnData::create(ReturnData::SUCCESS,$res); + } + + //我的足迹添加 + public function userGoodsHistoryAdd(Request $request) + { + //参数 + $data['goods_id'] = $request->input('goods_id',null); + $data['user_id'] = Token::$uid; + + if($data['goods_id']===null || $data['user_id']===null) + { + return ReturnData::create(ReturnData::PARAMS_ERROR); + } + + $res = UserGoodsHistory::add($data); + if($res === false) + { + return ReturnData::create(ReturnData::SYSTEM_FAIL); + } + + return ReturnData::create(ReturnData::SUCCESS,$res); + } + + //删除一条我的足迹 + public function userGoodsHistoryDelete(Request $request) + { + //参数 + $id = $request->input('id',null); + + $res = UserGoodsHistory::remove($id,Token::$uid); + if($res === false) + { + return ReturnData::create(ReturnData::SYSTEM_FAIL); + } + + return ReturnData::create(ReturnData::SUCCESS,$res); + } + + //清空我的足迹 + public function userGoodsHistoryClear(Request $request) + { + //参数 + $user_id = Token::$uid; + + $res = UserGoodsHistory::remove($user_id); + if($res === false) + { + return ReturnData::create(ReturnData::SYSTEM_FAIL); + } + + return ReturnData::create(ReturnData::SUCCESS,$res); + } +} \ No newline at end of file diff --git a/app/Http/Controllers/Weixin/ArticleController.php b/app/Http/Controllers/Weixin/ArticleController.php new file mode 100644 index 0000000..cb95c33 --- /dev/null +++ b/app/Http/Controllers/Weixin/ArticleController.php @@ -0,0 +1,53 @@ + $cat + ); + $url = env('APP_API_URL')."/arctype_detail"; + $arctype_detail = curl_request($url,$postdata,'GET'); + $data['post'] = $arctype_detail['data']; + + //文章列表 + $postdata = array( + 'limit' => 10, + 'offset' => 0 + ); + $url = env('APP_API_URL')."/article_list"; + $article_list = curl_request($url,$postdata,'GET'); + $data['article_list'] = $article_list['data']['list']; + + return view('weixin.article.category', $data); + } + + //文章详情页 + public function detail($id) + { + //最新资讯 + $postdata = array( + 'id' => $id + ); + $url = env('APP_API_URL')."/article_detail"; + $article_detail = curl_request($url,$postdata,'GET'); + if(empty($article_detail['data'])){return redirect()->route('weixin_page404');} + $article_detail['data']['body'] = preg_replace('/src=\"\/uploads\/allimg/',"src=\"".env('APP_URL')."/uploads/allimg",$article_detail['data']['body']); + $data['post'] = $article_detail['data']; + + return view('weixin.article.detail', $data); + } + +} \ No newline at end of file diff --git a/app/Http/Controllers/Weixin/CommonController.php b/app/Http/Controllers/Weixin/CommonController.php index 975937b..4d282f1 100644 --- a/app/Http/Controllers/Weixin/CommonController.php +++ b/app/Http/Controllers/Weixin/CommonController.php @@ -9,4 +9,58 @@ class CommonController extends Controller { parent::__construct(); } + + /** + * 操作错误跳转的快捷方法 + * @access protected + * @param string $msg 错误信息 + * @param string $url 页面跳转地址 + * @param mixed $time 当数字时指定跳转时间 + * @return void + */ + public function error_jump($msg='', $url='', $time=3) + { + if ($url=='' && isset($_SERVER["HTTP_REFERER"])) + { + $url = $_SERVER["HTTP_REFERER"]; + } + + if(!headers_sent()) + { + header("Location:".route('weixin_jump')."?error=$msg&url=$url&time=$time"); + exit(); + } + else + { + $str = ""; + exit($str); + } + } + + /** + * 操作成功跳转的快捷方法 + * @access protected + * @param string $msg 提示信息 + * @param string $url 页面跳转地址 + * @param mixed $time 当数字时指定跳转时间 + * @return void + */ + public function success_jump($msg='', $url='', $time=1) + { + if ($url=='' && isset($_SERVER["HTTP_REFERER"])) + { + $url = $_SERVER["HTTP_REFERER"]; + } + + if(!headers_sent()) + { + header("Location:".route('weixin_jump')."?message=$msg&url=$url&time=$time"); + exit(); + } + else + { + $str = ""; + exit($str); + } + } } diff --git a/app/Http/Controllers/Weixin/GoodsController.php b/app/Http/Controllers/Weixin/GoodsController.php index 5e47be5..89d8762 100644 --- a/app/Http/Controllers/Weixin/GoodsController.php +++ b/app/Http/Controllers/Weixin/GoodsController.php @@ -32,7 +32,6 @@ class GoodsController extends CommonController $goods_list = curl_request($url,$postdata,'GET'); $data['goods_list'] = $goods_list['data']['list']; - return view('weixin.index.goodslist', $data); + return view('weixin.goods.goodslist', $data); } - } \ No newline at end of file diff --git a/app/Http/Controllers/Weixin/IndexController.php b/app/Http/Controllers/Weixin/IndexController.php index 8a68c33..0c3db28 100644 --- a/app/Http/Controllers/Weixin/IndexController.php +++ b/app/Http/Controllers/Weixin/IndexController.php @@ -11,6 +11,12 @@ class IndexController extends CommonController { parent::__construct(); } + + //页面跳转 + public function jump() + { + return view('weixin.index.jump'); + } //首页 public function index() @@ -45,44 +51,6 @@ class IndexController extends CommonController return view('weixin.index.index',$data); } - //列表页 - public function category($cat) - { - //文章分类 - $postdata = array( - 'id' => $cat - ); - $url = env('APP_API_URL')."/arctype_detail"; - $arctype_detail = curl_request($url,$postdata,'GET'); - $data['post'] = $arctype_detail['data']; - - //文章列表 - $postdata = array( - 'limit' => 10, - 'offset' => 0 - ); - $url = env('APP_API_URL')."/article_list"; - $article_list = curl_request($url,$postdata,'GET'); - $data['article_list'] = $article_list['data']['list']; - - return view('weixin.index.category', $data); - } - - //文章详情页 - public function detail($id) - { - //最新资讯 - $postdata = array( - 'id' => $id - ); - $url = env('APP_API_URL')."/article_detail"; - $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); - } - //标签详情页,共有3种显示方式,1正常列表,2列表显示文章,3显示描述 public function tag($tag, $page=0) { diff --git a/app/Http/Controllers/Weixin/UserController.php b/app/Http/Controllers/Weixin/UserController.php index 6638239..b2cfded 100644 --- a/app/Http/Controllers/Weixin/UserController.php +++ b/app/Http/Controllers/Weixin/UserController.php @@ -13,7 +13,7 @@ class UserController extends CommonController //个人中心 public function index(Request $request) - { + {$_SESSION['weixin_user_info']['access_token'] = '72d623d26a1a6d61186a97f9ccf752f7'; 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');} @@ -38,23 +38,15 @@ class UserController extends CommonController //浏览记录 public function userGoodsHistory(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( 'limit' => 10, - 'offset' => 0 + 'offset' => 0, + 'access_token' => $_SESSION['weixin_user_info']['access_token'] ); - $url = env('APP_API_URL')."/goods_list"; - $goods_list = curl_request($url,$postdata,'GET'); - $data['goods_list'] = $goods_list['data']['list']; + $url = env('APP_API_URL')."/user_goods_history_list"; + $res = curl_request($url,$postdata,'GET'); + $data['user_goods_history'] = $res['data']['list']; return view('weixin.user.userGoodsHistory', $data); } diff --git a/app/Http/Model/Goods.php b/app/Http/Model/Goods.php index 388f2c4..1266d72 100644 --- a/app/Http/Model/Goods.php +++ b/app/Http/Model/Goods.php @@ -31,9 +31,9 @@ class Goods extends BaseModel //protected $connection = 'connection-name'; //常用字段 - protected static $common_field = [ + protected static $common_field = array( 'id', 'typeid', 'tuijian', 'click', 'title', 'sn', 'price','litpic', 'pubdate', 'add_time', 'market_price', 'goods_number', 'sale', 'comments','promote_start_date','promote_price','promote_end_date','goods_img','spec','point' - ]; + ); const STATUS = 0; //商品是否删除,0未删除 @@ -110,13 +110,20 @@ class Goods extends BaseModel return $res; } - public static function getOne($id) + public static function getOne(array $param) { - if(isset($status)){$where['status'] = $status;}else{$where['status'] = self::STATUS;} + extract($param); + + $model = new Goods; + $where['id'] = $id; - $goods = self::where($where)->first(); + if(isset($where)){$model = $model->where($where);} + if(isset($field)){$model = $model->select($field);} + + $goods = $model->first(); + $goods['goods_detail_url'] = route('weixin_goods_detail',array('id'=>$goods->id)); $goods['price'] = self::get_final_price($id); return $goods; diff --git a/app/Http/Model/UserGoodsHistory.php b/app/Http/Model/UserGoodsHistory.php index 77057ed..36f6004 100644 --- a/app/Http/Model/UserGoodsHistory.php +++ b/app/Http/Model/UserGoodsHistory.php @@ -36,6 +36,16 @@ class UserGoodsHistory extends BaseModel if($res['count']>0) { $res['list'] = $model->skip($offset)->take($limit)->orderBy('id','desc')->get(); + + if($res['list']) + { + foreach($res['list'] as $k=>$v) + { + $goods = Goods::getOne(array('id'=>$v['goods_id'],'field'=>array('id', 'typeid', 'tuijian', 'click', 'title', 'sn', 'price','litpic', 'pubdate', 'add_time', 'market_price', 'goods_number', 'sale', 'comments','promote_start_date','promote_price','promote_end_date','goods_img','spec','point'))); + + $res['list'][$k]['goods'] = $goods; + } + } } else { @@ -77,9 +87,9 @@ class UserGoodsHistory extends BaseModel } //删除一条记录 - public static function remove($id) + public static function remove($id,$user_id) { - if (self::whereIn('id', explode(',', $id))->delete() === false) + if (self::whereIn('id', explode(',', $id))->where('user_id',$user_id)->delete() === false) { return false; } diff --git a/resources/views/admin/goods/edit.blade.php b/resources/views/admin/goods/edit.blade.php index 3b9fc70..04e7536 100644 --- a/resources/views/admin/goods/edit.blade.php +++ b/resources/views/admin/goods/edit.blade.php @@ -2,6 +2,7 @@ @section('title', '商品信息修改') @section('content') +
商品列表 > 修改商品
{{ csrf_field() }} diff --git a/resources/views/weixin/index/category.blade.php b/resources/views/weixin/article/category.blade.php similarity index 100% rename from resources/views/weixin/index/category.blade.php rename to resources/views/weixin/article/category.blade.php diff --git a/resources/views/weixin/index/detail.blade.php b/resources/views/weixin/article/detail.blade.php similarity index 94% rename from resources/views/weixin/index/detail.blade.php rename to resources/views/weixin/article/detail.blade.php index 4d7eb27..93d381a 100644 --- a/resources/views/weixin/index/detail.blade.php +++ b/resources/views/weixin/article/detail.blade.php @@ -37,7 +37,7 @@  
3.客户还可以通过交易所的咨询电话进行查询:0755-2288800(深市),021-16893006(沪市)投资者所查到的配号是投资者在一个帐户上申购新股所得配号的起始号,其余配号依次顺延.
-
下:
+ @include('weixin.common.footer') \ No newline at end of file diff --git a/resources/views/weixin/index/goods.blade.php b/resources/views/weixin/goods/goods.blade.php similarity index 100% rename from resources/views/weixin/index/goods.blade.php rename to resources/views/weixin/goods/goods.blade.php diff --git a/resources/views/weixin/index/goodslist.blade.php b/resources/views/weixin/goods/goodslist.blade.php similarity index 100% rename from resources/views/weixin/index/goodslist.blade.php rename to resources/views/weixin/goods/goodslist.blade.php diff --git a/resources/views/weixin/index/index.blade.php b/resources/views/weixin/index/index.blade.php index c210768..01f93d3 100644 --- a/resources/views/weixin/index/index.blade.php +++ b/resources/views/weixin/index/index.blade.php @@ -140,9 +140,9 @@ var swiper = new Swiper('.swiper-nav', {
diff --git a/resources/views/weixin/index/jump.blade.php b/resources/views/weixin/index/jump.blade.php new file mode 100644 index 0000000..5610c87 --- /dev/null +++ b/resources/views/weixin/index/jump.blade.php @@ -0,0 +1,47 @@ + + +跳转提示 + + + +
+ +

:)

+

+ +

:(

+

+ +

+

页面自动 跳转 等待时间:

+
+ + \ No newline at end of file diff --git a/resources/views/weixin/user/userGoodsHistory.blade.php b/resources/views/weixin/user/userGoodsHistory.blade.php index 36975ba..311dbb8 100644 --- a/resources/views/weixin/user/userGoodsHistory.blade.php +++ b/resources/views/weixin/user/userGoodsHistory.blade.php @@ -1,33 +1,22 @@ -商城 +我的足迹
返回
我的足迹
- +
diff --git a/routes/web.php b/routes/web.php index 729f71d..b1a3dfe 100644 --- a/routes/web.php +++ b/routes/web.php @@ -57,11 +57,11 @@ Route::group(['prefix' => 'weixin', 'namespace' => 'Weixin'], function () { Route::get('/', 'IndexController@index')->name('weixin'); Route::get('/page404', 'IndexController@page404')->name('weixin_page404'); //404页面 Route::get('/search', '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('/p/{id}', 'ArticleController@detail')->name('weixin_article_detail'); //文章详情页 + Route::get('/cat{cat}', 'ArticleController@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_detail'); //商品详情页 + Route::get('/goods/{id}', 'GoodsController@goods')->name('weixin_goods_detail'); //商品详情页 Route::get('/goodslist', 'GoodsController@goodslist')->name('weixin_goods_list'); //产品分类页 Route::get('/user', 'UserController@index')->name('weixin_user'); @@ -71,6 +71,8 @@ Route::group(['prefix' => 'weixin', 'namespace' => 'Weixin'], function () { Route::get('/user_address_list', 'AddressController@index')->name('weixin_user_address_list'); + //页面跳转 + Route::get('/jump', 'IndexController@jump')->name('weixin_jump'); Route::get('/test', 'IndexController@test')->name('weixin_test'); //测试 }); @@ -233,6 +235,10 @@ Route::group(['prefix' => 'dataapi', 'namespace' => 'Api', 'middleware' => ['web Route::get('/user_money_list', 'UserMoneyController@userMoneyList'); //用户余额明细 Route::post('/user_money_add', 'UserMoneyController@userMoneyAdd'); //添加余额明细 //浏览记录 + Route::get('/user_goods_history_list', 'UserGoodsHistoryController@userGoodsHistoryList'); //我的足迹列表 + Route::get('/user_goods_history_delete', 'UserGoodsHistoryController@userGoodsHistoryDelete'); //我的足迹删除一条 + Route::get('/user_goods_history_clear', 'UserGoodsHistoryController@userGoodsHistoryClear'); //我的足迹清空 + //商品评价 Route::get('/goods_comment_list', 'CommentController@goodsCommentList'); //商品评价列表 Route::post('/goods_comment_add', 'CommentController@goodsCommentAdd'); //商品评价添加