Commit d919b1e0 by zhangxw

fix(venus-usedcar-quality): 车况简报折线图修改

1 parent d00991f4
...@@ -339,7 +339,7 @@ const handleTrendResize = () => { ...@@ -339,7 +339,7 @@ const handleTrendResize = () => {
function setData(data: any) { function setData(data: any) {
const trends = (data as any)?.priceTrends || []; const trends = (data as any)?.priceTrends || [];
const xAxisData = Array.isArray(trends) ? trends.map((i: any) => `${i?.month ?? ""}月`) : []; const xAxisData = Array.isArray(trends) ? trends.map((i: any) => String(i?.month ?? "")) : [];
const seriesData = Array.isArray(trends) ? trends.map((i: any) => Number(i?.priceWan ?? 0)) : []; const seriesData = Array.isArray(trends) ? trends.map((i: any) => Number(i?.priceWan ?? 0)) : [];
const numeric = seriesData.filter((n) => Number.isFinite(n)); const numeric = seriesData.filter((n) => Number.isFinite(n));
hasTrendData.value = numeric.length > 0; hasTrendData.value = numeric.length > 0;
...@@ -355,15 +355,50 @@ function setData(data: any) { ...@@ -355,15 +355,50 @@ function setData(data: any) {
const yMax = numeric.length > 0 ? Math.ceil((maxVal + 0.5) * 10) / 10 : 1; const yMax = numeric.length > 0 ? Math.ceil((maxVal + 0.5) * 10) / 10 : 1;
trendChart?.dispose(); trendChart?.dispose();
trendChart = echarts.init(trendChartRef.value, undefined, { renderer: "canvas" }); trendChart = echarts.init(trendChartRef.value, undefined, { renderer: "canvas" });
const formatMonthLabel = (raw: unknown) => {
const s = String(raw ?? "");
if (/^\d{1,2}$/.test(s)) return `${s}月`;
if (/^\d{4}-\d{1,2}$/.test(s)) return s;
return s;
};
const formatWanText = (raw: unknown) => {
const n = Number(raw);
if (!Number.isFinite(n)) return "-";
const fixed = n.toFixed(1);
return fixed.endsWith(".0") ? fixed.slice(0, -2) : fixed;
};
trendChart.setOption({ trendChart.setOption({
grid: { left: 28, right: 12, top: 12, bottom: 24 }, grid: { left: 44, right: 12, top: 12, bottom: 24, containLabel: true },
tooltip: { trigger: "axis" }, tooltip: {
trigger: "axis",
triggerOn: "click",
backgroundColor: "#ffffff",
borderColor: "transparent",
extraCssText: "box-shadow: 0 6px 18px rgba(0,0,0,0.12); border-radius: 8px; padding: 10px 12px;",
textStyle: { color: "#1d1d1d", fontSize: 12 },
axisPointer: {
type: "line",
lineStyle: { color: "rgba(0,0,0,0.18)", width: 1 },
},
formatter: (params: any) => {
const first = Array.isArray(params) ? params[0] : params;
const month = formatMonthLabel(first?.axisValue ?? "");
const value = formatWanText(first?.data);
return `<div style="line-height: 18px;">
<div style="font-weight: 600; margin-bottom: 2px;">${month}</div>
<div>本车预估价值: ${value}万</div>
</div>`;
},
},
xAxis: { xAxis: {
type: "category", type: "category",
data: xAxisData, data: xAxisData,
axisTick: { show: false }, axisTick: { show: false },
axisLine: { lineStyle: { color: "#eee" } }, axisLine: { lineStyle: { color: "#eee" } },
axisLabel: { color: "#999", fontSize: 10 } axisLabel: { color: "#999", fontSize: 10, formatter: (v: unknown) => formatMonthLabel(v) }
}, },
yAxis: { yAxis: {
type: "value", type: "value",
...@@ -371,7 +406,13 @@ function setData(data: any) { ...@@ -371,7 +406,13 @@ function setData(data: any) {
max: yMax, max: yMax,
axisLine: { show: false }, axisLine: { show: false },
axisTick: { show: false }, axisTick: { show: false },
axisLabel: { color: "#999", fontSize: 10 }, axisLabel: {
color: "#999",
fontSize: 10,
margin: 10,
align: "right",
formatter: (v: unknown) => formatWanText(v),
},
splitLine: { lineStyle: { color: "#f0f0f0" } } splitLine: { lineStyle: { color: "#f0f0f0" } }
}, },
series: [ series: [
......
...@@ -24,7 +24,7 @@ import { computed, onMounted, ref } from "vue"; ...@@ -24,7 +24,7 @@ import { computed, onMounted, ref } from "vue";
import { exchangeOpenIdByCode, getScanLivecodeQrcode } from "@/api/modules/vehicle-message"; import { exchangeOpenIdByCode, getScanLivecodeQrcode } from "@/api/modules/vehicle-message";
import { fetchConfig, getConfig } from "@/config/center"; import { fetchConfig, getConfig } from "@/config/center";
import { useReportTrackPage } from "@/mixins/reportTrackPageMixin"; import { useReportTrackPage } from "@/mixins/reportTrackPageMixin";
import { showToast } from "vant"; import { closeToast, showLoadingToast, showToast } from "vant";
useReportTrackPage({ useReportTrackPage({
browseEventCode: "scanLivecodeBrowse", browseEventCode: "scanLivecodeBrowse",
...@@ -116,7 +116,9 @@ function buildWeChatOauthAuthorizeUrl(redirectUrl: string) { ...@@ -116,7 +116,9 @@ function buildWeChatOauthAuthorizeUrl(redirectUrl: string) {
async function exchangeCodeToOpenId(code: string) { async function exchangeCodeToOpenId(code: string) {
try { try {
const appId = await ensureWeChatAppId(); const appId = await ensureWeChatAppId();
showLoadingToast({ message: "加载中...", forbidClick: true, duration: 0 });
const res = await exchangeOpenIdByCode({ code, appId, state: "snsapi_base" }); const res = await exchangeOpenIdByCode({ code, appId, state: "snsapi_base" });
closeToast();
const anyRes = res as any; const anyRes = res as any;
return String(anyRes?.openId ?? anyRes?.openid ?? anyRes?.data?.openId ?? anyRes?.data?.openid ?? ""); return String(anyRes?.openId ?? anyRes?.openid ?? anyRes?.data?.openId ?? anyRes?.data?.openid ?? "");
} catch { } catch {
...@@ -136,6 +138,7 @@ async function fetchQrByOpenId(params: { ...@@ -136,6 +138,7 @@ async function fetchQrByOpenId(params: {
phase.value = "loading"; phase.value = "loading";
message.value = "正在获取群二维码"; message.value = "正在获取群二维码";
try { try {
showLoadingToast({ message: "加载中...", forbidClick: true, duration: 0 });
const res = await getScanLivecodeQrcode({ const res = await getScanLivecodeQrcode({
liveCode: params.liveCode, liveCode: params.liveCode,
exp: params.exp, exp: params.exp,
...@@ -145,6 +148,7 @@ async function fetchQrByOpenId(params: { ...@@ -145,6 +148,7 @@ async function fetchQrByOpenId(params: {
carConditionCode: params.carConditionCode, carConditionCode: params.carConditionCode,
openid: params.openId openid: params.openId
}); });
closeToast();
const { code, data, msg } = res as unknown as { code: number; data?: Record<string, unknown>; msg?: string }; const { code, data, msg } = res as unknown as { code: number; data?: Record<string, unknown>; msg?: string };
if (code !== 0 || !data) { if (code !== 0 || !data) {
showToast(msg || "获取二维码失败"); showToast(msg || "获取二维码失败");
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!