|
@@ -1,18 +1,22 @@
|
1
|
1
|
import Taro from "@tarojs/taro";
|
2
|
2
|
import store from "@/store"
|
3
|
3
|
|
4
|
|
-export function subscribeMessage(messageType) {
|
5
|
|
- if (!messageType) return Promise.resolve();
|
|
4
|
+export function subscribeMessage(...messageTypes) {
|
|
5
|
+ if (!messageTypes || messageTypes.length < 1) return Promise.resolve();
|
6
|
6
|
|
7
|
7
|
const { messageTpls } = store.getModel('system').getState()
|
8
|
8
|
if (!messageTpls || !messageTpls.length) return Promise.resolve();
|
9
|
9
|
|
10
|
10
|
return new Promise((resolve, reject) => {
|
11
|
|
- const tpl = messageTpls.filter(x => x.messageType === messageType)[0] || {}
|
|
11
|
+ const tmplIds = messageTypes.map((messageType) => {
|
|
12
|
+ const tpl = messageTpls.filter(x => x.messageType === messageType)[0] || {}
|
|
13
|
+ return tpl.templateId;
|
|
14
|
+ }).filter(Boolean)
|
12
|
15
|
|
13
|
|
- if (tpl.templateId) {
|
|
16
|
+
|
|
17
|
+ if (tmplIds && tmplIds.length > 0) {
|
14
|
18
|
Taro.requestSubscribeMessage({
|
15
|
|
- tmplIds: [tpl.templateId],
|
|
19
|
+ tmplIds,
|
16
|
20
|
complete: () => resolve(),
|
17
|
21
|
})
|
18
|
22
|
} else {
|