import { getConfig } from '@/common/server/interface/common' import { ref } from 'vue'; export const configData = ref(null); export const preloadConfigData = async () => { const res = await getConfig(); configData.value = { config: res }; console.log("configData.value", configData.value); }; export const getConfigData = async () => { if (configData.value == null) { await preloadConfigData(); } return configData.value; } /** * 获取订阅消息模板ID列表 * @param {Number} depositFee 押金费用 * @returns {Array|null} 返回模板ID数组,失败时返回null */ export const getSubscribeMessage = async (depositFee) => { try { debugger const config = await getConfigData(); if (!config || !config.config || !config.config.subscribeMessage) { return null; } const templateIds = config.config.subscribeMessage .filter(element => { // 如果没有押金,过滤掉扣费通知和退款通知 if (element.type == "reservation_success" || element.type == "reservation_change" || element.type == "reservation_reminder") { return true; } return false; // if (depositFee === 0) { // return element.type !== "deduction_notice" && element.type !== "refund"; // } // return true; }) .map(element => element.templateId); return templateIds; } catch (error) { console.error('获取订阅消息配置失败:', error); return null; } } /** * * @param {*} path * @returns */ export const getShareConfig = async (path) => { if (configData.value == null) { return null; } var config = configData.value.config; return { title: config.shareTitle, path: path, imageUrl: config.shareImage }; }