shenwu 6 kuukautta sitten
vanhempi
commit
80e538f8a1

+ 0 - 11
src/pages/MiniApp/AdBack/configModal.tsx

@@ -1,11 +0,0 @@
-import { Button } from "antd"
-import { useState } from "react"
-
-function ConfigModal() {
-    let [open, setOpen] = useState<boolean>(false)
-    return <div>
-        <Button type="primary">编辑</Button>
-        
-    </div>
-}
-export default ConfigModal

+ 2 - 1
src/pages/MiniApp/AdBack/formConfig.tsx

@@ -234,7 +234,8 @@ function formConfig(): ProFormColumnsType<{
                                                             preserve: true,
                                                             hideInForm: backType !== 1,
                                                             convertValue: (value) => {
-                                                                let v: any = typeof value === "number" ? value : 0
+                                                                console.log(value)
+                                                                let v: any = String(value).includes(":") || !value ? 0 : Number(value)
                                                                 return v
                                                             },
                                                             formItemProps: {

+ 101 - 45
src/pages/MiniApp/AdBack/index.tsx

@@ -1,6 +1,6 @@
 import { useAjax } from "@/Hook/useAjax"
-import { getAppAccountConfig, tencentAdAccountDoAuth, tencentAdAccountToAuth } from "@/services/miniApp/adBack"
-import { BetaSchemaForm, PageContainer, ProCard, ProForm, ProFormRadio, ProFormSelect, ProFormText } from "@ant-design/pro-components"
+import { appAccountConfig, getAppAccountConfig, tencentAdAccountDoAuth, tencentAdAccountToAuth } from "@/services/miniApp/adBack"
+import { BetaSchemaForm, PageContainer, ProCard, ProForm, ProFormInstance, ProFormRadio, ProFormSelect, ProFormText } from "@ant-design/pro-components"
 import { history, useModel } from "@umijs/max"
 import { Button, Divider, message, Space } from "antd"
 import { useEffect, useRef, useState } from "react"
@@ -12,10 +12,12 @@ function Auth() {
     let { initialState } = useModel("@@initialState")
     let [key, setKey] = useState<any>()
     let [isEdit, setIsEdit] = useState(false)
-    let formRef = useRef()
+    const [readonly, setReadonly] = useState(false);
+    const formRef = useRef<ProFormInstance>();
     let TencentAdAccountToAuth = useAjax((params) => tencentAdAccountToAuth(params))//获取授权地址
     let TencentAdAccountDoAuth = useAjax((params) => tencentAdAccountDoAuth(params))//开始授权
     let GetAppAccountConfig = useAjax((params) => getAppAccountConfig(params))//获取回传配置
+    let AppAccountConfig = useAjax((params) => appAccountConfig(params))//设置配置
     // 获取广告回传列表
     useEffect(() => {
         // 授权回调
@@ -64,8 +66,46 @@ function Auth() {
                 return item;
             });
         }
+        if (values.otherBackRate) {
+            values.otherBackRate = values.otherBackRate.map((item: any) => {
+                if (Array.isArray(item.backRate)) {
+                    item.backRate = item.backRate.join(":"); // 转换数组为 'min:max' 字符串
+                }
+                return item;
+            });
+        }
+        if (values.markUpBackRate) {
+            values.markUpBackRate = values.markUpBackRate.map((item: any) => {
+                if (Array.isArray(item.backRate)) {
+                    item.backRate = item.backRate.join(":"); // 转换数组为 'min:max' 字符串
+                }
+                return item;
+            });
+        }
         // 打印转换后的数据
         console.log("处理后的表单数据: ", values);
+        AppAccountConfig.run({
+            appType: initialState?.selectApp?.appType,
+            appId: initialState?.selectApp?.id,
+            advertisingChannel: key,
+            policyType: 1,
+            policyContentOfDefault: values
+        }).then(res => {
+            if (res.code === 200) {
+                message.success("配置成功!")
+                GetAppAccountConfig.refresh()
+                setIsEdit(false)
+            }
+        })
+    }
+    // lock or edit
+    const edit = () => {
+        setIsEdit(true)
+        if (GetAppAccountConfig?.data?.data[key]?.distributorAppAdBackPolicy?.policyContentOfDefault) {
+            setTimeout(() => {
+                formRef?.current?.setFieldsValue(GetAppAccountConfig?.data?.data[key]?.distributorAppAdBackPolicy?.policyContentOfDefault)
+            }, 100)
+        }
     }
     return <PageContainer
         tabList={getEnum("ADVERTISING_CHANNEL", "arr")?.map((item: { label: any; key: any }, index: number) => {
@@ -80,61 +120,71 @@ function Auth() {
             onChange: (e) => setKey(e),
         }}
     >
-        <ProCard direction="column" ghost gutter={8} >
+        <ProCard direction="column" ghost gutter={8} loading={GetAppAccountConfig?.loading} >
             <ProCard
                 bordered
                 title="归因设置"
                 actions={
-                    <Space style={{ margin: 20 }}> <Button type="primary" onClick={auth}>授权</Button></Space>
+                    !GetAppAccountConfig?.data?.data[key]?.tencentAdAccount && <Space style={{ margin: 20 }}> <Button type="primary" onClick={auth}>授权</Button></Space>
                 }
             >
-                <ProForm
-                    readonly={true}
-                    submitter={false}
-                    colProps={{ span: 2 }}
-                    labelCol={{ span: 1 }}
-                    layout="horizontal"
-                >
-                    {/* 数据源ID */}
-                    <ProFormText label={"归因方式"} formItemProps={{ style: { marginBottom: 10 } }} />
-                    <ProFormText label={"数据源类型"} formItemProps={{ style: { marginBottom: 10 } }} />
-                    <ProFormText label={"数据源ID"} formItemProps={{ style: { marginBottom: 10 } }} />
-                    {/* accountId */}
-                    <ProFormText label={"已授权账号ID"} formItemProps={{ style: { marginBottom: 10 } }} />
-                </ProForm>
-
+                <div>
+                    <div style={{ marginBottom: 5 }}>
+                        <span style={{ width: 100, display: 'inline-block', textAlign: 'right' }}>归因方式:</span>
+                        <span style={{ color: "#999" }}>数据源ID</span>
+                    </div>
+                    <div style={{ marginBottom: 5 }}>
+                        <span style={{ width: 100, display: 'inline-block', textAlign: 'right' }}>数据源类型:</span>
+                        <span style={{ color: "#999" }}>{getEnum("TENCENT_USER_ACTION_TYPE", 'map').get(GetAppAccountConfig?.data?.data[key]?.tencentAdAccount?.userActionSets?.type) || "-"}</span>
+                    </div>
+                    <div style={{ marginBottom: 5 }}>
+                        <span style={{ width: 100, display: 'inline-block', textAlign: 'right' }}>数据源ID:</span>
+                        <span style={{ color: "#999" }}>{GetAppAccountConfig?.data?.data[key]?.tencentAdAccount?.userActionSets?.userActionSetId || "-"}</span>
+                    </div>
+                    <div style={{ marginBottom: 5 }}>
+                        <span style={{ width: 100, display: 'inline-block', textAlign: 'right' }}>已授权账号ID:</span>
+                        <span style={{ color: "#999" }}> {GetAppAccountConfig?.data?.data[key]?.tencentAdAccount?.userActionSets?.accountId || "-"}</span>
+                    </div>
+                    {GetAppAccountConfig?.data?.data[key]?.tencentAdAccount && <div style={{ marginBottom: 5 }}>
+                        <span style={{ width: 100, display: 'inline-block', textAlign: 'right' }}>授权:</span>
+                        <span style={{ color: "#999" }}> <Button type="primary" onClick={auth} size="small" danger>更换授权</Button></span>
+                    </div>}
+                </div>
             </ProCard>
             <ProCard
                 bordered
                 title="回传设置"
                 tooltip="回传“下单”“付费”两个行为事件,直投小程序链路额外支持“注册”(纯新+染色回流用户进入小程序)事件回传。"
                 actions={<Space style={{ margin: 20 }}>
-                    {
-                        !isEdit ? <>
-                            <Button type="primary" onClick={() => { setIsEdit(true) }}>编辑</Button>
-                            <Button>取消回传</Button>
-                        </> : <>
-                            <Button type="primary" onClick={() => { setIsEdit(true) }}>保存</Button>
-                            <Button onClick={() => { setIsEdit(false) }}>取消</Button>
-                        </>
-                    }
+                    <Button type="primary" onClick={edit}>编辑</Button>
                 </Space>}
             >
-                <ProForm
-                    readonly={true}
-                    formRef={formRef}
-                    submitter={false}
-                    colProps={{ span: 2 }}
-                    labelCol={{ span: 2 }}
-                    layout="horizontal"
-                >
-                    {/*  注册充值回传的最大间隔时间,回传类型,VIP回传策略,是否补单,单用户最大回传订单数,详情弹窗*/}
-                    <ProFormText label={"注册充值回传的最大间隔时间"} formItemProps={{ style: { marginBottom: 10 } }} />
-                    <ProFormRadio.Group label={"单用户最大回传订单数"} formItemProps={{ style: { marginBottom: 10 } }} />
-                    <ProFormRadio.Group label={"回传类型"} formItemProps={{ style: { marginBottom: 10 } }} />
-                    <ProFormSelect label={"VIP回传策略"} formItemProps={{ style: { marginBottom: 10 } }} />
-                    <ProFormRadio.Group label={"是否补单"} formItemProps={{ style: { marginBottom: 10 } }} />
-                </ProForm>
+                <div>
+                    <div style={{ marginBottom: 5 }}>
+                        <span style={{ width: 200, display: 'inline-block', textAlign: 'right' }}>回传类型:</span>
+                        <span style={{ color: "#999" }}> {getEnum("CALLBACK_TYPE", "map")?.get(GetAppAccountConfig?.data?.data[key]?.distributorAppAdBackPolicy?.policyContentOfDefault?.backUnit) || "-"}</span>
+                    </div>
+                    <div style={{ marginBottom: 5 }}>
+                        <span style={{ width: 200, display: 'inline-block', textAlign: 'right' }}>VIP回传策略:</span>
+                        <span style={{ color: "#999" }}>{getEnum("VIP_CALLBACK", "map")?.get(GetAppAccountConfig?.data?.data[key]?.distributorAppAdBackPolicy?.policyContentOfDefault?.vipOrderBackType) || "-"}</span>
+                    </div>
+                    <div style={{ marginBottom: 5 }}>
+                        <span style={{ width: 200, display: 'inline-block', textAlign: 'right' }}>是否补单:</span>
+                        <span style={{ color: "#999" }}>{new Map([true, false].map(key => [key, key ? "是" : "否"])).get(GetAppAccountConfig?.data?.data[key]?.distributorAppAdBackPolicy?.policyContentOfDefault?.markUpOrder) || "-"}</span>
+                    </div>
+                    <div style={{ marginBottom: 5 }}>
+                        <span style={{ width: 200, display: 'inline-block', textAlign: 'right' }}>单用户最大回传订单数:</span>
+                        <span style={{ color: "#999" }}>     {GetAppAccountConfig?.data?.data[key]?.distributorAppAdBackPolicy?.policyContentOfDefault?.maxBackCountOfUser || "-"}</span>
+                    </div>
+                    <div style={{ marginBottom: 5 }}>
+                        <span style={{ width: 200, display: 'inline-block', textAlign: 'right' }}>注册充值回传的最大间隔时间:</span>
+                        <span style={{ color: "#999" }}>     {GetAppAccountConfig?.data?.data[key]?.distributorAppAdBackPolicy?.policyContentOfDefault?.regPayIntervalTime ? GetAppAccountConfig?.data?.data[key]?.distributorAppAdBackPolicy?.policyContentOfDefault?.regPayIntervalTime + "分钟" : "-"}</span>
+                    </div>
+                    {GetAppAccountConfig?.data?.data[key]?.distributorAppAdBackPolicy?.policyContentOfDefault && <div style={{ marginBottom: 5 }}>
+                        <span style={{ width: 200, display: 'inline-block', textAlign: 'right' }}>更多内容:</span>
+                        <span style={{ color: "#999" }}><Button size='small' type='link' onClick={() => { setReadonly(true); edit() }}>查看</Button></span>
+                    </div>}
+                </div>
             </ProCard>
         </ProCard>
         {/* 回传配置 */}
@@ -142,7 +192,12 @@ function Auth() {
             title={"回传策略配置"}
             formRef={formRef}
             open={isEdit}
-            onOpenChange={(b) => { !b && setIsEdit(b) }}
+            onOpenChange={(b) => {
+                if (!b) {
+                    setIsEdit(b)
+                    setReadonly(false)
+                }
+            }}
             layoutType={"ModalForm"}
             labelCol={{ span: 24 }}
             colProps={{ span: 8 }}
@@ -150,6 +205,7 @@ function Auth() {
             layout="vertical"
             onFinish={submit}
             columns={formConfig()}
+            submitter={readonly ? false : { render: (props, dom) => [...dom] }}
             modalProps={{
                 destroyOnClose: true
             }}

+ 8 - 1
src/services/miniApp/adBack/index.ts

@@ -26,9 +26,16 @@ export async function tencentAdAccountDoAuth(data: DoAuthData) {
         data
     });
 }
-/**广告账号授权*/
+/**应用账号广告及回传配置信息*/
 export async function getAppAccountConfig({ appType, appId }: any) {
     return request(api + `/admin/tencentAdAccount/getAppAccountConfig/${appType}/${appId}`, {
         method: 'GET',
     });
+}
+/**应用账号广告及回传配置信息*/
+export async function appAccountConfig(data:any) {
+    return request(api + `/admin/tencentAdAccount/appAccountConfig`, {
+        method: 'PUT',
+        data
+    });
 }