index.tsx 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. import { useState } from 'react'
  2. import Taro from '@tarojs/taro'
  3. import { Image, View } from '@tarojs/components'
  4. import IconCertificateColor from "@/components/icon/icon-certificate-color";
  5. import { TAgentDetail } from '@/types/agent';
  6. import { AvatarMedia } from '@/components/AvatarMedia';
  7. import IconMicOutline from '@/components/icon/IconMicOutline';
  8. import IconArrowRightGray from '@/components/icon/IconArrowRightGray';
  9. import IconClean from '@/components/icon/IconClean';
  10. import IconArrowVerticalFilled from '@/components/icon/IconArrowVerticalFilled';
  11. import { useTextChat } from '@/store/textChatStore';
  12. import style from './index.module.less'
  13. interface IProps {
  14. agent: TAgentDetail|null
  15. haveBg: boolean
  16. onClear: ()=>void
  17. }
  18. export default ({haveBg, agent, onClear}:IProps) => {
  19. /**
  20. * 之前个人卡片信息有两种样式,现在统一为一种
  21. */
  22. const nameStyle = haveBg ? 'text-white' : 'text-black'
  23. const entStyle = haveBg ? 'text-white' : 'text-black-45'
  24. const [show, setShow] = useState(false)
  25. const { setIsNewChat } = useTextChat()
  26. const handleClick = (e:any) => {
  27. e.stopPropagation()
  28. setShow(!show)
  29. }
  30. const handleClean = (e:any) => {
  31. // e.stopPropagation()
  32. console.log('clean')
  33. setShow(false)
  34. setIsNewChat(true)
  35. onClear()
  36. }
  37. const handleVoiceChoose = (e:any) => {
  38. setShow(false)
  39. Taro.navigateTo({
  40. url: '/pages/voice/index'
  41. })
  42. console.log('handleVoiceChoose')
  43. }
  44. const renderContent = () => {
  45. return <>
  46. <View className='flex items-center' onClick={handleClick}>
  47. <View className='flex-1 flex items-center mr-16'>
  48. <View className="rounded-full overflow-hidden w-36 h-36 shrink-0 mr-8">
  49. <AvatarMedia source={agent?.avatarLogo || ''} className='w-36 h-36'></AvatarMedia>
  50. </View>
  51. <View className="flex flex-col flex-1 gap-6">
  52. <View className="flex items-center gap-4">
  53. <View className={`text-14 font-medium leading-14 ${nameStyle}`}>{agent?.name}</View>
  54. {agent?.isEnt && <View className="text-12 leading-12"><IconCertificateColor/></View>}
  55. </View>
  56. {agent?.entName && <View className="flex items-center gap-2">
  57. <View className={`text-12 leading-12 truncate max-w-[180px] ${entStyle}`}>
  58. {agent?.entName}
  59. </View>
  60. </View>}
  61. </View>
  62. </View>
  63. <View className='w-16 h-16'>
  64. <View className='relative w-16 h-16'>
  65. <View>
  66. <IconArrowVerticalFilled color={ haveBg ? 'white' : 'gray' } rotation={show ? 0 : 180} />
  67. </View>
  68. {!!show && <View className={style.bubbleWrapper} onClick={(e)=>e.stopPropagation()}>
  69. <View className={`flex flex-col gap-8 ${style.bubble}`}>
  70. <View className={style.bubbleArrowWrap}>
  71. <View className={style.bubbleArrow}></View>
  72. </View>
  73. <View className='flex items-center gap-4' onClick={handleClean}>
  74. <View className='w-16 h-16'>
  75. <IconClean />
  76. </View>
  77. <View className='flex-1'>清除对话</View>
  78. </View>
  79. <View className='h-1' style={{backgroundColor: 'rgba(17,17,17,.15)', width: '100%'}}></View>
  80. <View className='flex items-center gap-4' onClick={handleVoiceChoose}>
  81. <View className='w-16 h-16'><IconMicOutline/></View>
  82. <View className='flex-1'>音色选择</View>
  83. <View className='w-16 h-16'><IconArrowRightGray/></View>
  84. </View>
  85. </View>
  86. </View>}
  87. </View>
  88. </View>
  89. </View>
  90. </>
  91. }
  92. return (
  93. <View className="flex items-center gap-8">
  94. {renderContent()}
  95. </View>
  96. )
  97. }