增加了客服消息发小程序模板

This commit is contained in:
Xu Chang 2023-02-20 08:51:08 +08:00
parent 655e988d4c
commit 09fbf5bcc4
3 changed files with 53 additions and 2 deletions

View File

@ -11,7 +11,17 @@ declare type NewsServeMessageOption = {
url: string;
picurl?: string;
};
declare type ServeMessageOption = TextServeMessageOption | NewsServeMessageOption;
declare type MpServeMessageOption = {
openId: string;
type: 'mp';
data: {
title: string;
appId: string;
pagepath: string;
thumbnailId: string;
};
};
declare type ServeMessageOption = TextServeMessageOption | NewsServeMessageOption | MpServeMessageOption;
export declare class WechatPublicInstance {
appId: string;
appSecret?: string;

View File

@ -341,6 +341,21 @@ var WechatPublicInstance = /** @class */ (function () {
});
break;
}
case 'mp': {
Object.assign(myInit, {
body: JSON.stringify({
touser: openId,
msgtype: 'miniprogrampage',
miniprogrampage: {
title: options.data.title,
appid: options.data.appId,
pagepath: options.data.pagepath,
thumb_media_id: options.data.thumbnailId,
},
}),
});
break;
}
default: {
throw new Error('当前消息类型暂不支持');
}

View File

@ -17,7 +17,18 @@ type NewsServeMessageOption = {
picurl?: string;
};
type ServeMessageOption = TextServeMessageOption | NewsServeMessageOption;
type MpServeMessageOption = {
openId: string;
type: 'mp';
data: {
title: string;
appId: string;
pagepath: string;
thumbnailId: string;
};
};
type ServeMessageOption = TextServeMessageOption | NewsServeMessageOption | MpServeMessageOption;
export class WechatPublicInstance {
appId: string;
@ -328,6 +339,21 @@ export class WechatPublicInstance {
});
break;
}
case 'mp': {
Object.assign(myInit, {
body: JSON.stringify({
touser: openId,
msgtype: 'miniprogrampage',
miniprogrampage: {
title: options.data.title,
appid: options.data.appId,
pagepath: options.data.pagepath,
thumb_media_id: options.data.thumbnailId,
},
}),
});
break;
}
default: {
throw new Error('当前消息类型暂不支持');
}