Commit 11bcfe9c by Lin

feat: 接待中心移动端开发

1 parent 0acde363
<template>
<view class="output-value-box">
<view class="output-value-title">本月产值</view>
<text class="output-value-title">本月产值</text>
<view class="output-value">
<view class="value">
<text class="value-num">{{ formattedNumber('actualProduction') }}</text>
......@@ -12,7 +12,7 @@
</view>
</view>
<view class="output-canvas">
<l-echart ref="chartRef" class="pie-chart" @finished="initChart" />
<canvas id="output-chart" class="canvas"></canvas>
<view class="chart-text">
<text class="chart-label">产值贡献</text>
<text class="chart-num">{{ formattedNumber('productionContribution') }}%</text>
......@@ -35,10 +35,6 @@
</template>
<script setup lang="uts">
import { ref, computed, watch, nextTick } from 'vue';
const chartRef = ref<LEchartComponentPublicInstance | null>(null);
/** 页面数据:actualProduction、personalProduction、targetProduction、achievementRatio、productionContribution */
const props = withDefaults(
defineProps<{
......@@ -69,222 +65,200 @@ function formattedNumber(key: string, unit: string | null = null): string {
return str;
}
/** 获取产值贡献百分比(0-100) */
function getContribution(): number {
onMounted(() => {
drawChart();
});
watch(
() => props.pageData,
() => {
drawChart();
},
{ deep: true }
);
function drawChart() {
const pd = props.pageData;
const ds = props.dataShow;
if (pd == null) return;
// 获取 contribution 值,假设是 0-100 的数字
let contribution = 0;
if (pd != null && ds) {
const val = pd['productionContribution'];
if (val != null && val != "") {
contribution = parseFloat("" + val);
}
}
if (contribution < 0) { contribution = 0; }
if (contribution > 100) { contribution = 100; }
return contribution;
}
/** 构建产值贡献环形图(饼图)配置 */
function buildPieOption(): UTSJSONObject {
const contribution = getContribution();
const rest = 100 - contribution;
const dataItems: UTSJSONObject[] = [
{
value: contribution,
name: '贡献',
itemStyle: {
color: {
type: 'linear',
x: 0,
y: 0,
x2: 1,
y2: 1,
colorStops: [{ offset: 0, color: '#7AAFFF' }, { offset: 1, color: '#4673FF' }]
}
}
} as UTSJSONObject,
{
value: rest,
name: '',
itemStyle: { color: '#F2F6FF' }
} as UTSJSONObject
];
return {
tooltip: { show: false },
series: [
{
type: 'pie',
radius: ['45%', '65%'],
center: ['50%', '50%'],
startAngle: 90,
data: dataItems,
label: { show: false },
labelLine: { show: false },
emphasis: { scale: false }
}
]
} as UTSJSONObject;
}
// 限制在 0-100
if (contribution < 0) contribution = 0;
if (contribution > 100) contribution = 100;
/** 初始化 lime-echart 饼图 */
const initChart = async (): Promise<void> => {
const comp = chartRef.value;
if (comp == null) { return; }
try {
await comp.init(null);
comp.setOption(buildPieOption());
} catch (e) {
console.error('OutputValue 饼图初始化失败:', e);
}
};
const ctx = uni.getElementById('output-chart')?.getContext('2d') as CanvasRenderingContext2D | null;
if (ctx == null) return;
const pageDataRef = computed((): UTSJSONObject => {
const pd = props.pageData;
return pd != null ? pd : ({} as UTSJSONObject);
});
const width = 100; // canvas 宽
const height = 100; // canvas 高
const centerX = width / 2;
const centerY = height / 2;
const radius = 38; // 半径
const lineWidth = 8; // 线宽
watch(
pageDataRef,
() => {
nextTick(() => {
chartRef.value?.setOption(buildPieOption());
});
},
{ deep: true }
);
// 清空画布
ctx.clearRect(0, 0, width, height);
// 绘制背景圆环
ctx.beginPath();
ctx.arc(centerX, centerY, radius, 0, 2 * Math.PI);
ctx.lineWidth = lineWidth;
ctx.strokeStyle = '#F0F2F5'; // 浅灰色背景
ctx.lineCap = 'round';
ctx.stroke();
// 绘制进度条
const startAngle = -Math.PI / 2;
const endAngle = startAngle + (contribution / 100) * 2 * Math.PI;
// 只有当有进度时才绘制
if (contribution > 0) {
ctx.beginPath();
ctx.arc(centerX, centerY, radius, startAngle, endAngle);
ctx.lineWidth = lineWidth;
ctx.strokeStyle = '#4673ff'; // 蓝色进度
ctx.lineCap = 'round';
// 增加阴影,使效果更接近设计图
ctx.shadowBlur = 4;
ctx.shadowColor = 'rgba(70, 115, 255, 0.3)';
ctx.stroke();
// 绘制完后清除阴影,以免影响其他绘制
ctx.shadowBlur = 0;
}
}
</script>
<style scoped lang="scss">
/* 本月产值模块 1:1 还原样式 */
/* 本月产值 - 基准 183px,toRpx/2 换算为 px;文字样式仅写在 text 上 */
.output-value-box {
position: relative;
width: 100%;
height: 183px;
display: flex;
flex-direction: column;
box-sizing: border-box;
background-color: #ffffff;
border-radius: 12px;
background-color: #ffffff; /* 确保背景色 */
border-radius: 12px; /* 圆角 */
padding: 0;
overflow: hidden;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02); /* 轻微阴影,增强卡片质感 */
}
.output-value-title {
font-size: 14px;
font-weight: 500; /* 加粗一点 */
padding: 16px 16px 0;
color: #333333;
font-size: 11px;
font-weight: 500;
padding: 16px 20px 0;
}
.output-value {
width: 50%;
padding: 12px 0 0 24px;
padding: 20px 0 0 20px;
flex-shrink: 0;
display: flex;
flex-direction: column;
}
.value {
display: flex;
flex-direction: row;
align-items: center;
margin-bottom: 4px;
align-items: baseline;
margin-bottom: 8px;
}
.value-num {
color: #4673ff;
font-size: 32px;
line-height: 38px;
font-size: 32px; /* 加大字体 */
line-height: 32px;
font-weight: bold;
font-family: 'DIN Alternate', 'DINAlternate-Bold', 'DINCondensed-Bold', sans-serif;
font-family: DINAlternate-Bold, Roboto-Bold, Helvetica-Bold, sans-serif; /* 字体回退 */
}
.unit {
color: #999999;
font-size: 12px;
margin-left: 2px;
color: #333333;
font-size: 14px;
font-weight: 400;
margin-left: 4px;
line-height: 18px;
}
.sub-value {
display: flex;
align-items: center;
margin-top: -2px;
}
.sub-value .sub-label {
color: #999999;
color: #666666; /* 稍微浅一点的灰色 */
font-size: 12px;
}
.sub-value .num {
color: #4673ff;
font-size: 14px;
font-weight: bold;
font-weight: 500;
margin-left: 4px;
}
.output-canvas {
position: absolute;
right: 16px;
top: 24px;
width: 110px;
height: 110px;
top: 36px;
width: 100px;
height: 100px;
display: flex;
justify-content: center;
align-items: center;
}
.pie-chart {
width: 100%;
height: 100%;
.canvas {
width: 100px;
height: 100px;
position: absolute;
top: 0;
left: 0;
}
.chart-text {
position: absolute;
position: relative;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
pointer-events: none;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 1;
z-index: 1; /* 确保在 canvas 上方 */
}
.chart-label {
font-size: 10px;
color: #999999;
color: #666666;
margin-bottom: 2px;
}
.chart-num {
font-size: 18px;
font-size: 16px;
color: #4673ff;
font-weight: bold;
font-family: 'DIN Alternate', sans-serif;
}
/* 底部目标/达成比例栏 */
.output-view-wrap {
position: absolute;
left: 16px;
right: 16px;
left: 0;
right: 0;
bottom: 16px;
display: flex;
justify-content: center;
}
.output-view {
width: 100%;
height: 36px;
width: 90%; /* 稍微宽一点 */
max-width: 340px;
height: 36px; /* 加高一点 */
border-radius: 18px;
background-color: #F6F8FF;
background: #F5F7FF; /* 浅蓝色背景,更接近设计图 */
display: flex;
align-items: center;
justify-content: space-between;
padding: 0;
padding: 0 16px;
box-sizing: border-box;
}
......@@ -293,11 +267,12 @@ watch(
justify-content: center;
align-items: center;
flex: 1;
flex-shrink: 0;
}
.output-view .item-label {
color: #666666;
font-size: 13px;
color: #333333;
font-size: 12px;
}
.output-view .num {
......@@ -311,7 +286,8 @@ watch(
.divider {
width: 1px;
height: 14px;
background-color: #E0E4EF;
background: #D8DCE6; /* 调整分隔线颜色 */
flex-shrink: 0;
margin: 0 10px;
}
</style>
......@@ -819,8 +819,8 @@ onUnmounted(() => {
.record-list {
flex: 1;
box-sizing: border-box;
position: relative;
overflow: hidden;
width: 100%;
min-height: 0;
}
/* ── 提示条(高度 38px ≈ toRpx(76)/2) ─────────────────────────────────────── */
......
......@@ -51,6 +51,9 @@
<view v-else-if="tabIndex == 0" class="legacy-home-wrap">
<slot name="home"></slot>
</view>
<view v-else-if="tabIndex == 1" class="reception-center-wrap">
<ReceptionCenterCenter />
</view>
</view>
<view v-else class="right-side">
......@@ -97,6 +100,10 @@
<view v-else-if="tabIndex == 0" class="legacy-home-wrap">
<slot name="home"></slot>
</view>
<!-- 横屏接待中心:仅显示右侧列表区 -->
<view v-else-if="tabIndex == 1" class="reception-center-wrap">
<ReceptionCenterCenter :only-right="true" />
</view>
</view>
<!-- 竖屏:底部 TabBar;横屏:左侧栏 -->
......@@ -135,6 +142,7 @@ import { storage } from "@/utils/storage.uts";
import HomeFrameLeftSide from "./LeftSide.uvue";
import HomeFrameMessageIndex from "./MessageIndex.uvue";
import ReceptionCenterCenter from "./ReceptionCenter/center.uvue";
const props = defineProps<{
showFooter?: boolean
......@@ -384,6 +392,15 @@ defineExpose({
overflow: hidden;
}
.reception-center-wrap {
flex: 1;
width: 100%;
height: 100%;
min-height: 0;
display: flex;
flex-direction: column;
}
/* 底部门店信息,与旧项目 store-addr 一致:居中、无通栏背景、两侧渐变线 */
.store-addr {
position: absolute;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!