|
@@ -2,90 +2,126 @@ import { View } from "@tarojs/components";
|
|
|
import style from "./index.module.less";
|
|
|
import TagCertificated from "@/components/tag-certificated";
|
|
|
|
|
|
-import IconPhoneGray from "@/components/icon/IconPhoneGray";
|
|
|
-import IconMailGray from "@/components/icon/IconMailGray";
|
|
|
-import IconLocationGray from "@/components/icon/IconLocationGray";
|
|
|
-import IconQRCodeGray from "@/components/icon/IconQrcodeGray";
|
|
|
import IconPlusBlue from "@/components/icon/icon-plus-blue";
|
|
|
import Popup from "@/components/popup/popup";
|
|
|
import WemetaTabs from "@/components/wemeta-tabs/index";
|
|
|
import { useAgentStore } from "@/store/agentStore";
|
|
|
import { TAgent } from "@/types/agent";
|
|
|
import Taro from "@tarojs/taro";
|
|
|
-import ContactIcon from '@/components/ContactIcon'
|
|
|
+import ContactIcon from "@/components/ContactIcon";
|
|
|
interface IProps {
|
|
|
show: boolean;
|
|
|
setShow: (show: boolean) => void;
|
|
|
}
|
|
|
export default ({ show, setShow }: IProps) => {
|
|
|
+ const { agents, setDefaultAgent, fetchAgents, createAgent } = useAgentStore();
|
|
|
+ let loading = false;
|
|
|
+ const personalAgents = agents.filter((item) => !item.isEnt);
|
|
|
+ const entAgents = agents.filter((item) => item.isEnt);
|
|
|
|
|
|
- const { agents, setDefaultAgent, fetchAgents } = useAgentStore()
|
|
|
- let loading = false
|
|
|
- const personalAgents = agents.filter( item => !item.isEnt)
|
|
|
- const entAgents = agents.filter( item => item.isEnt)
|
|
|
|
|
|
- const handleClick = async (item: TAgent)=> {
|
|
|
- if(loading){
|
|
|
- return
|
|
|
+
|
|
|
+
|
|
|
+ const handleClick = async (item: TAgent) => {
|
|
|
+ if (loading) {
|
|
|
+ return;
|
|
|
}
|
|
|
loading = true;
|
|
|
- Taro.showLoading({title: '加载中'})
|
|
|
- const result = await setDefaultAgent(item.agentId)
|
|
|
-
|
|
|
- if(result){
|
|
|
- await fetchAgents()
|
|
|
+ Taro.showLoading({ title: "加载中" });
|
|
|
+ const result = await setDefaultAgent(item.agentId);
|
|
|
+
|
|
|
+ if (result) {
|
|
|
+ await fetchAgents();
|
|
|
}
|
|
|
loading = false;
|
|
|
- Taro.hideLoading()
|
|
|
+ Taro.hideLoading();
|
|
|
+ setShow(false)
|
|
|
+
|
|
|
+ };
|
|
|
+
|
|
|
+ const handleCreate = async ()=> {
|
|
|
+ Taro.showLoading()
|
|
|
+ if (loading) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ loading = true;
|
|
|
+ try{
|
|
|
+ const response = await createAgent()
|
|
|
+ if(response?.agentId){
|
|
|
+ const result = await setDefaultAgent(response.agentId);
|
|
|
+ if (result) {
|
|
|
+ await fetchAgents();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Taro.hideLoading()
|
|
|
+ loading = false;
|
|
|
+ setShow(false)
|
|
|
+ }catch(e:any){
|
|
|
+ Taro.hideLoading()
|
|
|
+ loading = false;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
const renderCard = (item: TAgent, isEnt: boolean) => {
|
|
|
- return <View className={item.isDefault ? style.cardActive : style.card}>
|
|
|
- <View className="flex items-start mb-24" onClick={()=> handleClick(item)}>
|
|
|
- <View className="flex flex-col flex-1">
|
|
|
- <View className="flex items-end gap-8 text-gray-65">
|
|
|
- <View className="text-20 font-medium leading-28 text-black">
|
|
|
- {item.name}
|
|
|
+ return (
|
|
|
+ <View className={item.isDefault ? style.cardActive : style.card}>
|
|
|
+ <View
|
|
|
+ className="flex items-start mb-24"
|
|
|
+ onClick={() => handleClick(item)}
|
|
|
+ >
|
|
|
+ <View className="flex flex-col flex-1">
|
|
|
+ <View className="flex items-end gap-8 text-gray-65">
|
|
|
+ <View className="text-20 font-medium leading-28 text-black">
|
|
|
+ {item.name}
|
|
|
+ </View>
|
|
|
+ <View className="text-12 leading-20">
|
|
|
+ {item.position ?? "暂无职位信息"}
|
|
|
+ </View>
|
|
|
+ </View>
|
|
|
+ <View className="flex items-center gap-2">
|
|
|
+ <View className="text-12 leading-20 truncate max-w-[188px]">
|
|
|
+ {item.entName ?? "暂无公司信息"}
|
|
|
+ </View>
|
|
|
+ {isEnt && <TagCertificated />}
|
|
|
+ </View>
|
|
|
</View>
|
|
|
- <View className="text-12 leading-20">{item.position ?? '暂无职位信息'}</View>
|
|
|
</View>
|
|
|
- <View className="flex items-center gap-2">
|
|
|
- <View className="text-12 leading-20 truncate max-w-[188px]">
|
|
|
- {item.entName ?? '暂无公司信息'}
|
|
|
- </View>
|
|
|
- {isEnt && <TagCertificated />}
|
|
|
+ <View className={style.icons}>
|
|
|
+ <ContactIcon type="phone" actived={!!item?.mobile}></ContactIcon>
|
|
|
+ <ContactIcon type="mail" actived={!!item?.email}></ContactIcon>
|
|
|
+ <ContactIcon type="location" actived={!!item?.address}></ContactIcon>
|
|
|
+ <ContactIcon type="qrcode" actived={!!item?.qrCodeUrl}></ContactIcon>
|
|
|
</View>
|
|
|
</View>
|
|
|
- </View>
|
|
|
- <View className={style.icons}>
|
|
|
- <ContactIcon type="phone" actived={!!item?.mobile}></ContactIcon>
|
|
|
- <ContactIcon type="mail" actived={!!item?.email}></ContactIcon>
|
|
|
- <ContactIcon type="location" actived={!!item?.address}></ContactIcon>
|
|
|
- <ContactIcon type="qrcode" actived={!!item?.qrCodeUrl}></ContactIcon>
|
|
|
- </View>
|
|
|
- </View>
|
|
|
- }
|
|
|
+ );
|
|
|
+ };
|
|
|
|
|
|
- const renderPersonalAgents = ()=> {
|
|
|
+ const renderPersonalAgents = () => {
|
|
|
return personalAgents.map((item) => {
|
|
|
- return renderCard(item, false)
|
|
|
- })
|
|
|
- }
|
|
|
+ return renderCard(item, false);
|
|
|
+ });
|
|
|
+ };
|
|
|
|
|
|
const renderEntAgents = () => {
|
|
|
- if(entAgents.length){
|
|
|
+ if (entAgents.length) {
|
|
|
return entAgents.map((item) => {
|
|
|
- return renderCard(item, true)
|
|
|
- })
|
|
|
+ return renderCard(item, true);
|
|
|
+ });
|
|
|
}
|
|
|
- return <View className={style.card}>
|
|
|
- <View className="flex flex-col items-center">
|
|
|
- <View className="text-16 leading-24 font-medium mb-4">你还没有企业配置的名片</View>
|
|
|
- <View className="text-12 text-gray-45 leading-20 mb-24">企业小蓝本由公司创建并授权,可引用企业知识内容</View>
|
|
|
- <View className="text-primary font-medium leading-22">联系我们</View>
|
|
|
- </View>
|
|
|
- </View>
|
|
|
- }
|
|
|
+ return (
|
|
|
+ <View className={style.card}>
|
|
|
+ <View className="flex flex-col items-center">
|
|
|
+ <View className="text-16 leading-24 font-medium mb-4">
|
|
|
+ 你还没有企业配置的名片
|
|
|
+ </View>
|
|
|
+ <View className="text-12 text-gray-45 leading-20 mb-24">
|
|
|
+ 企业小蓝本由公司创建并授权,可引用企业知识内容
|
|
|
+ </View>
|
|
|
+ <View className="text-primary font-medium leading-22">联系我们</View>
|
|
|
+ </View>
|
|
|
+ </View>
|
|
|
+ );
|
|
|
+ };
|
|
|
|
|
|
const tabList = [
|
|
|
{
|
|
@@ -96,45 +132,11 @@ export default ({ show, setShow }: IProps) => {
|
|
|
<View className="pt-12">
|
|
|
<View className={style.tabContainer}>
|
|
|
{renderPersonalAgents()}
|
|
|
- {/* <View className={style.card}>
|
|
|
- <View className="flex items-start mb-24">
|
|
|
- <View className="flex flex-col flex-1">
|
|
|
- <View className="flex items-end gap-8 text-gray-65">
|
|
|
- <View className="text-20 font-medium leading-28 text-black">
|
|
|
- 张三
|
|
|
- </View>
|
|
|
- <View className="text-12 leading-20">销售医师</View>
|
|
|
- </View>
|
|
|
- <View className="flex items-center gap-2">
|
|
|
- <View className="text-12 leading-20 truncate max-w-[188px]">
|
|
|
- 北京茗视光眼科医院管理有限公司
|
|
|
- </View>
|
|
|
- <TagCertificated />
|
|
|
- </View>
|
|
|
- </View>
|
|
|
- </View>
|
|
|
- <View className={style.icons}>
|
|
|
- <View className={style.icon}>
|
|
|
- <IconPhoneGray />
|
|
|
- </View>
|
|
|
- <View className={style.icon}>
|
|
|
- <IconMailGray />
|
|
|
- </View>
|
|
|
- <View className={style.icon}>
|
|
|
- <IconLocationGray />
|
|
|
- </View>
|
|
|
- <View className={style.icon}>
|
|
|
- <IconQRCodeGray />
|
|
|
- </View>
|
|
|
- </View>
|
|
|
- </View> */}
|
|
|
-
|
|
|
|
|
|
-
|
|
|
- <View className="button-rounded button-primary-light gap-8 mb-15">
|
|
|
- <IconPlusBlue />
|
|
|
- <View>创建新的智能体</View>
|
|
|
- </View>
|
|
|
+ <View className="button-rounded button-primary-light gap-8 mb-15" onClick={handleCreate}>
|
|
|
+ <IconPlusBlue />
|
|
|
+ <View>创建新的智能体</View>
|
|
|
+ </View>
|
|
|
</View>
|
|
|
</View>
|
|
|
</>
|
|
@@ -146,9 +148,7 @@ export default ({ show, setShow }: IProps) => {
|
|
|
children: (
|
|
|
<>
|
|
|
<View className="pt-12">
|
|
|
- <View className={style.tabContainer}>
|
|
|
- {renderEntAgents()}
|
|
|
- </View>
|
|
|
+ <View className={style.tabContainer}>{renderEntAgents()}</View>
|
|
|
</View>
|
|
|
</>
|
|
|
),
|