2 Revize 21f527c1c6 ... 9ba0a0b8bd

Autor SHA1 Zpráva Datum
  xiebaomin 9ba0a0b8bd updated před 1 rokem
  xiebaomin b190a16b81 updated před 1 rokem

+ 2 - 2
.env.development

@@ -1,6 +1,6 @@
 VITE_ENV = 'development'
 
-VITE_BASE_URL = 'https://core.caimei365.com'
+VITE_BASE_URL = 'https://core-b.caimei365.com'
 
 VITE_BASE_HTTP = 'https://material-b.caimei365.com'
 
@@ -8,4 +8,4 @@ VITE_BASE_OSS = 'https://caimei-oss.oss-cn-shenzhen.aliyuncs.com/beta/archiveFil
 
 VITE_IMAGE_URL = 'https://static.caimei365.com/'
 
-VITE_HTTP_URL = 'https://www.caimei365.com'
+VITE_HTTP_URL = 'http://120.79.25.27:8009'

+ 4 - 4
src/types/api/context.type.ts

@@ -120,11 +120,11 @@ export type IShareConfig = {
 
 export type IStatistics = {
 	accessDuration: number
-	pageType?: '67' | string
-	pageLabel?: '内容库文件预览' | string
+	pageType: '67' | string
+	pageLabel: '内容库文件预览' | string
 	pagePath: string
-	headUserId?: string
-	productArchiveId?: string
+	headUserId: string
+	productArchiveId: string
 	accessClient: '0' | '1'
 	userId: string
 	productId: string

+ 1 - 5
src/views/Database/components/context-share.vue

@@ -24,8 +24,6 @@
 import { DArchiveResultData } from "@/types/api/context.type";
 import { DFindParams, DScrollTab, tabList } from "@/types/views/database.type";
 import { computed } from "vue";
-import { useRouter } from "vue-router";
-//import useCopyText from "@/Hooks/useCopyText";
 import useWeChatShare from "@/Hooks/useWeChatShare";
 import { useUserInfoState } from "@/store/user/user";
 import getFileImg from "@/Hooks/useFileImage";
@@ -33,7 +31,6 @@ import useCopyText from '@/Hooks/useCopyText';
 
 const props = defineProps<DArchiveResultData>();
 const { serviceProviderId, userId } = useUserInfoState();
-const router = useRouter();
 
 const imageLink = computed<string>(() => {
   if (props.type !== "3") return props.image as string;
@@ -50,8 +47,7 @@ const handleDetail = ($event: DArchiveResultData) => {
     (Number($event.type) === 6 ? "-1.html" : ".html");
   console.log('链接', link)
   if (Number($event.type) > 5) return window.open(link);
-  router.push("/database/detail?id=" + $event.id + "&t=" + $event.type);
-  console.log($event.type);
+  window.location.href = "/database/detail?id=" + $event.id + "&t=" + $event.type
 };
 </script>
 

+ 82 - 72
src/views/Preview/index.vue

@@ -23,16 +23,16 @@
 
 <script lang="ts" setup>
 import { usePermission } from "@/Hooks/usePermission/usePermission";
-import { previewData } from "@/api/context/context";
-import useStatisticalTime from "@/Hooks/useStatisticalTime";
+import { previewData, setStatistics } from "@/api/context/context";
+//import useStatisticalTime from "@/Hooks/useStatisticalTime";
 import {
   computed,
-  onUnmounted,
+  //onUnmounted,
   ref,
-  watch,
   onActivated,
   ComponentOptions,
   shallowRef,
+  onMounted,
 } from "vue";
 import { useRoute } from "vue-router";
 import { ChangeTabEmit } from "@/types/views/database.type";
@@ -43,7 +43,8 @@ import useStopWindowContext from "@/Hooks/useStopWindowContext";
 import createWebShareCard from "@/Hooks/useCreateWebShareCard";
 import { showLoadingToast } from "vant";
 import useWeChatShare from "@/Hooks/useWeChatShare";
-import { onMounted } from 'vue';
+import { IStatistics } from "../../types/api/context.type";
+
 const route = useRoute();
 useStopWindowContext();
 const form = ref<IPreviewForm>({
@@ -69,20 +70,6 @@ const params = computed<shareParams & { url: string }>(
       suid: route.query?.suid as string,
     } as unknown) as shareParams & { url: string })
 );
-watch(
-  () => route.query?.url,
-  (val) => {
-    if (val) {
-      setTimeout(() => {
-        console.log("传递的url 链接为:", [route.query?.url]);
-        fileUrl.value = val as string;
-      }, 1000);
-    }
-  },
-  {
-    immediate: true,
-  }
-);
 const getPreviewData = async () => {
   const { data } = await previewData({
     userId: (route.query.uid as string) || "0",
@@ -100,53 +87,53 @@ const getPreviewData = async () => {
   );
   permiNode.value = PermiMode! as ComponentOptions;
 };
-const statistical = useStatisticalTime((time) => {
-  const t = Math.floor(time / 1000);
-  console.log("时长为:", t, Math.floor(time / 1000));
-  localStorage.setItem("spentTime", t.toString());
-  if (route.query.isSp) return
-  const f = {
-    productArchiveId: params.value.id,
-    headUserId: params.value.suid,
-    accessClient: "0",
-    pagePath: encodeURIComponent(
-      `${import.meta.env.VITE_BASE_HTTP}/preview?t=${params.value.type}&id=${
-        params.value.id
-      }&isSp=1`
-    ),
-    accessDuration: t * 1000,
-    pageType: params.value.type === "1" ? "70" : params.value.type === "2" ? "71" : "69",
-    pageLabel: "内容库预览",
-    userId: params.value.userId || "0",
-    productId: form.value?.productId || "0",
-    shopId: "" || "0",
-    behaviorType: "1",
-  };
-  fetch(
-    `
-    ${import.meta.env.VITE_BASE_URL}/user/record/Statistics?accessClient=${
-      f.accessClient
-    }&userId=${f.userId}&pagePath=${f.pagePath}&productId=${f.productId}&accessDuration=${
-      f.accessDuration
-    }&pageLabel=${f.pageLabel}&behaviorType=${f.behaviorType}&shopId=${
-      f.shopId
-    }&pageType=${f.pageType}&productArchiveId=${f.productArchiveId}&headUserId=${
-      f.headUserId
-    }
-    `,
-    {
-      method: "GET",
-      headers: {
-        "Content-Type": "application/x-www-form-urlencoded",
-      },
-      keepalive: true,
-    }
-  )
-    .then((res) => res.json())
-    .then(() => {
-      console.log("时间推送记录成功");
-    });
-});
+//const statistical = useStatisticalTime((time) => {
+//  const t = Math.floor(time / 1000);
+//  console.log("时长为:", t, Math.floor(time / 1000));
+//  localStorage.setItem("spentTime", t.toString());
+//  if (route.query.isSp) return
+//const f = {
+//  productArchiveId: params.value.id,
+//  headUserId: params.value.suid,
+//  accessClient: "0",
+//  pagePath: encodeURIComponent(
+//    `${import.meta.env.VITE_BASE_HTTP}/preview?t=${params.value.type}&id=${
+//      params.value.id
+//    }&isSp=1`
+//  ),
+//  accessDuration: t * 1000 || 0,
+//  pageType: params.value.type === "1" ? "70" : params.value.type === "2" ? "71" : "69",
+//  pageLabel: "内容库预览",
+//  userId: params.value.userId || "0",
+//  productId: form.value?.productId || "0",
+//  shopId: "" || "0",
+//  behaviorType: "1",
+//};
+//  fetch(
+//    `
+//    ${import.meta.env.VITE_BASE_URL}/user/record/Statistics?accessClient=${
+//      f.accessClient
+//    }&userId=${f.userId}&pagePath=${f.pagePath}&productId=${f.productId}&accessDuration=${
+//      f.accessDuration
+//    }&pageLabel=${f.pageLabel}&behaviorType=${f.behaviorType}&shopId=${
+//      f.shopId
+//    }&pageType=${f.pageType}&productArchiveId=${f.productArchiveId}&headUserId=${
+//      f.headUserId
+//    }
+//    `,
+//    {
+//      method: "GET",
+//      headers: {
+//        "Content-Type": "application/x-www-form-urlencoded",
+//      },
+//      //keepalive: true, // 设置请求延时
+//    }
+//  )
+//    .then((res) => res.json())
+//    .then(() => {
+//      console.log("时间推送记录成功");
+//    });
+//});
 const initData = () => {
   fileUrl.value = "";
   !route.query.isSp &&
@@ -157,17 +144,39 @@ const initData = () => {
   const obj = shareOptions.filter((e) => e.type === params.value.type)[0];
   if (!params.value.url) {
     getPreviewData();
+  } else {
+    setTimeout(() => {
+      fileUrl.value = params.value.url;
+    }, 1000);
   }
-  //useWeChatShare(params.value);
   createWebShareCard({
     title: obj.text,
     description: obj.text,
     image: params.value.imageUrl!,
   });
 };
-onUnmounted(() => {
-  statistical();
-});
+const statistical = async () => {
+  //if (route.query.isSp) return;
+  const statisticsForm = {
+    productArchiveId: params.value.id,
+    headUserId: params.value.suid?.toString(),
+    accessClient: "0",
+    pagePath: encodeURIComponent(
+      `${import.meta.env.VITE_BASE_HTTP}/preview?t=${params.value.type}&id=${
+        params.value.id
+      }&isSp=1`
+    ),
+    accessDuration: 0,
+    pageType: params.value.type === "1" ? "70" : params.value.type === "2" ? "71" : "69",
+    pageLabel: "内容库预览",
+    userId: params.value.userId || "0",
+    productId: form.value?.productId || "0",
+    shopId: "0",
+    behaviorType: "1",
+  } as IStatistics;
+  await setStatistics(statisticsForm);
+  console.log("数据统计成功");
+};
 onActivated(() => {
   initData();
 });
@@ -175,12 +184,13 @@ onMounted(() => {
   useWeChatShare({
     type: params.value.type,
     id: params.value.id!,
-    imageUrl: '',
+    imageUrl: "",
     spId: params.value.spId,
     isShowToast: false,
     suid: params.value.suid,
   });
-})
+  statistical();
+});
 </script>
 
 <style scoped lang="scss">