2 Commits f51079cf71 ... d9ae93e193

Autor SHA1 Mensaje Fecha
  lianghongjie d9ae93e193 Merge branch 'dev' of http://124.70.149.18:10880/lianghj/queenshow into dev hace 1 año
  lianghongjie c17fc2aa30 添加统计分析 hace 1 año

+ 0 - 8
src/hooks/initAuthDef.ts

@@ -1,5 +1,4 @@
 import { Dict_Apis } from "@/dict";
-import { cookieStorage } from "@/utils/cookieStorage";
 import { initAuth } from "@queenjs-modules/auth";
 
 export function initAuthDef() {
@@ -20,13 +19,6 @@ export function initAuthDef() {
         key: "queenshow",
       },
     },
-    actions: {
-      logout() {
-        this.store.clearUserInfo();
-        this.actions.jump("logout");
-        cookieStorage.removeItem("clientId");
-      },
-    },
     https: {
       getProfile() {
         return (this as any).request("/profile?appKey=" + this.config.key, {

+ 0 - 14
src/modules/editor/module/actions/init.ts

@@ -1,5 +1,3 @@
-import { cookieStorage } from "@/utils/cookieStorage";
-import { nanoid } from "nanoid";
 import { EditorModule } from "..";
 import { CompObject } from "../../controllers/SelectCtrl/compObj";
 import { DesignComp } from "../../objects/DesignTemp/DesignComp";
@@ -30,7 +28,6 @@ export const initActions = EditorModule.action({
 
   // 初始化数据
   async initDesign(id: string, isSys = false) {
-    this.actions.setCookieClientId();
     const ret = await this.https.getDesignDetail(id, { isSys });
     this.store.setDesignData(ret.result);
   },
@@ -49,15 +46,4 @@ export const initActions = EditorModule.action({
       this.controls.selectCtrl.selecteObjs([new CompObject(comp)]);
     }
   },
-
-  setCookieClientId() {
-    let clientId = undefined;
-    try {
-      const userInfo = JSON.parse(localStorage.getItem("userInfo") || "{}");
-      clientId = userInfo._id || nanoid();
-    } catch (error) {
-      clientId = nanoid();
-    }
-    cookieStorage.setItem("clientId", clientId);
-  },
 });

+ 37 - 21
src/modules/editor/module/helpers/index.ts

@@ -1,3 +1,4 @@
+import { nanoid } from "nanoid";
 import { EditorModule } from "..";
 import { CompObject } from "../../controllers/SelectCtrl/compObj";
 import { Matrix } from "../../controllers/SelectCtrl/matrix";
@@ -16,7 +17,7 @@ export const helpers = EditorModule.helper({
   designSizeToPx(value: number) {
     return value / 2.0;
   },
-  
+
   findComp(compId: string) {
     const { compMap } = this.store.designData;
     const comp = compMap[compId];
@@ -39,16 +40,16 @@ export const helpers = EditorModule.helper({
     }
     return false;
   },
-  isStreamCardChild(compId:string) {
-    if (compId == "root" || this.helper.isStreamCard(compId) ) {
+  isStreamCardChild(compId: string) {
+    if (compId == "root" || this.helper.isStreamCard(compId)) {
       return false;
     }
-    const cards = this.store.streamCardIds
+    const cards = this.store.streamCardIds;
     let n = cards.length;
     const compMap = this.store.designData.compMap;
-    while(n--) {
-       const childs = compMap[cards[n]].children.default || [];
-       if (childs.indexOf(compId) > -1 ) return true;
+    while (n--) {
+      const childs = compMap[cards[n]].children.default || [];
+      if (childs.indexOf(compId) > -1) return true;
     }
     return false;
   },
@@ -61,26 +62,26 @@ export const helpers = EditorModule.helper({
     return this.store.designData.compMap["root"];
   },
 
-  getCompCard(compId:string) {
-      const paths:DesignComp[] = this.helper.getCompTrees(compId);
-      return paths[1]
+  getCompCard(compId: string) {
+    const paths: DesignComp[] = this.helper.getCompTrees(compId);
+    return paths[1];
   },
 
-  getCompWorlParentPos(compId:string, vx:number ,vy: number) {
-    const paths:DesignComp[] = this.helper.getCompTrees(compId);
+  getCompWorlParentPos(compId: string, vx: number, vy: number) {
+    const paths: DesignComp[] = this.helper.getCompTrees(compId);
     const m = new Matrix();
     let n = paths.length;
     let box = paths[1].$el.getBoundingClientRect();
-    m.translate(box.left-vx, box.top-vy);
-    for( let i=2; i<(n-1); i++) {//card开始遍历
+    m.translate(box.left - vx, box.top - vy);
+    for (let i = 2; i < n - 1; i++) {
+      //card开始遍历
       const m1 = new Matrix();
-      m1.setMatrixStr(paths[i].layout.transformMatrix || "matrix(1,0,0,1,0,0)")
+      m1.setMatrixStr(paths[i].layout.transformMatrix || "matrix(1,0,0,1,0,0)");
       m.append(m1);
     }
     return m;
   },
 
-
   getCompTrees(compId: string) {
     const comps: DesignComp[] = [];
     const getParentComp = (compId: string) => {
@@ -93,7 +94,7 @@ export const helpers = EditorModule.helper({
     getParentComp(compId);
     return comps;
   },
-  createStyle(layout: Partial<Layout> & {size:any[]}) {
+  createStyle(layout: Partial<Layout> & { size: any[] }) {
     return createCompStyle(this, layout);
   },
   isCurrComp(compId: string) {
@@ -148,8 +149,8 @@ export const helpers = EditorModule.helper({
     };
   },
 
-  getCardCompBound(compId :string) {
-    const compMap = this.store.designData.compMap
+  getCardCompBound(compId: string) {
+    const compMap = this.store.designData.compMap;
     const c = compMap[compId];
     const obj = new CompObject(c);
     const bound = obj.getBox();
@@ -172,9 +173,24 @@ export const helpers = EditorModule.helper({
     }
     maxH = this.helper.pxToDesignSize(maxH);
 
-    if (childs.length < 1 ) {
-      maxH = 200
+    if (childs.length < 1) {
+      maxH = 200;
     }
     card.setH(maxH);
   },
+
+  getClientId() {
+    let clientId = undefined;
+    try {
+      const userInfo = JSON.parse(localStorage.getItem("userInfo") || "{}");
+      clientId = userInfo._id || localStorage.getItem("clientId");
+    } catch (error) {
+      console.error(error);
+    }
+    if (!clientId) {
+      clientId = nanoid();
+      localStorage.setItem("clientId", clientId);
+    }
+    return clientId;
+  },
 });

+ 4 - 1
src/modules/editor/module/https/index.ts

@@ -5,7 +5,10 @@ export const https = EditorModule.http({
   getDesignDetail(id: string, params?: { isSys: boolean }) {
     return this.request("/h5/detail/" + id, {
       method: "GET",
-      params,
+      params: {
+        ...params,
+        clientId: this.helper.getClientId(),
+      },
     });
   },
   getCompDetail(id: string) {

+ 0 - 98
src/pages/h5/statistics/Stat/EchartMap.tsx

@@ -1,98 +0,0 @@
-import * as echarts from "echarts";
-import { defineComponent, onMounted, ref, watch } from "vue";
-import { array } from "vue-types";
-
-export default defineComponent({
-  props: {
-    data: array().isRequired,
-  },
-  setup(props) {
-    const echartRef = ref();
-    let chartInstance: any;
-    let mapLoaded = false;
-
-    const option = {
-      tooltip: {
-        trigger: "item",
-        showDelay: 0,
-        transitionDuration: 0.2,
-      },
-      visualMap: {
-        show: false,
-        inRange: {
-          color: [
-            "#313695",
-            "#4575b4",
-            "#74add1",
-            "#abd9e9",
-            "#e0f3f8",
-            "#ffffbf",
-            "#fee090",
-            "#fdae61",
-            "#f46d43",
-            "#d73027",
-            "#a50026",
-          ],
-        },
-      },
-      series: [
-        {
-          name: "统计分析",
-          type: "map",
-          roam: true,
-          map: "china",
-          boundingCoords: [
-            // 定位左上角经纬度
-            [68.99814, 50.74432],
-            // 定位右下角经纬度
-            [139.93812, 25.23403],
-          ],
-          emphasis: {
-            label: {
-              show: true,
-            },
-          },
-          data: [] as any[],
-        },
-      ],
-    };
-
-    onMounted(() => {
-      initEchart(echartRef.value);
-    });
-
-    watch(
-      () => props.data,
-      () => {
-        if (mapLoaded) {
-          updateEchart();
-        }
-      }
-    );
-
-    function updateEchart() {
-      option.series[0].data = props.data;
-      chartInstance.setOption(option);
-    }
-
-    function initEchart(el: HTMLElement) {
-      chartInstance = echarts.init(el);
-      chartInstance.showLoading();
-
-      fetch(
-        "https://geo.datav.aliyun.com/areas_v3/bound/100000_full.json"
-      ).then(async (res) => {
-        const json = await res.json();
-        chartInstance.hideLoading();
-
-        echarts.registerMap("china", json);
-        updateEchart();
-        mapLoaded = true;
-      });
-    }
-
-    return () => {
-      return <div class="h-300px" ref={echartRef}></div>;
-    };
-  },
-});

+ 0 - 165
src/pages/h5/statistics/Stat/index.tsx

@@ -1,165 +0,0 @@
-import { Dict_Apis } from "@/dict";
-import { css } from "@linaria/core";
-import { defineComponent, reactive } from "vue";
-import EchartMap from "./EchartMap";
-
-export default defineComponent(() => {
-  const params = new URLSearchParams(location.href.split("?")[1]);
-  const id = params.get("id");
-  const state = reactive({
-    total: {
-      uv: 0,
-      pv: 0,
-      ip: 0,
-    } as Record<string, number>,
-    currType: "pv",
-    currMapData: [] as any[],
-  });
-  const result = { areas: [] as any[] };
-
-  fetch(`${Dict_Apis.promotion}/count/${id}`).then((res) => {
-    res.json().then((ret) => {
-      if (ret.errorNo === 200) {
-        result.areas = ret.result.areas || [];
-        const total = { uv: 0, pv: 0, ip: 0 };
-        result.areas.forEach((item) => {
-          total.pv += item.PV;
-          total.uv += item.UV.length;
-          total.ip += item.IP.length;
-        });
-        state.total = total;
-        state.currMapData = createMapData();
-      }
-    });
-  });
-
-  function createMapData() {
-    const data: any[] = [];
-    result.areas.forEach((item) => {
-      const itemNum: any = {
-        pv: item.PV,
-        uv: item.UV.length,
-        ip: item.IP.length,
-      };
-
-      data.push({
-        name: item.Province,
-        value: itemNum[state.currType] || 0,
-      });
-    });
-    return data;
-  }
-
-  const tabs = [
-    {
-      label: "浏览量(PV)",
-      value: "pv" as const,
-    },
-    {
-      label: "访客量(UV)",
-      value: "uv" as const,
-    },
-    {
-      label: "IP数",
-      value: "ip" as const,
-    },
-  ];
-
-  function switchStatType(type: string) {
-    state.currType = type;
-    state.currMapData = createMapData();
-  }
-
-  return () => (
-    <div class="p-20px space-y-20px">
-      <div class="grid grid-cols-3 py-16px bg-white rounded text-center">
-        {tabs.map((d) => {
-          return (
-            <div class={topTabCls}>
-              <div class="text-[#333] text-22px font-500 mb-8px">
-                {state.total[d.value]}
-              </div>
-              <div class="text-[#666] text-12px">{d.label}</div>
-            </div>
-          );
-        })}
-      </div>
-      <div class="bg-white rounded text-center font-500 flow-root">
-        <div class="grid grid-cols-3 leading-48px text-14px">
-          {tabs.map((d) => {
-            return (
-              <div
-                class={[mapTabCls, d.value === state.currType && "active"]}
-                onClick={() => switchStatType(d.value)}
-              >
-                {d.label}
-              </div>
-            );
-          })}
-        </div>
-        <EchartMap data={state.currMapData} />
-        <div class="m-15px">
-          <table class={tableCls}>
-            <thead>
-              <th>序列</th>
-              <th>省份</th>
-              <th>{tabs.find((d) => d.value == state.currType)?.label.split("(")[0]}</th>
-              <th>占比</th>
-            </thead>
-            <tbody>
-              {state.currMapData.map((d, i) => {
-                return (
-                  <tr key={i}>
-                    <td>{i + 1}</td>
-                    <td>{d.name}</td>
-                    <td>{d.value}</td>
-                    <td>
-                      {parseFloat(
-                        ((d.value / state.total[state.currType]) * 100).toFixed(
-                          2
-                        )
-                      ) + "%"}
-                    </td>
-                  </tr>
-                );
-              })}
-            </tbody>
-          </table>
-        </div>
-      </div>
-    </div>
-  );
-});
-
-const topTabCls = css`
-  &:not(:first-child) {
-    border-left: 1px solid #f1f1f1;
-  }
-`;
-
-const mapTabCls = css`
-  background-color: #f1f1f1;
-  &.active {
-    background-color: #fff;
-  }
-`;
-
-const tableCls = css`
-  width: 100%;
-  border: 1px solid #f5f6f7;
-  font-size: 12px;
-  thead {
-    height: 48px;
-    background-color: #f5f6f7;
-    th {
-      font-weight: 400;
-      color: #666;
-      width: 25%;
-    }
-  }
-  tr {
-    height: 42px;
-    border-bottom: 1px solid #f5f6f7;
-    color: #333;
-  }
-`;

+ 0 - 7
src/pages/h5/statistics/index.ts

@@ -1,7 +0,0 @@
-import { startApp } from "@/App";
-import { initViewportSize } from "@/hooks/initViewportSize";
-import "./style.less";
-import router from "./router";
-
-document.title = "统计分析";
-startApp(router, [initViewportSize]);

+ 0 - 19
src/pages/h5/statistics/router.ts

@@ -1,19 +0,0 @@
-import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router";
-
-const routes: Array<RouteRecordRaw> = [
-  {
-    path: "/",
-    name: "stat",
-    meta: {
-      needAuth: true,
-    },
-    component: () => import("./Stat"),
-  },
-];
-
-const router = createRouter({
-  history: createWebHashHistory(),
-  routes,
-});
-
-export default router;

+ 0 - 5
src/pages/h5/statistics/style.less

@@ -1,5 +0,0 @@
-#app {
-  min-height: 100vh;
-  min-width: 100vw;
-  background-color: #f5f6f7;
-}

+ 0 - 7
src/pages/stat/Count/index.tsx

@@ -1,7 +0,0 @@
-import { defineComponent } from "vue";
-
-export default defineComponent({
-  setup() {
-    return <div></div>;
-  },
-});

+ 0 - 7
src/pages/stat/components/Layout.tsx

@@ -1,7 +0,0 @@
-import { defineComponent } from "vue";
-
-export default defineComponent({
-  setup() {
-    return () => <div></div>;
-  },
-});

+ 0 - 12
src/pages/stat/index.ts

@@ -1,12 +0,0 @@
-import { startApp } from "@/App";
-import { initAuthDef } from "@/hooks/initAuthDef";
-import { initLauncher } from "@/modules/launcher";
-import { initResource } from "@/modules/resource";
-import CKEditor from "@ckeditor/ckeditor5-vue";
-import router from "./router";
-
-document.title = "推广编辑器";
-
-startApp(router, [initAuthDef, initResource, initLauncher], (app) => {
-  app.use(CKEditor);
-});

+ 0 - 24
src/pages/stat/router.ts

@@ -1,24 +0,0 @@
-import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router";
-import Layout from "./components/Layout"
-
-const routes: Array<RouteRecordRaw> = [
-  {
-    path: "/",
-    name: "backend",
-    component: Layout,
-    children: [
-      {
-        path: "/count",
-        name: "count",
-        component: () => import("./Count")
-      }
-    ]
-  },
-];
-
-const router = createRouter({
-  history: createWebHashHistory(),
-  routes,
-});
-
-export default router;

+ 3 - 2
src/pages/website/Promotion2/components/PromotionItem.tsx

@@ -88,8 +88,9 @@ export default defineUI({
               placement="bottom"
               overlay={
                 <Menu class="w-90px">
-                  {/* <Menu.Item>复制</Menu.Item> */}
-                  {/* <Menu.Item>分享</Menu.Item> */}
+                  <Menu.Item>
+                    <div onClick={() => emit("menu", "stat")}>统计分析</div>
+                  </Menu.Item>
                   <Menu.Item>
                     <div onClick={() => emit("menu", "rename")}>重命名</div>
                   </Menu.Item>

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

@@ -58,6 +58,9 @@ export function createPromotinController(
 
   ctrl.onMenuClick = async (name, record) => {
     switch (name) {
+      case "stat":
+        window.open("https://show.3dqueen.cloud/stat/#/count?id=" + record._id);
+        break;
       case "delete":
         await resource.actions.deletePromotion(record);
         ctrl.ListCtrl.fresh();

+ 0 - 1
vue.config.js

@@ -18,7 +18,6 @@ module.exports = defineConfig({
     index: "src/pages/website/index.ts",
     editor: "src/pages/editor/index.ts",
     share: "src/pages/h5/share/index.ts",
-    stat: "src/pages/h5/statistics/index.ts",
     treeapi: "src/pages/queentree/index.ts",
   },
   publicPath: publicPath,