Skip to content

Commit 2a43514

Browse files
committed
feat: support multiple template
1 parent 5462885 commit 2a43514

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

cloudfunctions/sendSubscribe/index.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,9 @@ const MAX = 1 // 限制发送人数
1111

1212
const sendSubscribeMessage = async ({ openid, templateId, version, content }) => {
1313
const time = dayjs().format('YYYY年M月D日 HH:mm')
14-
15-
const sendResult = await cloud.openapi.subscribeMessage.send({
16-
touser: openid,
17-
templateId,
18-
page: '/pages/index/index',
19-
data: {
14+
const date = dayjs().format('YYYY年M月D日')
15+
const dataMap = {
16+
'vjEDlUYrVJ05CauSw_V9jIWF-okt3OMCBtlz9yvjrfg': {
2017
character_string1: {
2118
value: version,
2219
},
@@ -26,7 +23,22 @@ const sendSubscribeMessage = async ({ openid, templateId, version, content }) =>
2623
thing3: {
2724
value: content,
2825
},
26+
},
27+
'Sbtj4X4gIKWRy0xDeWU8xCl8LejbTpIQ3gWiKh5JFp4': {
28+
thing1: {
29+
value: content,
30+
},
31+
date2: {
32+
value: date,
33+
},
2934
}
35+
}
36+
37+
const sendResult = await cloud.openapi.subscribeMessage.send({
38+
touser: openid,
39+
templateId,
40+
page: '/pages/index/index',
41+
data: dataMap[templateId]
3042
})
3143

3244
if (sendResult.errCode != 0) {

0 commit comments

Comments
 (0)