|
@@ -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">
|