From 9fb9aee154fe8fda78de7eeddcb202f58b6c4d36 Mon Sep 17 00:00:00 2001 From: lxy Date: Thu, 16 Jan 2025 14:41:44 +0800 Subject: [PATCH] =?UTF-8?q?wechatMp=E5=A2=9E=E5=8A=A0=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E8=BF=90=E5=8A=9Bid=E5=88=97=E8=A1=A8=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- es/service/wechat/WechatMp.d.ts | 5 +++++ es/service/wechat/WechatMp.js | 16 ++++++++++++++++ lib/service/wechat/WechatMp.d.ts | 5 +++++ lib/service/wechat/WechatMp.js | 16 ++++++++++++++++ src/service/wechat/WechatMp.ts | 24 ++++++++++++++++++++++-- 5 files changed, 64 insertions(+), 2 deletions(-) diff --git a/es/service/wechat/WechatMp.d.ts b/es/service/wechat/WechatMp.d.ts index 53fed47..eb35dcf 100644 --- a/es/service/wechat/WechatMp.d.ts +++ b/es/service/wechat/WechatMp.d.ts @@ -172,5 +172,10 @@ export declare class WechatMpInstance { }>; }; }>; + /** + * 获取运力id列表get_delivery_list + * https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/express/business/express_search.html#%E8%8E%B7%E5%8F%96%E8%BF%90%E5%8A%9Bid%E5%88%97%E8%A1%A8get-delivery-list + */ + getDeliveryList(): Promise; } export {}; diff --git a/es/service/wechat/WechatMp.js b/es/service/wechat/WechatMp.js index 584bdbe..70f64b3 100644 --- a/es/service/wechat/WechatMp.js +++ b/es/service/wechat/WechatMp.js @@ -376,4 +376,20 @@ export class WechatMpInstance { shipping: shipping }; } + /** + * 获取运力id列表get_delivery_list + * https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/express/business/express_search.html#%E8%8E%B7%E5%8F%96%E8%BF%90%E5%8A%9Bid%E5%88%97%E8%A1%A8get-delivery-list + */ + async getDeliveryList() { + const token = this.getAccessToken(); + const result = await this.access(`https://api.weixin.qq.com/cgi-bin/express/delivery/open_msg/get_delivery_list?access_token=${token}`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({}), + }); + // const { errcode, delivery_list, count } = result; + return result; + } } diff --git a/lib/service/wechat/WechatMp.d.ts b/lib/service/wechat/WechatMp.d.ts index 53fed47..eb35dcf 100644 --- a/lib/service/wechat/WechatMp.d.ts +++ b/lib/service/wechat/WechatMp.d.ts @@ -172,5 +172,10 @@ export declare class WechatMpInstance { }>; }; }>; + /** + * 获取运力id列表get_delivery_list + * https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/express/business/express_search.html#%E8%8E%B7%E5%8F%96%E8%BF%90%E5%8A%9Bid%E5%88%97%E8%A1%A8get-delivery-list + */ + getDeliveryList(): Promise; } export {}; diff --git a/lib/service/wechat/WechatMp.js b/lib/service/wechat/WechatMp.js index 4bf974b..3e8f49e 100644 --- a/lib/service/wechat/WechatMp.js +++ b/lib/service/wechat/WechatMp.js @@ -380,5 +380,21 @@ class WechatMpInstance { shipping: shipping }; } + /** + * 获取运力id列表get_delivery_list + * https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/express/business/express_search.html#%E8%8E%B7%E5%8F%96%E8%BF%90%E5%8A%9Bid%E5%88%97%E8%A1%A8get-delivery-list + */ + async getDeliveryList() { + const token = this.getAccessToken(); + const result = await this.access(`https://api.weixin.qq.com/cgi-bin/express/delivery/open_msg/get_delivery_list?access_token=${token}`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({}), + }); + // const { errcode, delivery_list, count } = result; + return result; + } } exports.WechatMpInstance = WechatMpInstance; diff --git a/src/service/wechat/WechatMp.ts b/src/service/wechat/WechatMp.ts index e98244a..e5caabd 100644 --- a/src/service/wechat/WechatMp.ts +++ b/src/service/wechat/WechatMp.ts @@ -202,8 +202,8 @@ export class WechatMpInstance { const result = this.externalRefreshFn ? await this.externalRefreshFn(this.appId) : await this.access( - `https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=${this.appId}&secret=${this.appSecret}` - ); + `https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=${this.appId}&secret=${this.appSecret}` + ); const { access_token, expires_in } = result; this.accessToken = access_token; if (process.env.NODE_ENV === 'development') { @@ -629,4 +629,24 @@ export class WechatMpInstance { } } } + + /** + * 获取运力id列表get_delivery_list + * https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/express/business/express_search.html#%E8%8E%B7%E5%8F%96%E8%BF%90%E5%8A%9Bid%E5%88%97%E8%A1%A8get-delivery-list + */ + async getDeliveryList() { + const token = this.getAccessToken(); + const result = await this.access( + `https://api.weixin.qq.com/cgi-bin/express/delivery/open_msg/get_delivery_list?access_token=${token}`, + { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({}), + } + ); + // const { errcode, delivery_list, count } = result; + return result; + } }