|
@@ -17,22 +17,38 @@ class AuthController extends Controller
|
|
{
|
|
{
|
|
public function bind(Request $request)
|
|
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)
|
|
public function notify(Request $request)
|
|
{
|
|
{
|
|
@@ -66,7 +82,7 @@ class AuthController extends Controller
|
|
$data['up_agent_id'] = 0;
|
|
$data['up_agent_id'] = 0;
|
|
AlbumUserModel::create($data);
|
|
AlbumUserModel::create($data);
|
|
}
|
|
}
|
|
- return view('web.auth.bind');
|
|
|
|
|
|
+ return view('web.auth.success');
|
|
}
|
|
}
|
|
|
|
|
|
public function notifyAccount(Request $request)
|
|
public function notifyAccount(Request $request)
|