import { useEffect, useState } from 'react'; import { View, Text } from '@tarojs/components'; import '../../styles/legal.css'; import Taro from '@tarojs/taro'; import PageShell from '../../components/PageShell'; import SubPageHeader from '../../components/SubPageHeader'; import { toast } from '../../lib/api'; import { getBrandAssetsSync, loadBrandAssets } from '../../lib/brand-assets'; import { BENEFIT_RULES_FOOTER, BENEFIT_RULES_SECTIONS, BENEFIT_RULES_SUMMARY, BENEFIT_RULES_TITLE, } from '../../lib/benefit-copy'; export default function BenefitRulesPage() { const [phone, setPhone] = useState(() => getBrandAssetsSync().customerServicePhone); useEffect(() => { void loadBrandAssets().then((brand) => setPhone(brand.customerServicePhone)); }, []); function dial() { const tel = phone.replace(/-/g, ''); Taro.makePhoneCall({ phoneNumber: tel }).catch(() => toast('无法拨打电话')); } return ( {BENEFIT_RULES_SUMMARY.replace(/不可兑现、不可转卖。$/, '')} 不可兑现、不可转卖。 {BENEFIT_RULES_SECTIONS.map((section) => ( {section.heading} {section.paragraphs.map((p, i) => { const emphasize = 'emphasize' in section ? section.emphasize : ''; const emphasizeAll = 'emphasizeAll' in section && section.emphasizeAll; if (emphasizeAll) { return ( {p} ); } if (emphasize && p.includes(emphasize)) { const [before, after] = p.split(emphasize); return ( {before} {emphasize} {after} ); } return ( {p} ); })} {section.heading === '八、联系客服' ? ( {phone} ) : null} ))} {BENEFIT_RULES_FOOTER} ); }