qinyan 1 year ago
parent
commit
427a29b518

+ 18 - 9
src/pages/website/Promotion2/components/PromotionItem.tsx

@@ -5,7 +5,7 @@ import { Divider, Dropdown, Menu, Tag } from "ant-design-vue";
 import { EyeOutlined } from "@ant-design/icons-vue";
 import dayjs from "dayjs";
 import { defineUI } from "queenjs";
-import { any } from "vue-types";
+import { any, bool } from "vue-types";
 import { useAuth } from "@queenjs-modules/auth";
 
 // const ShareBox = defineComponent({
@@ -38,13 +38,14 @@ import { useAuth } from "@queenjs-modules/auth";
 export default defineUI({
   props: {
     record: any(),
+    isPc: bool().def(false),
   },
   emits: ["edit", "preview", "menu"],
   setup(props, { emit }) {
     const auth = useAuth();
 
     return () => {
-      const { record } = props;
+      const { record, isPc } = props;
 
       //@ts-ignore
       const isSys = (auth.store.userInfo.roles || []).indexOf("system") > -1;
@@ -73,13 +74,21 @@ export default defineUI({
                 编辑
               </div>
 
-              <div
-                class="text-white icon_action w-60px leading-60px ml-10px cursor-pointer rounded-1/2 text-center transition-opacity hover:opacity-90 active:opacity-80"
-                onClick={() => emit("menu", "share")}
-              >
-                {/* 预览 */}
-                分享
-              </div>
+              {isPc ? (
+                <div
+                  class="text-white icon_action w-60px leading-60px ml-10px cursor-pointer rounded-1/2 text-center transition-opacity hover:opacity-90 active:opacity-80"
+                  onClick={() => emit("menu", "copyLink")}
+                >
+                  链接
+                </div>
+              ) : (
+                <div
+                  class="text-white icon_action w-60px leading-60px ml-10px cursor-pointer rounded-1/2 text-center transition-opacity hover:opacity-90 active:opacity-80"
+                  onClick={() => emit("menu", "share")}
+                >
+                  分享
+                </div>
+              )}
             </div>
           </View>
           <div class="item_footer rounded-b-4px flex items-center justify-between p-15px">

+ 43 - 13
src/pages/website/Promotion2/components/index.tsx

@@ -1,18 +1,18 @@
 import List from "@/components/AssetsList";
+import { useResource } from "@/modules/resource";
 import { PromotionController } from "@/modules/resource/controllers/PromotionController";
+import { useAuth } from "@queenjs-modules/auth";
 import { defineUI } from "queenjs";
-import { onMounted } from "vue";
+import { computed, onMounted, reactive } from "vue";
 import { any } from "vue-types";
-import Header from "./Header";
 import Filter from "./CategoryFilter";
+import Header from "./Header";
 import PromotionItem from "./PromotionItem";
-import { useAuth } from "@queenjs-modules/auth";
 
 export default defineUI({
   props: {
     Controller: any<PromotionController>().isRequired,
   },
-
   slots: {
     Header,
     Filter,
@@ -20,6 +20,23 @@ export default defineUI({
   },
   setup(props, { slots }) {
     const auth = useAuth();
+    const resource = useResource();
+
+    const state = reactive({
+      categoryList: computed(() => {
+        const categories = resource.controls.categoryCtrl.state.categories;
+        const currCate: any = categories.find((e: any) => {
+          return e.value == "template";
+        });
+        if (!currCate) return [];
+        const r = currCate.children.find((e: any) => e.name == "平台");
+        return r?.children || [];
+      }),
+      pcCategoryId: computed(() => {
+        const item: any = state.categoryList.find((e: any) => e.value == "PC");
+        return item.id;
+      }),
+    });
 
     const FilterChange = (query: any) => {
       const ctrlQuery = props.Controller.ListCtrl.state.query || {};
@@ -29,6 +46,14 @@ export default defineUI({
       };
       props.Controller.ListCtrl.loadPage(1);
     };
+
+    function isPcDesign(record: any) {
+      let res = false;
+      const categories: any[] = record.categories || [];
+      if (categories.includes(state.pcCategoryId)) res = true;
+      return res;
+    }
+
     onMounted(() => {
       props.Controller.ListCtrl.state.query = {};
       props.Controller.ListCtrl.loadPage(1);
@@ -37,6 +62,7 @@ export default defineUI({
     return () => {
       //@ts-ignore
       const isSys = (auth.store.userInfo.roles || []).indexOf("system") > -1;
+
       return (
         <div>
           <slots.Header onAdd={props.Controller.createPromotion} />
@@ -50,15 +76,19 @@ export default defineUI({
             class="my-30px"
             columns={5}
             control={props.Controller.ListCtrl}
-            item={(record: any) => (
-              <PromotionItem
-                record={record}
-                onMenu={(name) => {
-                  props.Controller.onMenuClick(name, record, isSys);
-                }}
-                onEdit={(record) => props.Controller.onEdit(record)}
-              />
-            )}
+            item={(record: any) => {
+              const isPc = isPcDesign(record);
+              return (
+                <PromotionItem
+                  isPc={isPc}
+                  record={record}
+                  onMenu={(name) => {
+                    props.Controller.onMenuClick(name, record, isSys);
+                  }}
+                  onEdit={(record) => props.Controller.onEdit(record)}
+                />
+              );
+            }}
           />
         </div>
       );

+ 6 - 0
src/pages/website/Promotion2/controller.tsx

@@ -7,6 +7,7 @@ import ShareModal from "./components/ShareModal";
 import { sendPromotion } from "./components/SendPromotion";
 import { AuthModule } from "@queenjs-modules/auth";
 import { SelectOneImage } from "../Material2/modal";
+import { clipboard } from "@/utils";
 
 export function createPromotinController(
   auth: AuthModule,
@@ -45,7 +46,12 @@ export function createPromotinController(
   }
   let url = "";
   ctrl.onMenuClick = async (name, record, isSys) => {
+    const shareLink =
+      location.origin + "/share.html?id=" + record._id + "&isSys=" + isSys;
     switch (name) {
+      case "copyLink":
+        clipboard.copy(shareLink);
+        break;
       case "stat":
         window.open("https://show.3dqueen.cloud/stat/#/count?id=" + record._id);
         break;