跳转到内容
Nacre
组件配色
EN

软电话 · 热线通话卡与来电表头 CallStatusCard

experimentalCallStatusCard · CallPanelHeader在画廊运行
CallStatusCard
在浏览器里运行真实组件。

侧栏热线卡与来电、拨号弹框表头。振铃短暂染底,接通后用中性卡面,表头与弹框共用表面。

状态:experimental · 组件:CallStatusCard、CallPanelHeader

import { CallStatusCard, CallPanelHeader } from 'nacre/call'

切换下线、待机、振铃、接通,或点接听和挂断。线路与操作固定在首行,通话内容在下方。

import { Text, View, signal } from 'nsh'
import { Button, Segmented, ToolbarButton, TEXT_SIZE } from 'nacre'
import { CallStatusCard } from 'nacre/call'
import type { CallStatusCardProps } from 'nacre/call'
export function CallStatusCardUsage() {
const phase = signal<CallStatusCardProps['phase']>('connected')
const muted = signal(false)
const hotline = '香港热线'
const labels = {
offline: '已下线', idle: '待机',
ringing: '振铃中', connected: '通话中',
}
return (
<View class="items-start gap-3">
<Segmented accessibilityLabel="通话状态" value={phase()}
onChange={(value) => { phase.set(value); muted.set(false) }}
options={(Object.keys(labels) as (keyof typeof labels)[]).map((value) => ({ value, label: labels[value] }))} />
<View class="w-60">
<CallStatusCard testID="demo-hotline" phase={phase()} hotline={hotline} accessibilityLabel={hotline}
headerEnd={<Text class={`flex-1 text-right ${TEXT_SIZE.small} text-muted-foreground`}>{labels[phase()]}</Text>}>
<If when={phase() === 'connected' || phase() === 'ringing'}>
<Text class={`${TEXT_SIZE.title} text-foreground`}>+852 5555 0123</Text>
<If when={phase() === 'connected'} else={<Button variant="primary" size="sm" onPress={() => phase.set('connected')}>接听</Button>}>
<Text class={`${TEXT_SIZE.small} text-muted-foreground tabular-nums`}>01:05</Text>
<ToolbarButton variant="control" icon="headset" label={muted() ? '取消静音' : '静音'}
pressed={muted()} onPress={() => muted.set(!muted())} />
<Button testID="demo-hotline-end" variant="primary" tone="danger" size="sm" onPress={() => { phase.set('idle'); muted.set(false) }}>挂断</Button>
</If>
</If>
</CallStatusCard>
</View>
</View>
)
}

来电显示标题和热线,拨号面板可显示外显号码与关闭按钮。标题沿用弹框表面。

import { Text, View, signal } from 'nsh'
import { Button, Icon, IconButton, TEXT_SIZE } from 'nacre'
import { CallPanelHeader } from 'nacre/call'
export function CallPanelHeaderExample() {
const hotline = '香港热线'
const dialer = signal(true)
return (
<View class="flex-row flex-wrap gap-3">
<View class="w-64 rounded-lg border border-border bg-popover overflow-hidden">
<CallPanelHeader testID="demo-incoming-header" title="来电呼入" meta={hotline}
icon={(glyph) => <Icon name="phone" size={glyph.size} color={glyph.color} />} />
<Text class={`px-4 py-3 ${TEXT_SIZE.body} text-popover-foreground`}>+852 5555 0123</Text>
</View>
<If when={dialer()} else={<Button size="sm" onPress={() => dialer.set(true)}>打开拨号盘</Button>}>
<View class="w-64 rounded-lg border border-border bg-popover overflow-hidden">
<CallPanelHeader title={hotline} subtitle="+852 5555 0100"
actions={<IconButton icon="close" label="关闭" onPress={() => dialer.set(false)} />} />
</View>
</If>
</View>
)
}
键 行为
Tab 移动到卡内下一个操作
  • 状态由文案、图标和可用操作共同表达。
  • 给热线卡提供读屏名,关闭和通话操作各有自己的名称。

该用

  • 业务负责拨号、接听、挂断和计时
  • 在 headerEnd 放拨号盘和坐席开关

不该用

  • 给接通状态或弹框表头铺整块品牌色
属性 类型 默认 说明
phase * 'offline' | 'idle' | 'ringing' | 'connected' —
hotline * string —
icon IconRender — 线路图标;默认电话听筒,图标是装饰,状态由卡内文案说明。
headerEnd JSX.Element — 线路名右侧的坐席状态、拨号盘和开关。
children JSX.Element — 卡内放坐席、联系人、计时、操作和告警。
accessibilityLabel string —
viewRef (node: ViewRef) => void —
obscured boolean —
testID string —

* 必填

属性 类型 默认 说明
title * string —
subtitle string —
meta string —
icon IconRender —
actions JSX.Element —
testID string —
subtitleTestID string —

* 必填