فهرست منبع

Merge branch 'dev' of http://124.70.149.18:10880/lianghj/queenshow into dev

liwei 1 سال پیش
والد
کامیت
55d0e05c1c

+ 18 - 4
src/controllers/wxController.ts

@@ -34,7 +34,11 @@ export class wxController {
     timestamp: 0, // 必填,生成签名的时间戳
     nonceStr: "", // 必填,生成签名的随机串
     signature: "", // 必填,签名
-    jsApiList: ["updateAppMessageShareData", "updateTimelineShareData"], // 必填,需要使用的JS接口列表
+    jsApiList: [
+      "updateAppMessageShareData",
+      "updateTimelineShareData",
+      "previewImage",
+    ], // 必填,需要使用的JS接口列表
   };
 
   //默认分享设置
@@ -45,10 +49,12 @@ export class wxController {
     desc: "",
   };
 
-  init(url: string) {
+  constructor(options: { url: string }) {
+    this.requestUrl = options.url;
+  }
+
+  setup(signUrl: string) {
     if (isWeixinBrowser()) {
-      this.requestUrl = url;
-      let signUrl = window.location.href;
       if (isIos()) {
         signUrl = signUrl.split("#")[0];
       }
@@ -142,4 +148,12 @@ export class wxController {
       },
     });
   }
+
+  setPreviewData(url: string, urls: string[]) {
+    if (!this.signSuccess) return;
+    wx.previewImage({
+      current: url, // 当前显示图片的http链接
+      urls: urls, // 需要预览的图片http链接列表
+    });
+  }
 }

+ 2 - 0
src/modules/editor/components/CompUI/basicUI/Image2/component.tsx

@@ -58,6 +58,8 @@ export const Component = defineComponent({
           onClick={() => {
             if (value.showLink && value.link && !store.isEditMode) {
               window.location.href = value.link;
+            } else {
+              controls.wxCtrl.setPreviewData(value.url, store.previewImageList);
             }
           }}
         >

+ 10 - 1
src/modules/editor/module/index.ts

@@ -17,6 +17,7 @@ import { DragAddCtrl } from "../controllers/DragAddCtrl";
 import { SelectCtrl } from "../controllers/SelectCtrl";
 import { CompObject } from "../controllers/SelectCtrl/compObj";
 import { manualActions } from "./actions/editWithManualHistory";
+import { wxController } from "@/controllers/wxController";
 
 export class EditorModule extends ModuleRoot {
   config = this.setConfig({
@@ -26,7 +27,12 @@ export class EditorModule extends ModuleRoot {
   });
   components = this.useComponents(components);
 
-  actions = this.createActions([initActions, editActions, ImgCompActions, manualActions]);
+  actions = this.createActions([
+    initActions,
+    editActions,
+    ImgCompActions,
+    manualActions,
+  ]);
   https = this.createHttps(https);
   store = this.createStore(store, {
     transform: (state) => createProxy(state),
@@ -40,6 +46,9 @@ export class EditorModule extends ModuleRoot {
       },
       dir: "queenshow",
     }),
+    wxCtrl: new wxController({
+      url: `${Dict_Apis.promotion}/wechat/share?`,
+    }),
     transferCtrl: new TransferCtrl(this),
     dragAddCtrl: new DragAddCtrl(this),
     streamCardTransferCtrl: new TransferCtrl(this),

+ 13 - 6
src/modules/editor/module/stores/index.ts

@@ -15,10 +15,8 @@ export const store = EditorModule.store({
     groupIds: [] as string[],
     compPids: {} as Record<string, string>,
 
-  
-
     selected: [] as string[], //选中的组件
-    selectId: "",    //选中的id唯一标识一次选中
+    selectId: "", //选中的id唯一标识一次选中
   }),
   getters: {
     isEditMode(): boolean {
@@ -49,6 +47,15 @@ export const store = EditorModule.store({
     streamCardIds(state): string[] {
       return state.designData.compMap.root?.children.default || [];
     },
+    previewImageList(state) {
+      const res: string[] = [];
+      Object.values(state.designData.compMap)
+        .filter((d) => d.compKey == "Image")
+        .forEach((value) => {
+          res.push(value.value?.url);
+        });
+      return res;
+    },
   },
   actions: {
     setCompData(id: string, data: any) {
@@ -90,9 +97,9 @@ export const store = EditorModule.store({
       const comps = this.helper.getCompTrees(compId);
 
       if (compId == "root") {
-          return;
+        return;
       }
-      this.store.currStreamCardId = comps[1]?.id || ''
+      this.store.currStreamCardId = comps[1]?.id || "";
     },
 
     deleteComp(compId: string) {
@@ -122,7 +129,7 @@ export const store = EditorModule.store({
       }
     },
     moveComp(selIndex: number, targetIndex: number) {
-      const pageCompIds = [...this.store.pageCompIds]
+      const pageCompIds = [...this.store.pageCompIds];
       const [selComp] = pageCompIds.splice(selIndex, 1);
       pageCompIds.splice(targetIndex, 0, selComp);
       this.store.designData.compMap.root.children.default = pageCompIds;

+ 3 - 8
src/pages/share/Promotion/index.tsx

@@ -1,5 +1,3 @@
-import { wxController } from "@/controllers/wxController";
-import { Dict_Apis } from "@/dict";
 import { initEditor } from "@/modules/editor";
 import { defineComponent } from "vue";
 
@@ -8,14 +6,11 @@ export default defineComponent(() => {
   const params = new URLSearchParams(location.href.split("?")[1]);
   const id = params.get("id");
 
-  const wxSdk = new wxController();
-  const url = `${Dict_Apis.promotion}/wechat/share?`;
-  wxSdk.init(url);
-
   editor.actions.switchMode("preview");
 
   if (id) {
     editor.actions.initDesign(id);
+    editor.controls.wxCtrl.setup(window.location.href);
 
     editor.actions.on("initDesign:success", () => {
       const data = editor.store.designData;
@@ -26,8 +21,8 @@ export default defineComponent(() => {
         imgUrl: data.thumbnail || "",
         desc: data.desc,
       };
-      wxSdk.setShareData(shareData);
-      wxSdk.setShare(shareData);
+      editor.controls.wxCtrl.setShareData(shareData);
+      editor.controls.wxCtrl.setShare(shareData);
     });
   }