/**
 * C 端商城配置 → 关于页展示模型
 * 数据来源：GET /api/mall/config（MallConfigAppVO）
 */
export function mapMallAboutPage(data) {
  const raw = data || {}
  const filings = []
  if (raw.icpNo && raw.icpLink) {
    filings.push({
      key: 'icp',
      label: 'ICP 备案',
      no: raw.icpNo,
      link: raw.icpLink
    })
  }
  if (raw.psbNo && raw.psbLink) {
    filings.push({
      key: 'psb',
      label: '公安备案',
      no: raw.psbNo,
      link: raw.psbLink
    })
  }
  return {
    currencySymbol: raw.currencySymbol || '¥',
    showSales: raw.showSales === true,
    filings,
    hasFiling: filings.length > 0
  }
}

/** 打开备案外链（H5 / App / 小程序降级复制） */
export function openExternalLink(url) {
  if (!url) return
  // #ifdef H5
  window.open(url, '_blank')
  // #endif
  // #ifdef APP-PLUS
  plus.runtime.openURL(url)
  // #endif
  // #ifdef MP
  uni.setClipboardData({
    data: url,
    success: () => {
      uni.showToast({ title: '链接已复制，请在浏览器打开', icon: 'none' })
    }
  })
  // #endif
}
