|
@@ -1,28 +1,55 @@
|
|
|
-import { defineComponent, onMounted, reactive, ref } from "vue";
|
|
|
import { Dict_Apis } from "@/dict";
|
|
|
-import EchartMap from "./EchartMap";
|
|
|
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 mapData = ref();
|
|
|
const state = reactive({
|
|
|
total: {
|
|
|
uv: 0,
|
|
|
pv: 0,
|
|
|
ip: 0,
|
|
|
- },
|
|
|
+ } as Record<string, number>,
|
|
|
currType: "pv",
|
|
|
- currMapData: [],
|
|
|
+ currMapData: [] as any[],
|
|
|
});
|
|
|
+ const result = { areas: [] as any[] };
|
|
|
|
|
|
fetch(`${Dict_Apis.promotion}/count/${id}`).then((res) => {
|
|
|
res.json().then((ret) => {
|
|
|
- console.log(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)",
|
|
@@ -40,6 +67,7 @@ export default defineComponent(() => {
|
|
|
|
|
|
function switchStatType(type: string) {
|
|
|
state.currType = type;
|
|
|
+ state.currMapData = createMapData();
|
|
|
}
|
|
|
|
|
|
return () => (
|
|
@@ -56,7 +84,7 @@ export default defineComponent(() => {
|
|
|
);
|
|
|
})}
|
|
|
</div>
|
|
|
- <div class="bg-white rounded text-center font-500">
|
|
|
+ <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 (
|
|
@@ -70,6 +98,34 @@ export default defineComponent(() => {
|
|
|
})}
|
|
|
</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>
|
|
|
);
|
|
@@ -87,3 +143,23 @@ const mapTabCls = css`
|
|
|
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;
|
|
|
+ }
|
|
|
+`;
|