From 4be3713e4baee51f8b27fa1a34721c9a18e020a5 Mon Sep 17 00:00:00 2001 From: "ZLW-PC\\Administrator" <374861669@qq.com> Date: Sat, 2 Dec 2017 16:01:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=8C=E7=BB=B4=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Common/Helper.php | 48 ++++++- app/Common/function.php | 26 ++-- .../Admin/GoodsBrandController.php | 84 ++++++++++++ app/Http/Controllers/Api/QrcodeController.php | 3 +- .../Controllers/Api/UserMessageController.php | 82 ++++++++++++ .../Controllers/Home/CommonController.php | 2 +- .../Controllers/Weixin/IndexController.php | 16 +-- .../Controllers/Weixin/UserController.php | 50 ++++++- app/Http/Model/GoodsBrand.php | 80 ++++++++++++ app/Http/Model/UserMessage.php | 84 ++++++++++++ public/css/weixin/style.css | 4 +- .../views/admin/GoodsBrand/add.blade.php | 108 ++++++++++++++++ .../views/admin/GoodsBrand/edit.blade.php | 122 ++++++++++++++++++ .../views/admin/GoodsBrand/index.blade.php | 29 +++++ resources/views/weixin/index/index.blade.php | 2 +- resources/views/weixin/user/index.blade.php | 4 +- .../views/weixin/user/register.blade.php | 2 +- .../weixin/user/userMessageList.blade.php | 95 ++++++++++++++ .../views/weixin/user/userinfo.blade.php | 16 +++ routes/web.php | 12 ++ 20 files changed, 842 insertions(+), 27 deletions(-) create mode 100644 app/Http/Controllers/Admin/GoodsBrandController.php create mode 100644 app/Http/Controllers/Api/UserMessageController.php create mode 100644 app/Http/Model/GoodsBrand.php create mode 100644 app/Http/Model/UserMessage.php create mode 100644 resources/views/admin/GoodsBrand/add.blade.php create mode 100644 resources/views/admin/GoodsBrand/edit.blade.php create mode 100644 resources/views/admin/GoodsBrand/index.blade.php create mode 100644 resources/views/weixin/user/userMessageList.blade.php diff --git a/app/Common/Helper.php b/app/Common/Helper.php index bbbc1b0..9ddd24a 100644 --- a/app/Common/Helper.php +++ b/app/Common/Helper.php @@ -314,5 +314,51 @@ class Helper if($_SERVER['SERVER_PORT'] == 443) return true; return false; - } + } + + /** + * @name php获取中文字符拼音首字母 + * @param $str + * @return null|string + */ + public function getFirstCharter($str) + { + if (empty($str)) + { + return ''; + } + + $fchar = ord($str{0}); + if ($fchar >= ord('A') && $fchar <= ord('z')) return strtoupper($str{0}); + $s1 = iconv('UTF-8', 'gb2312', $str); + $s2 = iconv('gb2312', 'UTF-8', $s1); + $s = $s2 == $str ? $s1 : $str; + $asc = ord($s{0}) * 256 + ord($s{1}) - 65536; + + if ($asc >= -20319 && $asc <= -20284) return 'A'; + if ($asc >= -20283 && $asc <= -19776) return 'B'; + if ($asc >= -19775 && $asc <= -19219) return 'C'; + if ($asc >= -19218 && $asc <= -18711) return 'D'; + if ($asc >= -18710 && $asc <= -18527) return 'E'; + if ($asc >= -18526 && $asc <= -18240) return 'F'; + if ($asc >= -18239 && $asc <= -17923) return 'G'; + if ($asc >= -17922 && $asc <= -17418) return 'H'; + if ($asc >= -17417 && $asc <= -16475) return 'J'; + if ($asc >= -16474 && $asc <= -16213) return 'K'; + if ($asc >= -16212 && $asc <= -15641) return 'L'; + if ($asc >= -15640 && $asc <= -15166) return 'M'; + if ($asc >= -15165 && $asc <= -14923) return 'N'; + if ($asc >= -14922 && $asc <= -14915) return 'O'; + if ($asc >= -14914 && $asc <= -14631) return 'P'; + if ($asc >= -14630 && $asc <= -14150) return 'Q'; + if ($asc >= -14149 && $asc <= -14091) return 'R'; + if ($asc >= -14090 && $asc <= -13319) return 'S'; + if ($asc >= -13318 && $asc <= -12839) return 'T'; + if ($asc >= -12838 && $asc <= -12557) return 'W'; + if ($asc >= -12556 && $asc <= -11848) return 'X'; + if ($asc >= -11847 && $asc <= -11056) return 'Y'; + if ($asc >= -11055 && $asc <= -10247) return 'Z'; + + return ''; + } } \ No newline at end of file diff --git a/app/Common/function.php b/app/Common/function.php index cf93616..412fa81 100644 --- a/app/Common/function.php +++ b/app/Common/function.php @@ -647,15 +647,9 @@ function get_keywords($keyword) } //获取二维码 -function get_erweima($url="") +function get_erweima($url='',$size=150) { - Vendor('phpqrcode.qrlib'); - - $url = str_replace("%26","&",$url); - $url = str_replace("%3F","?",$url); - $url = str_replace("%3D","=",$url); - - return QRcode::png($url, false, "H", 6); + return 'data:image/png;base64,'.base64_encode(\QrCode::format('png')->encoding('UTF-8')->size($size)->margin(0)->errorCorrection('H')->generate($url)); } //根据栏目id获取栏目信息 @@ -1145,7 +1139,21 @@ function get_table_columns($table, $field='') return $res; } - +function http_host($flag=true) +{ + $res = ''; + $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://"; + if($flag) + { + $res = "$protocol$_SERVER[HTTP_HOST]"; + } + else + { + $res = "$protocol$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; //完整网址 + } + + return $res; +} diff --git a/app/Http/Controllers/Admin/GoodsBrandController.php b/app/Http/Controllers/Admin/GoodsBrandController.php new file mode 100644 index 0000000..99e41dd --- /dev/null +++ b/app/Http/Controllers/Admin/GoodsBrandController.php @@ -0,0 +1,84 @@ +select('add_time', 'title', 'litpic', 'status', 'listorder', 'cover_img', 'click')->orderBy('id', 'desc')->get()); + return view('admin.GoodsBrand.index', $data); + } + + public function doadd() + { + $_POST['add_time'] = time();//更新时间 + $_POST['click'] = rand(200,500);//点击 + + unset($_POST["_token"]); + if(isset($_POST['editorValue'])){unset($_POST['editorValue']);} + + if(DB::table("goods_brand")->insert($_POST)) + { + success_jump('添加成功!'); + } + else + { + error_jump('添加失败!请修改后重新添加'); + } + } + + public function add() + { + return view('admin.GoodsBrand.add'); + } + + public function edit() + { + 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_brand')->where('id', $id)->first(), 1); + + return view('admin.GoodsBrand.edit', $data); + } + + public function doedit() + { + if(!empty($_POST["id"])){$id = $_POST["id"];unset($_POST["id"]);}else {$id="";exit;} + + unset($_POST["_token"]); + if(isset($_POST['editorValue'])){unset($_POST['editorValue']);} + + if(DB::table('goods_brand')->where('id', $id)->update($_POST)) + { + success_jump('修改成功!', route('admin_goodsbrand')); + } + else + { + error_jump('修改失败!请修改后重新添加'); + } + } + + public function del() + { + if(!empty($_GET["id"])){$id = $_GET["id"];}else{error_jump("删除失败!请重新提交");} //if(preg_match('/[0-9]*/',$id)){}else{exit;} + + if(DB::table('goods_brand')->whereIn("id", explode(',', $id))->delete()) + { + success_jump('删除成功'); + } + else + { + error_jump("删除失败!请重新提交"); + } + } +} \ No newline at end of file diff --git a/app/Http/Controllers/Api/QrcodeController.php b/app/Http/Controllers/Api/QrcodeController.php index b9a1103..eaa4027 100644 --- a/app/Http/Controllers/Api/QrcodeController.php +++ b/app/Http/Controllers/Api/QrcodeController.php @@ -32,7 +32,8 @@ class QrcodeController extends CommonController $url = str_replace("%3F","?",$url); $url = str_replace("%3D","=",$url); - require_once base_path('resources/org/phpqrcode').'/phpqrcode.php'; + require_once(resource_path('org/phpqrcode/phpqrcode.php')); + return \QRcode::png($url,false,"H",6); } } \ No newline at end of file diff --git a/app/Http/Controllers/Api/UserMessageController.php b/app/Http/Controllers/Api/UserMessageController.php new file mode 100644 index 0000000..769d695 --- /dev/null +++ b/app/Http/Controllers/Api/UserMessageController.php @@ -0,0 +1,82 @@ +input('limit', 10); + $data['offset'] = $request->input('offset', 0); + if($request->input('type', '') != ''){$data['type'] = $request->input('type');} + if($request->input('status', '') != ''){$data['status'] = $request->input('status');} + $data['user_id'] = Token::$uid; + + $res = UserMessage::getList($data); + if(!$res) + { + return ReturnData::create(ReturnData::SYSTEM_FAIL); + } + + return ReturnData::create(ReturnData::SUCCESS,$res); + } + + //添加用户消息 + public function userMessageAdd(Request $request) + { + //参数 + $data['des'] = $request->input('des',''); + if($request->input('type', '') != ''){$data['type'] = $request->input('type');} + if($request->input('title', '') != ''){$data['title'] = $request->input('title');} + if($request->input('litpic', '') != ''){$data['litpic'] = $request->input('litpic');} + $data['add_time'] = time(); + $data['user_id'] = Token::$uid; + + if($data['des']=='') + { + return ReturnData::create(ReturnData::PARAMS_ERROR); + } + + $res = UserMessage::add($data); + if(!$res) + { + return ReturnData::create(ReturnData::SYSTEM_FAIL); + } + + return ReturnData::create(ReturnData::SUCCESS,$res); + } + + //修改用户消息 + public function userMessageUpdate(Request $request) + { + //参数 + if($request->input('des', '') != ''){$data['des'] = $request->input('des');} + if($request->input('type', '') != ''){$data['type'] = $request->input('type');} + if($request->input('title', '') != ''){$data['title'] = $request->input('title');} + if($request->input('litpic', '') != ''){$data['litpic'] = $request->input('litpic');} + if($request->input('status', '') != ''){$data['status'] = $request->input('status');} + + $where['id'] = $request->input('id'); + $where['user_id'] = Token::$uid; + + $res = UserMessage::modify($where,$data); + 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/Home/CommonController.php b/app/Http/Controllers/Home/CommonController.php index 1b4c96b..912bf98 100644 --- a/app/Http/Controllers/Home/CommonController.php +++ b/app/Http/Controllers/Home/CommonController.php @@ -9,4 +9,4 @@ class CommonController extends Controller { parent::__construct(); } -} +} \ No newline at end of file diff --git a/app/Http/Controllers/Weixin/IndexController.php b/app/Http/Controllers/Weixin/IndexController.php index cd7afc8..472aa41 100644 --- a/app/Http/Controllers/Weixin/IndexController.php +++ b/app/Http/Controllers/Weixin/IndexController.php @@ -22,9 +22,9 @@ class IndexController extends CommonController public function index() { //分享到首页,把推荐id存下来 - if(isset($_GET['parent_id']) && !empty($_GET['parent_id'])) + if(isset($_REQUEST['invite_code']) && !empty($_REQUEST['invite_code'])) { - $_SESSION['weixin_user_parent_id'] = intval($_GET['parent_id']); + $_SESSION['weixin_user_invite_code'] = $_REQUEST['invite_code']; } //banner轮播图 @@ -33,8 +33,8 @@ class IndexController extends CommonController 'offset' => 0 ); $url = env('APP_API_URL')."/slide_list"; - $slide_list = curl_request($url,$postdata,'GET'); - $data['slide_list'] = $slide_list['data']['list']; + $res = curl_request($url,$postdata,'GET'); + $data['slide_list'] = $res['data']['list']; //最新资讯 $postdata = array( @@ -42,8 +42,8 @@ class IndexController extends CommonController 'offset' => 0 ); $url = env('APP_API_URL')."/article_list"; - $article_list = curl_request($url,$postdata,'GET'); - $data['article_list'] = $article_list['data']['list']; + $res = curl_request($url,$postdata,'GET'); + $data['article_list'] = $res['data']['list']; //商品列表 $postdata = array( @@ -51,8 +51,8 @@ class IndexController extends CommonController '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['goods_list'] = $res['data']['list']; return view('weixin.index.index',$data); } diff --git a/app/Http/Controllers/Weixin/UserController.php b/app/Http/Controllers/Weixin/UserController.php index 0b3fe80..32ad36b 100644 --- a/app/Http/Controllers/Weixin/UserController.php +++ b/app/Http/Controllers/Weixin/UserController.php @@ -296,6 +296,54 @@ class UserController extends CommonController return view('weixin.user.userBonusList', $data); } + //用户消息 + public function userMessageList(Request $request) + { + $pagesize = 10; + $offset = 0; + if(isset($_REQUEST['page'])){$offset = ($_REQUEST['page']-1)*$pagesize;} + + $postdata = array( + 'limit' => $pagesize, + 'offset' => $offset, + 'access_token' => $_SESSION['weixin_user_info']['access_token'] + ); + $url = env('APP_API_URL')."/user_message_list"; + $res = curl_request($url,$postdata,'GET'); + $data['list'] = $res['data']['list']; + + $data['totalpage'] = ceil($res['data']['count']/$pagesize); + + if(isset($_REQUEST['page_ajax']) && $_REQUEST['page_ajax']==1) + { + $html = ''; + + if($res['data']['list']) + { + foreach($res['data']['list'] as $k => $v) + { + $html .= '
'.$v['title'].'
'; + } + + if($v['des']==0) + { + $html .= ''.$v['des'].'
'; + } + + $html .= ''.date('Y-m-d H:i:s',$v['add_time']).'
'; + $html .= '