diff --git a/app/Common/WechatAuth.php b/app/Common/WechatAuth.php
new file mode 100644
index 0000000..53ce6de
--- /dev/null
+++ b/app/Common/WechatAuth.php
@@ -0,0 +1,45 @@
+开发者模式->获取
+ private $app_id = 'xxx';
+ private $app_secret = 'xxxxxxx';
+
+ //$registration_id = getenv('registration_id');
+
+ public static function send($msg, $param='')
+ {
+ $client = new JPushMsg(self::APP_KEY, self::APP_SECRET, null);
+
+ $push_payload = $client->push();
+ $push_payload = $push_payload->setPlatform('all');
+ if(isset($param['mobile'])){$push_payload = $push_payload->addAlias(md5($param['mobile']));}
+ $push_payload = $push_payload->addAllAudience();
+ $push_payload = $push_payload->setNotificationAlert($msg);
+
+ try
+ {
+ $push_payload->send();
+ }
+ catch (JPushMsg\Exceptions\APIConnectionException $e)
+ {
+ Log::info($e);
+ return false;
+ }
+ catch (JPushMsg\Exceptions\APIRequestException $e)
+ {
+ Log::info($e);
+ return false;
+ }
+
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/app/Http/Controllers/Weixin/UserController.php b/app/Http/Controllers/Weixin/UserController.php
index 25a734f..ec76eb5 100644
--- a/app/Http/Controllers/Weixin/UserController.php
+++ b/app/Http/Controllers/Weixin/UserController.php
@@ -271,6 +271,44 @@ class UserController extends CommonController
$this->success_jump(ReturnCode::SUCCESS);
}
+ //微信网页授权登录
+ public function oauth(Request $request)
+ {
+ if(isset($_SESSION['weixin_user_info']))
+ {
+ if(isset($_SERVER["HTTP_REFERER"])){header('Location: '.$_SERVER["HTTP_REFERER"]);exit;}
+ header('Location: '.route('weixin_user'));exit;
+ }
+
+ if($_SERVER['REQUEST_METHOD'] == 'POST')
+ {
+ if($_POST['user_name'] == '')
+ {
+ $this->error_jump('账号不能为空');
+ }
+
+ if($_POST['password'] == '')
+ {
+ $this->error_jump('密码不能为空');
+ }
+
+ $postdata = array(
+ 'user_name' => $_POST['user_name'],
+ 'password' => md5($_POST['password'])
+ );
+ $url = env('APP_API_URL')."/wx_login";
+ $res = curl_request($url,$postdata,'POST');
+
+ if($res['code'] != ReturnCode::SUCCESS_CODE){$this->error_jump('登录失败');}
+
+ $_SESSION['weixin_user_info'] = $res['data'];
+
+ header('Location: '.route('weixin_user'));exit;
+ }
+
+ return view('weixin.user.login');
+ }
+
//登录
public function login(Request $request)
{
@@ -324,7 +362,7 @@ class UserController extends CommonController
public function logout(Request $request)
{
session_unset();
- session_destroy();// 退出登录,清除session
+ session_destroy(); // 退出登录,清除session
$this->success_jump('退出成功',route('weixin'));
}
diff --git a/resources/views/weixin/index/index.blade.php b/resources/views/weixin/index/index.blade.php
index 393ef51..8e25929 100644
--- a/resources/views/weixin/index/index.blade.php
+++ b/resources/views/weixin/index/index.blade.php
@@ -146,59 +146,6 @@ var swiper = new Swiper('.swiper-nav', {
-
diff --git a/resources/views/weixin/user/login.blade.php b/resources/views/weixin/user/login.blade.php
index 8c9b1d1..b49aecd 100644
--- a/resources/views/weixin/user/login.blade.php
+++ b/resources/views/weixin/user/login.blade.php
@@ -13,7 +13,7 @@
@include('weixin.common.headerNav')