|
@@ -6,6 +6,7 @@ use App\Http\Controllers\Controller;
|
|
|
use App\Http\Requests\Client\Wechat\GetAuthUrlRequest;
|
|
|
use App\Http\Requests\Client\Wechat\HandleCallbackRequest;
|
|
|
use App\Services\Client\WechatService;
|
|
|
+use Illuminate\Http\Request;
|
|
|
|
|
|
/**
|
|
|
* @group 用户端
|
|
@@ -111,4 +112,49 @@ class WechatController extends Controller
|
|
|
|
|
|
return $this->success($result);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * [微信]获取JSAPI配置
|
|
|
+ *
|
|
|
+ * @description 获取微信JSAPI配置信息,用于前端调用微信JSAPI
|
|
|
+ *
|
|
|
+ * @queryParam url required 当前网页的URL,不包含#及其后面部分 Example: https://example.com/page
|
|
|
+ *
|
|
|
+ * @response 200 scenario="成功" {
|
|
|
+ * "code": 200,
|
|
|
+ * "data": {
|
|
|
+ * "appId": "wx123456789",
|
|
|
+ * "timestamp": 1577808000,
|
|
|
+ * "nonceStr": "random_string",
|
|
|
+ * "signature": "sha1_signature_string",
|
|
|
+ * "jsApiList": ["updateAppMessageShareData", "updateTimelineShareData"]
|
|
|
+ * }
|
|
|
+ * }
|
|
|
+ * @response 422 scenario="参数验证失败" {
|
|
|
+ * "code": 422,
|
|
|
+ * "message": "URL不能为空|URL必须是一个有效的网址"
|
|
|
+ * }
|
|
|
+ * @response 400 scenario="获取配置失败" {
|
|
|
+ * "code": 400,
|
|
|
+ * "message": "获取JSAPI配置失败,请稍后重试"
|
|
|
+ * }
|
|
|
+ *
|
|
|
+ * @throws BusinessException
|
|
|
+ */
|
|
|
+ public function getJsConfig(Request $request)
|
|
|
+ {
|
|
|
+ $url = $request->input('url');
|
|
|
+
|
|
|
+ if (empty($url)) {
|
|
|
+ return $this->error('URL不能为空');
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!filter_var($url, FILTER_VALIDATE_URL)) {
|
|
|
+ return $this->error('URL必须是一个有效的网址');
|
|
|
+ }
|
|
|
+
|
|
|
+ $config = $this->wechatService->getJsConfig($url);
|
|
|
+
|
|
|
+ return $this->success($config);
|
|
|
+ }
|
|
|
}
|