|
@@ -1,4 +1,4 @@
|
|
-import Taro from "@tarojs/taro";
|
|
|
|
|
|
+import Taro, { useDidShow } from "@tarojs/taro";
|
|
import { View, Image } from "@tarojs/components";
|
|
import { View, Image } from "@tarojs/components";
|
|
import WidgetCard from "@/components/widgets/widget-card/index";
|
|
import WidgetCard from "@/components/widgets/widget-card/index";
|
|
import ContactCard from "@/components/contact-card/index";
|
|
import ContactCard from "@/components/contact-card/index";
|
|
@@ -8,6 +8,8 @@ import { axios } from "taro-axios";
|
|
import { useEffect, useState } from "react";
|
|
import { useEffect, useState } from "react";
|
|
import { TAgent, TComponentItem } from "@/types/agent";
|
|
import { TAgent, TComponentItem } from "@/types/agent";
|
|
import { TContactItem } from "@/types/contact";
|
|
import { TContactItem } from "@/types/contact";
|
|
|
|
+import { getAgentBatch } from "@/service/agent";
|
|
|
|
+import { isSuccess } from "@/utils";
|
|
|
|
|
|
interface Props {
|
|
interface Props {
|
|
index: number;
|
|
index: number;
|
|
@@ -35,10 +37,29 @@ export default ({
|
|
|
|
|
|
const contacts = (component.data.values ?? []) as (TAgent|TContactItem)[]
|
|
const contacts = (component.data.values ?? []) as (TAgent|TContactItem)[]
|
|
|
|
|
|
|
|
+ const [list, setList] = useState<(TAgent|TContactItem)[]>(contacts);
|
|
|
|
+
|
|
|
|
|
|
// 非编辑模式且垂直平铺,背景显示为白色
|
|
// 非编辑模式且垂直平铺,背景显示为白色
|
|
const bgStyle = (component.data?.layout === "mini" || editMode) ? style.bgMini : style.bgFull
|
|
const bgStyle = (component.data?.layout === "mini" || editMode) ? style.bgMini : style.bgFull
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ const fetchData = async () => {
|
|
|
|
+ const response = await getAgentBatch(contacts.map(item=> item.agentId).join(','));
|
|
|
|
+ console.log(1111, response);
|
|
|
|
+ if(isSuccess(response.status)){
|
|
|
|
+ console.log('获取名片数据', response.data);
|
|
|
|
+ setList(response.data);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ useEffect(()=> {
|
|
|
|
+ fetchData()
|
|
|
|
+ }, [])
|
|
|
|
+
|
|
const handleClick= (item: TAgent|TContactItem) => {
|
|
const handleClick= (item: TAgent|TContactItem) => {
|
|
if(!editMode){
|
|
if(!editMode){
|
|
Taro.navigateTo({
|
|
Taro.navigateTo({
|
|
@@ -49,7 +70,7 @@ export default ({
|
|
|
|
|
|
|
|
|
|
const renderEmpty = ()=> {
|
|
const renderEmpty = ()=> {
|
|
- if(contacts.length){
|
|
|
|
|
|
+ if(list.length){
|
|
return <></>
|
|
return <></>
|
|
}
|
|
}
|
|
return <View className="px-16"><View className="component-card-empty">
|
|
return <View className="px-16"><View className="component-card-empty">
|
|
@@ -66,7 +87,7 @@ export default ({
|
|
if (component.data?.layout === "mini") {
|
|
if (component.data?.layout === "mini") {
|
|
return (
|
|
return (
|
|
<View className="grid grid-cols-3 gap-x-18 gap-y-20 px-16">
|
|
<View className="grid grid-cols-3 gap-x-18 gap-y-20 px-16">
|
|
- {contacts.map((item) => {
|
|
|
|
|
|
+ {list.map((item) => {
|
|
return (
|
|
return (
|
|
<View className="flex flex-col gap-8" onClick={()=> {handleClick(item)}}>
|
|
<View className="flex flex-col gap-8" onClick={()=> {handleClick(item)}}>
|
|
<View className={style.avatar}>
|
|
<View className={style.avatar}>
|
|
@@ -87,7 +108,7 @@ export default ({
|
|
//
|
|
//
|
|
return (
|
|
return (
|
|
<View className={`flex flex-col gap-8 ${editMode ? 'px-16' : ''}`}>
|
|
<View className={`flex flex-col gap-8 ${editMode ? 'px-16' : ''}`}>
|
|
- {contacts.map((item) => {
|
|
|
|
|
|
+ {list.map((item) => {
|
|
return (
|
|
return (
|
|
<ContactCard
|
|
<ContactCard
|
|
className={`${bgStyle} p-16`}
|
|
className={`${bgStyle} p-16`}
|