From 06084cfd87f67ed15f5e4c6455305eb80a630ab0 Mon Sep 17 00:00:00 2001 From: hope Date: Thu, 17 Aug 2023 15:54:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=8E=B7=E5=8F=96=E5=B0=8F?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F=20Short=20Link=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/services/WxIsvUrllinkService.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/services/WxIsvUrllinkService.ts b/src/services/WxIsvUrllinkService.ts index 8c90c11..6c96f1e 100644 --- a/src/services/WxIsvUrllinkService.ts +++ b/src/services/WxIsvUrllinkService.ts @@ -6,6 +6,10 @@ interface UrllinkGenerateResult { urlLink: string } +interface ShortUrllinkGenerateResult { + link: string +} + export class WxIsvUrllinkService extends WxIsvServiceBase { /** * 生成永久的URL LINK @@ -50,4 +54,23 @@ export class WxIsvUrllinkService extends WxIsvServiceBase { access_token: accessToken, }) } + + /** + * 获取小程序 Short Link,适用于微信内拉起小程序的业务场景 + * 详见 https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/qrcode-link/short-link/generateShortLink.html + */ + async generateShortLink( + accessToken: string, + page_url: string, + page_title = '', + is_permanent = true + ): Promise { + return await this.request( + 'POST', + '/wxa/genwxashortlink', + {}, + { access_token: accessToken, page_url, page_title, is_permanent } + ) + } + }