dyjh 6 rokov pred
rodič
commit
85a42b614e

+ 19 - 3
app/Http/Controllers/Web/AuthController.php

xqd xqd
@@ -9,6 +9,7 @@
 namespace App\Http\Controllers\Web;
 
 use App\Models\AlbumManufacturerModel;
+use App\Models\AlbumUserModel;
 use Illuminate\Http\Request;
 use EasyWeChat\Factory;
 
@@ -49,9 +50,24 @@ class AuthController extends Controller
         $app = Factory::officialAccount($config);
         $oauth = $app->oauth;
 // 获取 OAuth 授权结果用户信息
-        $user = $oauth->user();
-        dd($user->toArray());
-        \Log::info($user);
+        $user = $oauth->user()->toArray();
+        $check_user = AlbumUserModel::where([['store_id',$store_id],['wechat_union_id',$user['original']['unionid']]])->first();
+        if ($check_user) {
+            $check_user->g_open_id = $user['id'];
+            $check_user->save();
+        } else {
+            $data['username'] = $user['name'];
+            $data['wechat_union_id'] = $user['original']['unionid'];
+            $data['avatar'] = $user['avatar'];
+            $data['g_open_id'] = $user['id'];
+            $data['store_id'] = $store_id;
+            $data['is_dealer'] = 0;
+            $data['role'] = 0;
+            $data['model'] = 0;
+            $data['up_agent_id'] = 0;
+            AlbumUserModel::create($data);
+        }
+        return view('');
     }
 
     public function welcome()

+ 1 - 0
app/Models/AlbumUserModel.php

xqd
@@ -40,6 +40,7 @@ class AlbumUserModel extends Authenticatable
     protected $fillable = [
         'username',
         'wechat_open_id',
+        'g_open_id',
         'open_id',
         'wechat_union_id',
         'avatar',

+ 1 - 1
database/migrations/2018_05_11_094238_create_album_user.php

xqd
@@ -22,7 +22,7 @@ class CreateAlbumUser extends Migration
             $table->unsignedInteger('is_delete')->default(0)->comment('Is_delete');
             $table->unsignedinteger('store_id')->comment('商户号');
             $table->unsignedInteger('is_dealer')->comment('是否为经销商');
-            $table->string('phone',20)->comment('电话');
+            $table->string('phone',20)->nullable()->default('')->comment('电话');
             $table->timestamps();
         });
     }

+ 75 - 0
resources/views/web/auth/bind.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>