liwei hai 1 ano
pai
achega
4cc5a4f7c7

BIN=BIN
src/assets/comps/card/thumbnail.png


BIN=BIN
src/assets/comps/cardList/2.png


BIN=BIN
src/assets/comps/cover/1.png


+ 2 - 2
src/dict/apis.ts

@@ -14,8 +14,8 @@ const Dict_Apis = {
   queentreeLocal: base,
   auth: `${baseURL}${baseVersion}/usercenter`,
   queentree: `${baseURL}${treeVersion}/assetcenter`,
-  promotion: `${baseURL}${baseVersion}/promotion`,
-  // promotion: `${localURL}/promotion`,
+  // promotion: `${baseURL}${baseVersion}/promotion`,
+  promotion: `${localURL}/promotion`,
 };
 
 export { Dict_Apis };

+ 4 - 4
src/modules/editor/components/CompUI/customUI/Cards/Card/component.tsx

@@ -10,8 +10,8 @@ export const Component = createUIComp({
   },
   setup(props) {
     const { designToNaturalSize } = useEditor().helper;
-    const { value } = useCompData(props.compId);
-
+    const { value , children} = useCompData(props.compId);
+  
     return () => (
       <div class="flex">
         <Image.Component
@@ -19,9 +19,9 @@ export const Component = createUIComp({
             width: designToNaturalSize(value.imgSize[0]),
             height: designToNaturalSize(value.imgSize[1]),
           }}
-          v-model={[value.img, "value"]}
+          compId={children.img}
         />
-        <Text.Component class="flex-1 ml-0.1rem" v-model={[value.desc, "value"]} />
+        <Text.Component class="flex-1 ml-0.1rem" compId={children.desc} />
       </div>
     );
   },

+ 8 - 3
src/modules/editor/components/CompUI/customUI/Cards/Card/index.tsx

@@ -2,20 +2,25 @@ import { Dict_Imgs } from "@/dict";
 import { createAttrsForm } from "../../../defines/createAttrsForm";
 import { createCompHooks } from "../../../defines/createCompHooks";
 import { GroupNumber } from "../../../formItems/GroupNumber";
+import { createCompId } from "../../../defines/createCompId";
 
 export { Component } from "./component";
 
+const thumb = require("@/assets/comps/card/thumbnail.png");
+
 export const options = {
   name: "卡片",
-  thumbnail: Dict_Imgs.Default,
+  thumbnail: thumb,
 };
 
 export const { createComp, useCompData } = createCompHooks({
   value: {
-    img: { url: Dict_Imgs.Default },
     imgSize: [240, 240],
-    desc: "描述",
   },
+  children: {
+     img: ()=>createCompId("Image", {value: {url:thumb, x: 25.50, y: 7.00, s: 3.80}}),
+     desc: ()=>createCompId("Text", {value: `<p><span style="font-size:16px;">名称 &nbsp; p190 (注塑)</span></p><p><span style="font-size:16px;">规格 &nbsp; 52英寸</span></p><p><span style="font-size:16px;">厚度 &nbsp;1.0mm+0.05mm</span></p><p><span style="font-size:16px;">底材 &nbsp;鹿皮绒</span></p><p><span style="font-size:16px;">用途 &nbsp;凉鞋、跟鞋、高更鞋、</span><br><span style="font-size:16px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 时尚休闲鞋等</span></p>`})
+  }
 });
 
 export const Form = createAttrsForm([

+ 26 - 13
src/modules/editor/components/CompUI/customUI/Cards/CardList/index.tsx

@@ -6,9 +6,10 @@ import { createCompId } from "../../../defines/createCompId";
 
 export { Component } from "./component";
 
+const thumb  = require("@/assets/comps/cardList/thumnail.png")
 export const options = {
   name: "卡片列表",
-  thumbnail: Dict_Imgs.Default,
+  thumbnail: thumb,
 };
 
 export const { createComp, useCompData, useCreateChild } = createCompHooks({
@@ -16,21 +17,33 @@ export const { createComp, useCompData, useCreateChild } = createCompHooks({
     gap: 10,
     columns: 3,
     total: 3,
-    imgHeight: 120,
+    imgHeight: 300,
     showDesc: true,
   },
   children: {
-    list: (length = 3) =>
-      Array.from({ length }, () => ({
-        img: createCompId("Image", {
-          value: {
-            url: Dict_Imgs.Default,
-          },
-        }),
-        desc: createCompId("Text", {
-          value: "描述",
-        }),
-      })),
+    list: (defaultOpts:any, length = 3)=> {
+      let i = 0;
+      return Array.from({ length }, () => {
+        const offsets = [{x:32.50, y:3.00, s:3.60}, {x:0.50, y: 3.00, s: 3.50}, {x:-32.00, y:2.50, s:3.55}]
+        let offset = {x: 0, y: 0, s:1}
+        if (defaultOpts.value.columns == 3) {
+            offset = offsets[i%3]
+        }
+        i = i + 1;
+        return {
+          img: createCompId("Image", {
+            value: {
+              url: thumb,
+              ...offset
+            },
+          }),
+          desc: createCompId("Text", {
+            value: `<p style="text-align:center;">这是一个小标题</p>`,
+          }),
+        };
+      });
+    },
+
     img1: () =>
       createCompId("Image", {
         value: {

+ 1 - 1
src/modules/editor/components/CompUI/customUI/Covers/Cover/index.ts

@@ -7,7 +7,7 @@ export { Component } from "./component";
 
 export const options = {
   name: "封面",
-  thumbnail: Dict_Imgs.Default,
+  thumbnail: require("@/assets/comps/cover/1.png"),
 };
 
 export const { createComp, useCompData } = createCompHooks({

+ 6 - 4
src/modules/editor/components/CompUI/defines/createCompHooks.ts

@@ -1,7 +1,7 @@
 import { useEditor } from "@/modules/editor";
 import { DesignComp } from "@/modules/editor/defines/DesignTemp/DesignComp";
 import { Background, Layout } from "@/modules/editor/typings";
-import { cloneDeep } from "lodash";
+import { cloneDeep, defaultsDeep } from "lodash";
 import { AnyFun } from "queenjs/typing";
 import { addCacheToMap } from "./createCompId";
 
@@ -15,14 +15,16 @@ type IOptions<T, C> = {
 export function createCompHooks<T, C extends { [name: string]: AnyFun }>(
   defaultOpts: IOptions<T, C>
 ) {
+
   function createComp(opts: any) {
     const defData: any = cloneDeep(defaultOpts);
     if (defData.children) {
       Object.entries(defData.children).forEach(([key, fn]: any) => {
-        defData.children[key] = fn();
+        defData.children[key] = fn(defData);
       });
     }
-    const options = Object.assign(defData, opts);
+    const options = defaultsDeep(opts, defData)
+
     return new DesignComp(options);
   }
 
@@ -38,7 +40,7 @@ export function createCompHooks<T, C extends { [name: string]: AnyFun }>(
   function useCreateChild<T extends keyof C>(key: T) {
     const editor = useEditor();
     const createChild: any = (...args: any) => {
-      const result = (defaultOpts as any).children[key](...args);
+      const result = (defaultOpts as any).children[key](defaultOpts, ...args);
       addCacheToMap(editor.store.designData.compMap);
       return result;
     };