225 lines
7.2 KiB
TypeScript
225 lines
7.2 KiB
TypeScript
type TextServeMessageOption = {
|
|
openId: string;
|
|
type: 'text';
|
|
content: string;
|
|
};
|
|
type ImageServeMessageOption = {
|
|
openId: string;
|
|
type: 'image';
|
|
mediaId: string;
|
|
};
|
|
type NewsServeMessageOption = {
|
|
openId: string;
|
|
type: 'news';
|
|
title: string;
|
|
description?: string;
|
|
url: string;
|
|
picurl?: string;
|
|
};
|
|
type MpServeMessageOption = {
|
|
openId: string;
|
|
type: 'mp';
|
|
data: {
|
|
title: string;
|
|
appId?: string;
|
|
pagepath: string;
|
|
thumbnailId: string;
|
|
};
|
|
};
|
|
type MediaType = 'image' | 'voice' | 'video' | 'thumb';
|
|
type ServeMessageOption = TextServeMessageOption | NewsServeMessageOption | MpServeMessageOption | ImageServeMessageOption;
|
|
type UploadShippingInfo = {
|
|
order_key: {
|
|
order_number_type: 1 | 2;
|
|
transaction_id?: string;
|
|
mchid?: string;
|
|
out_trade_no?: string;
|
|
};
|
|
logistic_type: 1 | 2 | 3 | 4;
|
|
delivery_mode: 1 | 2;
|
|
is_all_delivered?: boolean;
|
|
shipping_list: Array<{
|
|
tracking_no?: string;
|
|
express_company?: string;
|
|
item_desc: string;
|
|
contact?: {
|
|
consignor_contact?: string;
|
|
receiver_contact?: string;
|
|
};
|
|
upload_time: string;
|
|
payer: {
|
|
openid: string;
|
|
};
|
|
}>;
|
|
};
|
|
import { AddExpressOrderData, CancelExpressOrderData, getExpressPathData, getWaybillTokenData } from '../../types/Wechat';
|
|
export declare class WechatMpInstance {
|
|
appId: string;
|
|
appSecret?: string;
|
|
private accessToken?;
|
|
private refreshAccessTokenHandler?;
|
|
private externalRefreshFn?;
|
|
constructor(appId: string, appSecret?: string, accessToken?: string, externalRefreshFn?: (appId: string) => Promise<string>);
|
|
private getAccessToken;
|
|
private access;
|
|
code2Session(code: string): Promise<{
|
|
sessionKey: string;
|
|
openId: string;
|
|
unionId: string;
|
|
}>;
|
|
private refreshAccessToken;
|
|
decryptData(sessionKey: string, encryptedData: string, iv: string, signature: string): any;
|
|
getMpUnlimitWxaCode({ scene, page, envVersion, width, autoColor, lineColor, isHyaline, }: {
|
|
scene: string;
|
|
page: string;
|
|
envVersion?: 'release' | 'trial' | 'develop';
|
|
width?: number;
|
|
autoColor?: boolean;
|
|
lineColor?: {
|
|
r: number;
|
|
g: number;
|
|
b: number;
|
|
};
|
|
isHyaline?: true;
|
|
}): Promise<ArrayBuffer>;
|
|
getUserPhoneNumber(code: string): Promise<{
|
|
phoneNumber: string;
|
|
purePhoneNumber: string;
|
|
countryCode: number;
|
|
watermark: {
|
|
timestamp: number;
|
|
appid: string;
|
|
};
|
|
}>;
|
|
/**
|
|
* 发送订阅消息
|
|
* @param param0
|
|
* @returns
|
|
* https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/mp-message-management/subscribe-message/sendMessage.html
|
|
*/
|
|
sendSubscribedMessage({ templateId, page, openId, data, state, lang, }: {
|
|
templateId: string;
|
|
page?: string;
|
|
openId: string;
|
|
data: object;
|
|
state?: 'developer' | 'trial' | 'formal';
|
|
lang?: 'zh_CN' | 'zh_TW' | 'en_US' | 'zh_HK';
|
|
}): Promise<any>;
|
|
createTemporaryMaterial(options: {
|
|
type: MediaType;
|
|
media: any;
|
|
filename: string;
|
|
filetype: string;
|
|
}): Promise<any>;
|
|
getTemporaryMaterial(options: {
|
|
mediaId: string;
|
|
}): Promise<any>;
|
|
sendServeMessage(options: ServeMessageOption): Promise<any>;
|
|
getAllPrivateTemplate(): Promise<{
|
|
priTmplId: string;
|
|
title: string;
|
|
type: number;
|
|
content: string;
|
|
example: string;
|
|
keywordEnumValueList?: {
|
|
keywordCode: string;
|
|
enumValueList: Array<string>;
|
|
}[] | undefined;
|
|
}[]>;
|
|
private isJson;
|
|
getURLScheme(options: {
|
|
jump_wxa: {
|
|
path?: string;
|
|
query?: string;
|
|
env_version?: string;
|
|
};
|
|
expireType?: number;
|
|
expiresAt?: number;
|
|
expireInterval?: number;
|
|
}): Promise<any>;
|
|
/**
|
|
* https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/order-shipping/order-shipping.html#%E4%B8%80%E3%80%81%E5%8F%91%E8%B4%A7%E4%BF%A1%E6%81%AF%E5%BD%95%E5%85%A5%E6%8E%A5%E5%8F%A3
|
|
* 发货信息录入
|
|
*/
|
|
uploadShippingInfo(info: UploadShippingInfo): Promise<any>;
|
|
/**
|
|
* 查询订单的发货状态
|
|
* https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/order-shipping/order-shipping.html#%E4%B8%89%E3%80%81%E6%9F%A5%E8%AF%A2%E8%AE%A2%E5%8D%95%E5%8F%91%E8%B4%A7%E7%8A%B6%E6%80%81
|
|
* @param info
|
|
*/
|
|
getOrderState(info: {
|
|
transaction_id?: string;
|
|
merchant_id?: string;
|
|
sub_merchant_id?: string;
|
|
merchant_trade_no?: string;
|
|
}): Promise<{
|
|
orderState: number;
|
|
inComplaint: boolean;
|
|
shipping: {
|
|
delevery_mode: 1 | 2;
|
|
logistics_type: 1 | 2 | 3 | 4;
|
|
finish_shipping: boolean;
|
|
goods_desc?: string | undefined;
|
|
finish_shipping_count: 0 | 1 | 2;
|
|
shipping_list: Array<{
|
|
tracking_no?: string;
|
|
express_company?: string;
|
|
goods_desc: string;
|
|
upload_time?: number;
|
|
contact?: {
|
|
consignor_contact?: string;
|
|
receiver_contact?: string;
|
|
};
|
|
}>;
|
|
};
|
|
}>;
|
|
/**
|
|
* 获取运力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<any>;
|
|
/**
|
|
* 生成物流运单
|
|
* https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/express/express-by-business/addOrder.html
|
|
*/
|
|
addExpressOrder(data: AddExpressOrderData): Promise<{
|
|
waybill_id: string;
|
|
waybill_data: Array<{
|
|
key: string;
|
|
value: string;
|
|
}>;
|
|
}>;
|
|
/**
|
|
* 取消物流运单
|
|
* https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/express/express-by-business/cancelOrder.html
|
|
* @param data
|
|
*/
|
|
cancelExpressOrder(data: CancelExpressOrderData): Promise<void>;
|
|
/**
|
|
* 查询运单轨迹
|
|
* https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/express/express-by-business/getPath.html
|
|
* @param data
|
|
*/
|
|
getExpressPath(data: getExpressPathData): Promise<{
|
|
path_item_num: number;
|
|
path_item_list: Array<{
|
|
action_time: number;
|
|
action_type: number;
|
|
action_msg: string;
|
|
}>;
|
|
}>;
|
|
/**
|
|
* 获取运单token
|
|
* https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/express/business/express_search.html
|
|
* @param data
|
|
*/
|
|
getWaybillToken(data: getWaybillTokenData): Promise<string>;
|
|
/**
|
|
* 获取运单状态
|
|
* https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/express/business/express_search.html
|
|
* @param data
|
|
*/
|
|
getExpressState(waybillToken: string): Promise<any>;
|
|
}
|
|
export {};
|