Browse Source

feat: 对接智能体联系方式表单

王晓东 1 month ago
parent
commit
be04ac7c02

+ 3 - 14
src/components/AgentPage/components/AgentQRcode/index.module.less

@@ -11,20 +11,9 @@
   display: flex;
   align-items: center;
   justify-content: center;
-  margin-bottom: 12px;
   padding: 20px;
-  width: 315px;
-  height: 415px;
+  width: 206px;
+  height: 206px;
   border-radius: 16px;
-  border: 1px solid rgba(#000, .05);
+  border: 1px dashed rgba(#000, .1);
 }
-
-.bottomButtons{
-  display: flex;
-  align-items: center;
-  justify-content: center;
-  font-weight: 500;
-  font-size: 12px;
-  line-height: 20px;
-  height: 88px;
-}

+ 14 - 19
src/components/AgentPage/components/AgentQRcode/index.tsx

@@ -1,11 +1,8 @@
 import { Image, View } from "@tarojs/components";
-import { useAppStore } from "@/store/appStore";
 import Popup from "@/components/popup/popup";
-import { useState } from "react";
 import style from "./index.module.less";
 import QrcodeUploadTips from "@/components/qrcode-upload-tips";
-import useEditContactCard from "@/hooks/useEditContactCard";
-import { useAgentStore } from "@/store/agentStore";
+import { useAgentStore, useAgentStoreActions } from "@/store/agentStore";
 import { pickAndUploadImageWithCrop } from "@/utils/upload";
 import Taro from "@tarojs/taro";
 import { TAgentDetail } from "@/types/agent";
@@ -17,11 +14,10 @@ interface IProps {
   agent: TAgentDetail
 }
 export default ({ show, setShow, agent, isVisitor }: IProps) => {
+  const { saveAgent, updateEditAgent } = useAgentStoreActions();
+  const agentEdit = useAgentStore((state) => state.agentEdit);
   const isMine = (!isVisitor)
-  const { setValue, submit } = useEditContactCard(
-    "qrCodeUrl",
-    agent?.qrCodeUrl
-  );
+
   const handleClick = async () => {
     Taro.showLoading();
     try{
@@ -30,9 +26,8 @@ export default ({ show, setShow, agent, isVisitor }: IProps) => {
       if (!result?.url) {
         return;
       }
-      setValue(result.url);
-
-      submit(result.url);
+      updateEditAgent({'qrCodeUrl': result.url})
+      saveAgent({'qrCodeUrl': result.url})
 
     }catch(e:any){
       Taro.hideLoading()
@@ -40,14 +35,13 @@ export default ({ show, setShow, agent, isVisitor }: IProps) => {
   };
 
   const handleClear = () => {
-    setValue('');
-
-    submit('');
+    updateEditAgent({'qrCodeUrl': ''})
+    saveAgent({'qrCodeUrl': ''})
   }
 
   const renderQrcode = () => {
-    if (agent?.qrCodeUrl) {
-      return <Image src={agent?.qrCodeUrl} showMenuByLongpress mode="widthFix"></Image>;
+    if (agentEdit?.qrCodeUrl) {
+      return <Image src={agentEdit?.qrCodeUrl} showMenuByLongpress mode="widthFix" style={{width: '206px', height: '206px'}}></Image>;
     }
 
     if(isMine){
@@ -63,15 +57,16 @@ export default ({ show, setShow, agent, isVisitor }: IProps) => {
   return (
     <View className="relative">
       <Popup setShow={setShow} show={show} title="二维码">
+        <View className="text-14 text-gray-4 leading-24 pt-16 pb-24">方便客户快速沟通,扫码即可联系你</View>
         <View className={style.container}>
           <View className={style.card}>
             {renderQrcode()}
           </View>
 
-          {isMine && <View className={style.bottomButtons}>
-            <View className="pr-16" onClick={handleClick}>替换</View>
+          {isMine && <View className='flex items-center text-12 font-pingfangSCMedium font-medium gap-16 pt-24'>
+            <View className="text-primary" onClick={handleClick}>替换</View>
             <View className="text-gray-3">|</View>
-            <View className="pl-16" onClick={handleClear}>清空</View>
+            <View className="text-primary" onClick={handleClear}>清空</View>
           </View>}
         </View>
       </Popup>

+ 12 - 12
src/components/WemetaTextareaAI/index.tsx

@@ -1,6 +1,6 @@
 import { View, Textarea, InputProps } from "@tarojs/components";
 import TextPolish from '@/components/TextPolish'
-import style from "./index.module.less";
+import styleIndex from "./index.module.less";
 import { useState, useRef, useCallback, useMemo, forwardRef, useImperativeHandle } from "react";
 import { countCharacters, getStrByMaxLength } from "@/utils/index";
 interface Props {
@@ -15,7 +15,7 @@ interface Props {
   confirmType?: keyof InputProps.ConfirmType;
   extra?: () => JSX.Element | JSX.Element[] | undefined;
   prefix?: () => JSX.Element | JSX.Element[] | undefined;
-  extraStyle?: Record<string, string>;
+  style?: Record<string, string>;
   onInput?: (value: string) => void;
   onBlur?: (value: string) => void;
   bgColor?: string;
@@ -30,7 +30,7 @@ const Index = ({
   defaultAiTips,
   bgColor,
   extraClass,
-  extraStyle,
+  style,
   disabled,
   confirmType,
   prefix,
@@ -112,12 +112,12 @@ const Index = ({
   return (
     <View
       className={`${
-        focus ? style.inputContainerFocused : style.inputContainer
+        focus ? styleIndex.inputContainerFocused : styleIndex.inputContainer
       }  p-12`}
       style={containerStyle}
     >
       <View className="flex w-full pb-12">
-        <View className={style.label}>
+        <View className={styleIndex.label}>
           {prefix && prefix()}
         </View>
       <View className="flex items-center gap-4 text-14 font-pingfangSCMedium">
@@ -125,17 +125,17 @@ const Index = ({
       </View>
       </View>
 
-      <View className={style.textareaContainer}>
+      <View className={styleIndex.textareaContainer}>
         <Textarea
           ref={inputRef}
           value={value}
           disabled={disabled || isPolishing}
           confirmType={confirmType}
-          style={extraStyle}
+          style={style}
           onInput={handleTextareaInput}
           placeholder={placeholder}
           placeholderStyle="rgba(17,17,17,.25)"
-          className={`${style.textInput} ${extraClass || ''}`}
+          className={`${styleIndex.textInput} ${extraClass || ''}`}
           onFocus={handleFocus}
           onBlur={handleBlur}
           autoHeight={autoHeight}
@@ -144,7 +144,7 @@ const Index = ({
           maxlength={DEFAULT_TEXTAREA_MAXLENGTH}
           onConfirm={handleConfirm}
         />
-        <View className={`${style.textareaButtons} justify-end gap-8`}>
+        <View className={`${styleIndex.textareaButtons} justify-end gap-8`}>
           {extra && extra()}
           {maxlength && (
             <View className="text-gray-4">
@@ -152,9 +152,9 @@ const Index = ({
             </View>
           )}
         </View>
-        <View className={`${ isPolishing ? style.skelonton : style.skelontonHide}`}>
-          <View className={style.skelontonItem}></View>
-          <View className={style.skelontonItemShort}></View>
+        <View className={`${ isPolishing ? styleIndex.skelonton : styleIndex.skelontonHide}`}>
+          <View className={styleIndex.skelontonItem}></View>
+          <View className={styleIndex.skelontonItemShort}></View>
         </View>
       </View>
     </View>

+ 7 - 0
src/components/icon/IconCloseThin/index.tsx

@@ -0,0 +1,7 @@
+import { Image } from '@tarojs/components'
+import Icon from '@/images/svgs/IconCloseThin.svg'
+export default () => {
+  return (
+    <Image src={Icon} mode="widthFix" style={{width: '16px', height: '16px'}}></Image>
+  )
+}

+ 3 - 4
src/components/popup-link-copyer/index.tsx

@@ -2,7 +2,6 @@ import { View, Image } from "@tarojs/components"
 import { TSocialMediaItem } from '@/types/index'
 import style from './index.module.less'
 import Taro from "@tarojs/taro"
-import closeIcon from '@/images/icon-close-8.png';
 import IconCorrect from '@/images/svgs/website/IconCorrect.svg'
 
 import Popup from "@/components/popup/popup";
@@ -15,7 +14,7 @@ interface Props {
 export default ({show, setShow, link, mediaItem}:Props)=> {
   let iconClassName = `${mediaItem.className}`
   let title = mediaItem.label
-  
+
   const handleCopy = (e: any)=> {
     e.stopPropagation();
     // 手动复制并 toast 提示
@@ -65,8 +64,8 @@ export default ({show, setShow, link, mediaItem}:Props)=> {
             </View>
             <View className={style.copyButton} onClick={handleCopy}>复制链接</View>
           </View>
-          
+
         </View>
       </View>
    </Popup>
-}
+}

+ 5 - 4
src/components/popup-page/popup-page/index.tsx

@@ -1,6 +1,7 @@
 import { View, PageContainer, Image } from "@tarojs/components"
 import style from './index.module.less'
-import closeIcon from '@/images/icon-close-8.png';
+import IconCloseThin from "@/components/icon/IconCloseThin";
+
 interface Props {
   setShow: (show: boolean)=>void
   show: boolean,
@@ -11,7 +12,7 @@ export default ({title, show, setShow, children}:Props)=> {
   const handlePopupLeave = () => {
     setShow(false)
   }
-  
+
   return <PageContainer
     show={show}
     round
@@ -24,11 +25,11 @@ export default ({title, show, setShow, children}:Props)=> {
     >
       <View className={style.container}>
         <View className={style.closeButton} onClick={()=>setShow(false)}>
-          <Image src={closeIcon} mode="widthFix" className={style.closeIcon} />
+          <IconCloseThin />
         </View>
         <View className={style.content}>
           {children}
         </View>
       </View>
    </PageContainer>
-}
+}

+ 2 - 3
src/components/popup/popup-modal/index.tsx

@@ -1,6 +1,5 @@
 import { View, Image } from "@tarojs/components"
 import style from './index.module.less'
-import closeIcon from '@/images/icon-close-8.png';
 interface Props {
   title?: string
   setShow: (show: boolean)=>void
@@ -8,7 +7,7 @@ interface Props {
   children?: JSX.Element|JSX.Element[]
 }
 export default ({title = '', show, setShow, children}:Props)=> {
-  
+
   return <>
     {show && <View
       className={`taro-portal-container ${style.popup}`}
@@ -23,4 +22,4 @@ export default ({title = '', show, setShow, children}:Props)=> {
       </View>
    </View>}
   </>
-}
+}

+ 0 - 5
src/components/popup/popup/index.module.less

@@ -52,11 +52,6 @@
   width: 24px;
   height: 24px;
   border-radius: 100%;
-  background-color: #F2F4F5;
-}
-.closeIcon{
-  width: 8.25px;
-  width: 8.25px;
 }
 
 .title{

+ 3 - 7
src/components/popup/popup/index.tsx

@@ -1,6 +1,6 @@
 import { View, Image, RootPortal } from "@tarojs/components";
 import style from "./index.module.less";
-import closeIcon from "@/images/icon-close-8.png";
+import IconCloseThin from "@/components/icon/IconCloseThin";
 import { useEffect, useState } from "react";
 import Taro from "@tarojs/taro";
 interface IProps {
@@ -39,7 +39,7 @@ export default ({
       Taro.hideTabBar().catch(()=> {});
     } else {
       Taro.showTabBar().catch(()=> {});
-      
+
     }
   }, [show]);
 
@@ -56,11 +56,7 @@ export default ({
                     <View
                       className={style.closeButton}
                     >
-                      <Image
-                        src={closeIcon}
-                        mode="widthFix"
-                        className={style.closeIcon}
-                      />
+                      <IconCloseThin />
                     </View>
                   </View>
                 )}

+ 7 - 7
src/components/wemeta-input/index.tsx

@@ -1,5 +1,5 @@
 import { View, Input, InputProps } from "@tarojs/components";
-import style from "./index.module.less";
+import styleIndex from "./index.module.less";
 import { useState, useRef } from "react";
 import { countCharacters, getStrByMaxLength } from "@/utils/index";
 interface Props {
@@ -13,7 +13,7 @@ interface Props {
   confirmType?: keyof InputProps.ConfirmType;
   onConfirm?: (value: string) => void;
   cursorSpacing?: number;
-  extraStyle?: Record<string, string>;
+  style?: Record<string, string>;
   adjustPosition?: boolean
   maxlength?: number;
   placeholderStyle?: string;
@@ -27,7 +27,7 @@ const index = ({
   onInput,
   onConfirm,
   confirmType = "done",
-  extraStyle,
+  style,
   prefix,
   suffix,
   onBlur,
@@ -64,23 +64,23 @@ const index = ({
   return (
     <View
       className={`${
-        focus ? style.inputContainerFocused : style.inputContainer
+        focus ? styleIndex.inputContainerFocused : styleIndex.inputContainer
       } p-12`}
-      style={extraStyle}
     >
       <View
-        className={style.inputAreaContainer}
+        className={styleIndex.inputAreaContainer}
       >
         {prefix && prefix()}
         <Input
           value={value}
           ref={inputRef}
+          style={style}
           type="text"
           adjustPosition={adjustPosition}
           onInput={(e: any) => handleInput(e.target.value)}
           placeholder={placeholder}
           placeholderStyle={placeholderStyle ?? "color: rgba(17,17,17,.25)"}
-          className={style.textInput}
+          className={styleIndex.textInput}
           onFocus={handleFocus}
           onBlur={handleBlur}
           cursorSpacing={cursorSpacing}

+ 2 - 2
src/components/wemeta-textarea/index.module.less

@@ -1,7 +1,7 @@
 .inputContainer{
   display: flex;
   align-items: center;
-  padding: 10px;
+  padding: 14px 16px;
   border-radius: 12px;
   background-color: white;
   border: 2px solid transparent;
@@ -42,4 +42,4 @@
   flex: 1;
   align-items: center;
   gap: 8px;
-}
+}

+ 11 - 9
src/components/wemeta-textarea/index.tsx

@@ -1,5 +1,5 @@
 import { View, Textarea, InputProps } from "@tarojs/components";
-import style from "./index.module.less";
+import styleIndex from "./index.module.less";
 import { useState, useRef, useEffect } from "react";
 import { countCharacters, getStrByMaxLength } from "@/utils/index";
 interface Props {
@@ -12,20 +12,21 @@ interface Props {
   confirmType?: keyof InputProps.ConfirmType;
   extra?: () => JSX.Element | JSX.Element[] | undefined;
   prefix?: () => JSX.Element | JSX.Element[] | undefined;
-  extraStyle?: Record<string, string>;
+  style?: React.CSSProperties;
   onInput?: (value: string) => void;
   onBlur?: (value: string) => void;
   bgColor?: string;
   autoFocus?: boolean;
   extraClass?: string;
   onConfirm?: (value: string) => void;
+  placeholderStyle?: string;
 }
 let isInbox = false;
 const index = ({
   value,
   bgColor,
   extraClass,
-  extraStyle,
+  style,
   disabled,
   confirmType,
   prefix,
@@ -38,6 +39,7 @@ const index = ({
   maxlength,
   extra,
   onConfirm,
+  placeholderStyle,
 }: Props) => {
   const [focus, setFocus] = useState(false);
   const inputRef = useRef<HTMLInputElement>(null); // 创建一个 ref
@@ -68,22 +70,22 @@ const index = ({
   return (
     <View
       className={`${
-        focus ? style.inputContainerFocused : style.inputContainer
+        focus ? styleIndex.inputContainerFocused : styleIndex.inputContainer
       }  p-12`}
       style={bgColor ? { backgroundColor: bgColor } : {}}
     >
       {prefix && prefix()}
-      <View className={style.textareaContainer}>
+      <View className={styleIndex.textareaContainer}>
         <Textarea
           ref={inputRef}
           value={value}
           disabled={disabled}
           confirmType={confirmType}
-          style={extraStyle}
+          style={style}
           onInput={(e: any) => handleInput(e.target.value)}
           placeholder={placeholder}
-          placeholderStyle="rgba(0,0,0,.25)"
-          className={`${style.textInput} ${extraClass}`}
+          placeholderStyle={placeholderStyle ?? 'color: rgba(17,17,17,.25)'}
+          className={`${styleIndex.textInput} ${extraClass}`}
           onFocus={handleFocus}
           onBlur={handleBlur}
           autoHeight={autoHeight}
@@ -94,7 +96,7 @@ const index = ({
             onConfirm && onConfirm(e.detail.value);
           }}
         />
-        <View className={`${style.textareaButtons} justify-end gap-8`}>
+        <View className={`${styleIndex.textareaButtons} justify-end gap-8`}>
           {extra && extra()}
           {/* <View className={`button-rounded-mini ${!value.length ? 'disabled' :''}`} onClick={handleClear}>清除</View> */}
           {maxlength && (

BIN
src/images/icon-close-8.png


+ 0 - 3
src/images/icon-close-white.svg

@@ -1,3 +0,0 @@
-<svg width="8" height="8" viewBox="0 0 8 8" fill="none" xmlns="http://www.w3.org/2000/svg">
-<path fill-rule="evenodd" clip-rule="evenodd" d="M4.70786 3.99997L7.087 1.62083L6.37989 0.913727L4.00075 3.29287L1.62178 0.913898L0.914673 1.621L3.29364 3.99997L0.914673 6.37895L1.62178 7.08605L4.00075 4.70708L6.37989 7.08622L7.087 6.37912L4.70786 3.99997Z" fill="white"/>
-</svg>

+ 3 - 0
src/images/svgs/IconCloseThin.svg

@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" class="design-iconfont">
+  <path d="M8.8102902,8.02907919 L13.7877872,3.02745863 C14.0192987,2.79482512 14.0192987,2.44587484 13.7877872,2.21324133 C13.5562757,1.98060782 13.2090084,1.98060782 12.977497,2.21324133 L8,7.21486189 L3.02250304,2.17447514 C2.79099155,1.94184162 2.44372432,1.94184162 2.21221283,2.17447514 C1.98070135,2.40710865 1.98070135,2.75605892 2.21221283,2.98869244 L7.1897098,8.02907919 L2.17363361,13.0306997 C1.94212213,13.2633333 1.94212213,13.6122835 2.17363361,13.844917 C2.28938936,13.9612338 2.44372432,14 2.59805928,14 C2.75239424,14 2.90674729,13.9612338 3.02250304,13.844917 L8,8.84329649 L12.977497,13.844917 C13.0932527,13.9612338 13.2475877,14 13.4019407,14 C13.5562938,14 13.7106106,13.9612338 13.8263664,13.844917 C14.0578779,13.6122835 14.0578779,13.2633333 13.8263664,13.0306997 L8.8102902,8.02907919 Z" fill="#000" fill-rule="nonzero"/>
+</svg>

+ 3 - 2
src/pages/agent/components/AgentSetting/index.tsx

@@ -1,13 +1,14 @@
 import { View } from "@tarojs/components";
+import React, { useEffect, useState, forwardRef, useImperativeHandle, useRef } from "react";
 import AgentSettingList from './components/AgentSettingList'
 import AgentKnowledgeLib from './components/AgentKnowledgeLib'
 import AgentCard from './components/AgentCard'
 import AgentContactCard from './components/AgentContactCard'
 import BottomBar from "@/components/BottomBar";
+import WemetaButton from "@/components/buttons/WemetaButton";
+
 
-import React, { useEffect, useState, forwardRef, useImperativeHandle, useRef } from "react";
 
-import WemetaButton from "@/components/buttons/WemetaButton";
 import { useAgentStore } from "@/store/agentStore";
 
 

+ 9 - 1
src/pages/agent/index.tsx

@@ -23,7 +23,7 @@ export default function Index() {
 
   const headerHeight = useAppStore((state) => state.headerHeight);
   const agentEdit = useAgentStore((state) => state.agentEdit);
-  const { fetchAgent, saveAgent, createAgent, updateEditAgent } = useAgentStoreActions();
+  const { fetchAgent, saveAgent, createAgent, updateEditAgent, fetchDefaultNewAgentInfo } = useAgentStoreActions();
   const { fetchMyEntList } = useUserStore();
   const { setComponentList } = useComponentStore();
   const { confirmNavBack, confirmCreateAgent, confirmEditWebsite, confirmPersonalityAndGreeting, confirmSaveAvatar } = useConfirms();
@@ -91,6 +91,10 @@ export default function Index() {
           return;
         }
       }
+      if(!agentEdit?.voiceId){
+        console.log('创建智能体时请选择声音')
+        return
+      }
       const res = await createAgent()
       if(res){
         const goEditWebsite = await confirmEditWebsite()
@@ -126,6 +130,10 @@ export default function Index() {
 
   useEffect(()=> {
     fetchAgents()
+    if(!agentId){
+      fetchDefaultNewAgentInfo();
+    }
+    console.log(111)
   }, [])
 
   return (

+ 8 - 8
src/pages/chat/components/InputBar/TextInputBar.tsx

@@ -12,7 +12,7 @@ interface Props {
 export default ({disabled, onIconClick, onSend}:Props) => {
   const [value, setValue] = useState('')
   const {messageStopHandle} = useTextChat()
-  
+
   const handleInput = (value: string)=> {
     setValue(value)
   }
@@ -34,19 +34,19 @@ export default ({disabled, onIconClick, onSend}:Props) => {
     </View>
   }
   return <>
-    
-      <WemetaInput 
+
+      <WemetaInput
       	adjustPosition={false}
         disabled={disabled}
-        extraStyle={{'borderRadius': '10px'}}
+        style={{'borderRadius': '10px'}}
         confirmType="send"
-        suffix={iconButton} 
-        placeholder="有问题尽管问我..." 
-        value={value} 
+        suffix={iconButton}
+        placeholder="有问题尽管问我..."
+        value={value}
         cursorSpacing={400}
         onConfirm={handleConfirm}
         onInput={(value: any) => handleInput(value)}
         >
       </WemetaInput>
   </>
-}
+}

+ 21 - 0
src/pages/editor-contact/index.module.less

@@ -12,3 +12,24 @@
   color: #000;
   width:100%;
 }
+.icon{
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  width: 28px;
+  height: 28px;
+  border-radius: 100%;
+  background-color: var(--color-primary);
+}
+.qrcodeContainer{
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+  justify-content: center;
+  width: 168px;
+  height: 168px;
+  background: #FFFFFF;
+  border: 1px dashed rgba(#000, .1);
+  border-radius: 12px;
+  overflow: hidden;
+}

+ 79 - 20
src/pages/editor-contact/index.tsx

@@ -1,15 +1,16 @@
 import NavBarNormal from "@/components/NavBarNormal/index";
-import { View, Input, Text } from "@tarojs/components";
+import { View, Image, Text } from "@tarojs/components";
 import PageCustom from "@/components/page-custom/index";
 import WemetaInput from '@/components/wemeta-input/index'
+import WemetaTextarea from '@/components/wemeta-textarea/index'
 import Taro, { useRouter } from "@tarojs/taro";
 import { useAgentStore, useAgentStoreActions } from "@/store/agentStore";
-import { TAgentDetail } from "@/types/agent";
+import IconPlusBig from "@/components/icon/icon-plus-big";
 import { useState } from "react";
 import BottomBar from "@/components/BottomBar";
 import WemetaButton from "@/components/buttons/WemetaButton";
 import style from './index.module.less'
-
+import { pickAndUploadImageWithCrop } from "@/utils/upload";
 
 // const RenderEntCard = (
 //   agent: TAgentDetail | null,
@@ -80,11 +81,15 @@ import style from './index.module.less'
 export default function Index() {
   const router = useRouter();
   const agentEdit = useAgentStore((state) => state.agentEdit)
-  const { updateEditAgent } = useAgentStoreActions()
+  const { updateEditAgent, saveAgent } = useAgentStoreActions()
 
   const [disabled, setDisabled] = useState(false)
   const handleSave = ()=>{
-
+    console.log(agentEdit,111)
+    if(agentEdit?.agentId){
+      saveAgent()
+    }
+    Taro.navigateBack();
   }
 
   const handleFieldChange = (field: string, value: string) => {
@@ -95,6 +100,44 @@ export default function Index() {
     console.log(field, value)
     updateEditAgent({ [field]: value });
   };
+  const handleChooseAddress = () => {
+    Taro.chooseLocation({
+      success: (res) => {
+        console.log(res)
+        handleFieldChange('address', res.address)
+      },
+    })
+  };
+
+  const handleUpload = async () => {
+    Taro.showLoading();
+    try{
+      const result = await pickAndUploadImageWithCrop(["album"]);
+
+      Taro.hideLoading();
+      if (!result?.url) {
+        return;
+      }
+      handleFieldChange('qrCodeUrl', result.url)
+    }catch(e:any){
+      Taro.hideLoading();
+    }
+  }
+
+  const renderQrcode = () => {
+    if(agentEdit?.qrCodeUrl){
+      return <Image showMenuByLongpress className="w-full" src={agentEdit?.qrCodeUrl || ''} mode="widthFix"></Image>
+    }
+
+    return <View className="flex flex-col items-center justify-center" onClick={handleUpload}>
+        <View className={style.icon}>
+          <IconPlusBig></IconPlusBig>
+        </View>
+        <View className="pt-8 text-12 leading-22 text-primary">
+          上传微信二维码
+        </View>
+    </View>
+  }
 
   return (
     <PageCustom>
@@ -106,8 +149,8 @@ export default function Index() {
             <View className={style.value}>
               <WemetaInput
                 value={agentEdit?.name || ''}
-                onBlur={(e: any) => handleFieldChange('name', e.detail.value)}
-                onInput={(e: any) => handleFieldChange('name', e.detail.value)}
+                onBlur={(value) => handleFieldChange('name', value)}
+                onInput={(value) => handleFieldChange('name', value)}
                 placeholderStyle="color: rgba(17,17,17,.25)"
                 placeholder="输入姓名"
                 maxlength={40}
@@ -119,8 +162,8 @@ export default function Index() {
             <View className={style.value}>
               <WemetaInput
                 value={agentEdit?.position || ''}
-                onBlur={(e: any) => handleFieldChange('position', e.detail.value)}
-                onInput={(e: any) => handleFieldChange('position', e.detail.value)}
+                onBlur={(value) => handleFieldChange('position', value)}
+                onInput={(value) => handleFieldChange('position', value)}
                 placeholderStyle="color: rgba(17,17,17,.25)"
                 placeholder="输入职位名称"
               />
@@ -132,8 +175,8 @@ export default function Index() {
             <View className={style.value}>
               <WemetaInput
                 value={agentEdit?.entName || ''}
-                onBlur={(e: any) => handleFieldChange('entName', e.detail.value)}
-                onInput={(e: any) => handleFieldChange('entName', e.detail.value)}
+                onBlur={(value) => handleFieldChange('entName', value)}
+                onInput={(value) => handleFieldChange('entName', value)}
                 placeholderStyle="color: rgba(17,17,17,.25)"
                 placeholder="输入企业名称"
               />
@@ -144,8 +187,8 @@ export default function Index() {
             <View className={style.value}>
               <WemetaInput
                 value={agentEdit?.mobile || ''}
-                onBlur={(e: any) => handleFieldChange('mobile', e.detail.value)}
-                onInput={(e: any) => handleFieldChange('mobile', e.detail.value)}
+                onBlur={(value) => handleFieldChange('mobile', value)}
+                onInput={(value) => handleFieldChange('mobile', value)}
                 placeholderStyle="color: rgba(17,17,17,.25)"
                 placeholder="手机号"
               />
@@ -156,8 +199,8 @@ export default function Index() {
             <View className={style.value}>
               <WemetaInput
                 value={agentEdit?.email || ''}
-                onBlur={(e: any) => handleFieldChange('email', e.detail.value)}
-                onInput={(e: any) => handleFieldChange('email', e.detail.value)}
+                onBlur={(value) => handleFieldChange('email', value)}
+                onInput={(value) => handleFieldChange('email', value)}
                 placeholderStyle="color: rgba(17,17,17,.25)"
                 placeholder="联系邮箱"
               />
@@ -165,12 +208,16 @@ export default function Index() {
           </View>
           <View>
 
-            <View className={style.label}>地址</View>
+            <View className={style.label}>
+              <View className="flex-1 font-pingfangSCMedium font-medium">地址</View>
+              <View className="font-pingfangSCMedium font-medium text-primary" onClick={handleChooseAddress}>选择地址</View>
+            </View>
             <View className={style.value}>
-              <WemetaInput
+              <WemetaTextarea
                 value={agentEdit?.address || ''}
-                onBlur={(e: any) => handleFieldChange('address', e.detail.value)}
-                onInput={(e: any) => handleFieldChange('address', e.detail.value)}
+                style={{ height: '46px' }}
+                onBlur={(value) => handleFieldChange('address', value)}
+                onInput={(value) => handleFieldChange('address', value)}
                 placeholderStyle="color: rgba(17,17,17,.25)"
                 placeholder="地址"
               />
@@ -178,7 +225,19 @@ export default function Index() {
           </View>
           <View
           >
-            <View className={style.label}>二维码</View>
+            <View className={style.label}>
+              <View className="flex-1">二维码</View>
+              {agentEdit?.qrCodeUrl?.length && <View className="flex items-center font-pingfangSCMedium font-medium text-primary gap-16">
+                <View onClick={handleUpload}>替换</View>
+                <View>|</View>
+                <View onClick={() => handleFieldChange('qrCodeUrl', '')}>清空</View>
+              </View>}
+            </View>
+            <View>
+              <View className={style.qrcodeContainer}>
+                {renderQrcode()}
+              </View>
+            </View>
           </View>
         </View>
       </View>

+ 4 - 4
src/store/agentStore.ts

@@ -164,7 +164,7 @@ export const useAgentStore = create<AgentStoreState>((set, get) => ({
           ...agentEdit,
           ...agentFields,
         };
-        console.log(mixedAgent,3333333)
+
         const cleanAgent = {
           ...mixedAgent,
           address: mixedAgent.address ?? undefined,
@@ -328,9 +328,9 @@ export const useAgentStore = create<AgentStoreState>((set, get) => ({
     fetchDefaultNewAgentInfo: async () => {
       const response = await getNewAgentInfo()
       if (isSuccess(response.status)) {
-        // set({
-        //   agentEdit: response.data,
-        // });
+        set({
+          agentEdit: response.data,
+        });
       }
       return response.data
     },