dyjh 6 years ago
parent
commit
fa4ed2c759

+ 32 - 16
app/Http/Controllers/Web/AuthController.php

xqd xqd
@@ -17,22 +17,38 @@ class AuthController extends Controller
 {
     public function bind(Request $request)
     {
-        $store_id = $request->input('store_id');
-        $weChatApp = AlbumManufacturerModel::where('store_id', $store_id)->first();
-        $config = [
-            'app_id' => $weChatApp->G_app_id,
-            'secret' => $weChatApp->G_app_secret,
-            'response_type' => 'array',
-            'oauth' => [
-                'scopes'   => ['snsapi_userinfo'],
-                'callback' => '/web/notify?store_id=' . $store_id,
-            ]
+        if ($request->isMethod('post')) {
+            $store_id = $request->input('store_id');
+            $phone = $request->input('phone');
+            $name = $request->input('name');
+            if (!$phone) {
+                $message = '请输入电话号码';
+                return view('web.auth.bind', compact('message'));
+            } else {
+                $check = AlbumUserModel::where([['phone', $phone],['g_open_id', null]])->first();
+                if (!$check) {
+                    $message = '该号码不存在或是已绑定';
+                }
+                return view('web.auth.bind', compact('message'));
+            }
+            $weChatApp = AlbumManufacturerModel::where('store_id', $store_id)->first();
+            $config = [
+                'app_id' => $weChatApp->G_app_id,
+                'secret' => $weChatApp->G_app_secret,
+                'response_type' => 'array',
+                'oauth' => [
+                    'scopes'   => ['snsapi_userinfo'],
+                    'callback' => '/web/notify?store_id=' . $store_id,
+                ]
 
-        ];
-        $app = Factory::officialAccount($config);
-        $response = $app->oauth
-            ->redirect();
-        return $response;
+            ];
+            $app = Factory::officialAccount($config);
+            $response = $app->oauth
+                ->redirect();
+            return $response;
+        } else {
+            return view('web.auth.bind');
+        }
     }
     public function notify(Request $request)
     {
@@ -66,7 +82,7 @@ class AuthController extends Controller
             $data['up_agent_id'] = 0;
             AlbumUserModel::create($data);
         }
-        return view('web.auth.bind');
+        return view('web.auth.success');
     }
 
     public function notifyAccount(Request $request)

+ 7 - 4
resources/views/web/auth/bind.blade.php

xqd
@@ -61,13 +61,16 @@
     </style>
 </head>
 <body>
-<div class="header">绑定成功</div>
+<div class="header">绑定画册</div>
 <div class="container" style="padding: 40px;width: 100%;height: 100%;">
     <div class="row visible-on">
         <div class="txtbox">
-            <div class="title">您的微信号已经成功绑定!</div>
-            <!-- <input class="input" type="text" placeholder="请输入手机号">
-            <button>确认绑定</button> -->
+            <form action="" method="post" enctype="multipart/form-data">
+                {{ csrf_field() }}
+                <input class="input" type="text" name="phone" placeholder="请输入手机号">
+                <input class="input" type="text" name="name" placeholder="请输入姓名">
+                <button>确认绑定</button>
+            </form>
         </div>
     </div>
 </div>

+ 75 - 0
resources/views/web/auth/success.blade.php

xqd
@@ -0,0 +1,75 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>绑定微信号</title>
+    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
+    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
+    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
+    <style>
+        body{
+            background: #fff;
+        }
+        .header{
+            width: 100%;
+            height: 160px;
+            text-align:center;
+            line-height: 160px;
+            font-size: 55px;
+            background: rgb(40,125,180);
+            color:#fff;
+            background: -webkit-linear-gradient(left, rgb(255,172,20) ,  rgb(235,127,20)); /* Safari 5.1 - 6.0 */
+            background: -o-linear-gradient(right, rgb(255,172,20) ,  rgb(235,127,20)); /* Opera 11.1 - 12.0 */
+            background: -moz-linear-gradient(right,rgb(255,172,20) ,  rgb(235,127,20)); /* Firefox 3.6 - 15 */
+            background: linear-gradient(to right, rgb(255,172,20) ,  rgb(235,127,20)); /* 标准的语法 */
+        }
+        .txtbox{
+            width: 100%;
+            height: 450px;
+        }
+        .txtbox .title{
+            display: inline-block;
+            width: 100%;
+            height: 120px;
+            text-align: center;
+            line-height: 120px;
+            font-size: 45px;
+        }
+        .txtbox .input{
+            width: 60%;
+            height: 100px;
+            margin: 50px 20% 70px 20%;
+            font-size: 40px;
+            border: 1px solid #999;
+            border-radius: 60px;
+            text-indent: 60px;
+        }
+        .txtbox button{
+            width: 80%;
+            height: 120px;
+            line-height: 120px;
+            font-size: 45px;
+            font-weight: 600;
+            text-align: center;
+            margin-left: 10%;
+            border: none;
+            border-radius: 20px;
+            background: rgba(0,0,0,0.1);
+            color: #666;
+            margin-top: 100px;
+        }
+    </style>
+</head>
+<body>
+<div class="header">绑定成功</div>
+<div class="container" style="padding: 40px;width: 100%;height: 100%;">
+    <div class="row visible-on">
+        <div class="txtbox">
+            <div class="title">您的微信号已经成功绑定!</div>
+            <!-- <input class="input" type="text" placeholder="请输入手机号">
+            <button>确认绑定</button> -->
+        </div>
+    </div>
+</div>
+</body>
+</html>