邮件html解析

dev/emitter
Lei OT 10 months ago
parent 72deb04451
commit 7132d7b76a

@ -1,6 +1,13 @@
import { fetchJSON, postForm } from '@/utils/request'; import { fetchJSON, postForm } from '@/utils/request';
import { API_HOST, EMAIL_HOST } from '@/config'; import { API_HOST, EMAIL_HOST } from '@/config';
import testData from './test1.json';
const parseHTMLString = (html) => {
const parser = new DOMParser()
const doc = parser.parseFromString(html, 'text/html')
const bodyContent = doc.body.innerHTML
return bodyContent
}
/** /**
* 获取顾问签名 * 获取顾问签名
@ -10,11 +17,7 @@ export const getSalesSignatureAction = async (params) => {
try { try {
const { result } = await fetchJSON(`${EMAIL_HOST}/email_sign`, params) const { result } = await fetchJSON(`${EMAIL_HOST}/email_sign`, params)
const { SignContent: html } = result const { SignContent: html } = result
const parser = new DOMParser(); return parseHTMLString(html);
const doc = parser.parseFromString(html, 'text/html');
const bodyContent = doc.body.innerHTML;
return bodyContent;
} catch (error) { } catch (error) {
return ''; return '';
} }
@ -66,7 +69,7 @@ export const getEmailDetailAction = async (params) => {
const { result } = await fetchJSON(`${EMAIL_HOST}/getmail`, params); const { result } = await fetchJSON(`${EMAIL_HOST}/getmail`, params);
const mailType = result.MailInfo?.[0]?.MAI_ContentType || ''; const mailType = result.MailInfo?.[0]?.MAI_ContentType || '';
return { info: encodeEmailInfo(result.MailInfo?.[0] || {}), content: mailType === 'text/html' ? (result.MailContent || '').replace(/[\r\n]/g, '') : (result.MailContent || ''), attachments: result?.AttachList || [] }; return { info: encodeEmailInfo(result.MailInfo?.[0] || {}), content: mailType === 'text/html' ? parseHTMLString((result.MailContent || '').replace(/\r\n/g, '')) : (result.MailContent || ''), attachments: result?.AttachList || [] };
} }
/** /**
@ -87,7 +90,7 @@ export const getEmailFetchAction = async (params) => {
*/ */
export const getEmailQuotationDraftAction = async (params) => { export const getEmailQuotationDraftAction = async (params) => {
const { result } = await fetchJSON(`${EMAIL_HOST}/QuotationLetter`, params) const { result } = await fetchJSON(`${EMAIL_HOST}/QuotationLetter`, params)
return { subject: (result.Subject || ''), content: (result.MailContent || '').replace(/[\r\n]/g, '') } return { subject: (result.Subject || ''), content: parseHTMLString((result.MailContent || '').replace(/\r\n/g, '')) }
} }
/** /**

Loading…
Cancel
Save