|
@@ -1,6 +1,7 @@
|
|
|
import { defineStore } from 'pinia'
|
|
import { defineStore } from 'pinia'
|
|
|
import { submitAuditMessageSubscriptionApi, getWxSubscribeListApi } from '@/service/index'
|
|
import { submitAuditMessageSubscriptionApi, getWxSubscribeListApi } from '@/service/index'
|
|
|
import { useAppStore } from '@/store/app'
|
|
import { useAppStore } from '@/store/app'
|
|
|
|
|
+import { useDictStore } from '@/store/dict'
|
|
|
import { until } from '@vueuse/core'
|
|
import { until } from '@vueuse/core'
|
|
|
|
|
|
|
|
export const useSettingsStore = defineStore(
|
|
export const useSettingsStore = defineStore(
|
|
@@ -43,11 +44,29 @@ export const useSettingsStore = defineStore(
|
|
|
return res.Data
|
|
return res.Data
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 获取微信模板ID
|
|
|
|
|
+ const getWxTemplateId = async (): Promise<string> => {
|
|
|
|
|
+ const dictStore = useDictStore()
|
|
|
|
|
+ const configList = await dictStore.getConfigList('wxapp_template_id')
|
|
|
|
|
+
|
|
|
|
|
+ if (!configList || configList.length === 0) {
|
|
|
|
|
+ throw new Error('未配置微信模板ID,请联系管理员')
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const templateId = configList[0].substance
|
|
|
|
|
+ if (!templateId || templateId.trim() === '') {
|
|
|
|
|
+ throw new Error('微信模板ID配置为空,请联系管理员')
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return templateId
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 调起wx.requestSubscribeMessage
|
|
// 调起wx.requestSubscribeMessage
|
|
|
const requestSubscribeMessage = async () => {
|
|
const requestSubscribeMessage = async () => {
|
|
|
|
|
+ const templateId = await getWxTemplateId()
|
|
|
return new Promise((resolve, reject) => {
|
|
return new Promise((resolve, reject) => {
|
|
|
const params = {
|
|
const params = {
|
|
|
- tmplIds: ['oi3JmzaEbkAXubBsPPMDE8Grjfj9Tf0VP7rttWAgPlA'],
|
|
|
|
|
|
|
+ tmplIds: [templateId],
|
|
|
success: (res) => {
|
|
success: (res) => {
|
|
|
console.log('requestSubscribeMessage success', res)
|
|
console.log('requestSubscribeMessage success', res)
|
|
|
resolve(res)
|
|
resolve(res)
|
|
@@ -65,6 +84,7 @@ export const useSettingsStore = defineStore(
|
|
|
submitAuditMessageSubscription,
|
|
submitAuditMessageSubscription,
|
|
|
getAuditMessageSubscription,
|
|
getAuditMessageSubscription,
|
|
|
requestSubscribeMessage,
|
|
requestSubscribeMessage,
|
|
|
|
|
+ getWxTemplateId,
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|