[更新]修改微信服务异常处理

This commit is contained in:
Anyon 2018-05-03 11:14:26 +08:00
parent da499ff485
commit cee220c167

View File

@ -75,12 +75,13 @@ class WechatService
} }
throw new Exception("Class '{$class}' not found"); throw new Exception("Class '{$class}' not found");
case 'thr': case 'thr':
default:
list($appid, $appkey) = [sysconf('wechat_thr_appid'), sysconf('wechat_thr_appkey')]; list($appid, $appkey) = [sysconf('wechat_thr_appid'), sysconf('wechat_thr_appkey')];
$token = strtolower("{$name}-{$appid}-{$appkey}"); $token = strtolower("{$name}-{$appid}-{$appkey}");
$location = config('wechat.service_url') . "/wechat/api.client/soap/{$token}.html"; $location = config('wechat.service_url') . "/wechat/api.client/soap/{$token}.html";
$params = ['uri' => strtolower($name), 'location' => $location, 'trace' => true]; $params = ['uri' => strtolower($name), 'location' => $location, 'trace' => true];
return new SoapService(null, $params); return new SoapService(null, $params);
default:
throw new Exception('请在后台配置微信对接授权模式!');
} }
} }
@ -102,7 +103,7 @@ class WechatService
case 'thr': case 'thr':
return WechatService::wechat()->jsSign($signUrl); return WechatService::wechat()->jsSign($signUrl);
default: default:
throw new Exception('请在后配置微信对接授权模式!'); throw new Exception('请在后配置微信对接授权模式!');
} }
} }
@ -145,7 +146,6 @@ class WechatService
redirect(decode(request()->get('rcode')), [], 301)->send(); redirect(decode(request()->get('rcode')), [], 301)->send();
break; break;
case 'thr': case 'thr':
default:
$service = self::wechat(); $service = self::wechat();
$result = $service->oauth(session_id(), $url, $fullMode); $result = $service->oauth(session_id(), $url, $fullMode);
session("{$appid}_openid", $openid = $result['openid']); session("{$appid}_openid", $openid = $result['openid']);
@ -158,6 +158,9 @@ class WechatService
redirect($result['url'], [], 301)->send(); redirect($result['url'], [], 301)->send();
} }
exit("window.location.href='{$result['url']}'"); exit("window.location.href='{$result['url']}'");
default:
throw new Exception('请在后台配置微信对接授权模式!');
} }
} }
@ -175,7 +178,7 @@ class WechatService
case 'thr': case 'thr':
return sysconf('wechat_thr_appid'); return sysconf('wechat_thr_appid');
default: default:
return ''; throw new Exception('请在后台配置微信对接授权模式!');
} }
} }