Commit 4aabfcf9 by Lin

修复(登录):处理移动端输入验证并优化标签加载反馈

- 更新了登录功能,确保在继续操作之前会对移动端输入进行验证。
- 改进了 loadTagListFromApi 函数,使其能返回成功和失败情况下的特定状态码。
- 添加了关于标签加载结果的用户反馈,根据结果显示相应的消息。
- 调整了样式以在各个组件之间实现更好的视觉一致性,包括字体大小和内边距的调整。
- 移除了未使用的 CustomerListPanel 和 DashboardPanel 组件,以简化代码库。
1 parent 20c7f197
......@@ -162,7 +162,8 @@ const jump = (data: any, remember: boolean): void => {
const doLogin = async (): Promise<void> => {
console.log("doLogin mobile:", mobile.value);
const m = mobile.value;
const mv = mobile.value;
const m = mv != null && mv != "" ? mv : "";
const smsCode = code.value;
const remember = noSignIn.value;
const agreed = readingStatus.value;
......
......@@ -402,20 +402,28 @@
labelToIdMap.value = next
}
async function loadTagListFromApi(): Promise<void> {
/**
* 拉取标签列表
* @returns 0=成功且有数据;1=成功但无数据;2=失败(接口异常/返回码异常)
*/
async function loadTagListFromApi(): Promise<number> {
try {
const params = { scene: props.scene } as UTSJSONObject
const res = await findCustomerTags(params)
console.log("[loadTagListFromApi] res", res);
const resObj = res as UTSJSONObject
const code = resObj['code']
if (code != null && `${code}` != '0') {
tagGroups.value = []
return
return 2
}
tagGroups.value = parseTagGroupsFromResponse(res)
const groups = parseTagGroupsFromResponse(res)
tagGroups.value = groups
return groups.length > 0 ? 0 : 1
} catch (e) {
console.error('findCustomerTags 失败:', e)
tagGroups.value = []
return 2
}
}
......@@ -541,7 +549,15 @@
async function open(): Promise<void> {
updateSheetPanelHeight()
initSelectionFromEcho()
await loadTagListFromApi()
const loadRes = await loadTagListFromApi()
if (loadRes != 0) {
if (loadRes == 1) {
uni.showToast({ title: '暂无可选客户标签', icon: 'none' })
} else {
uni.showToast({ title: '获取客户标签失败,请稍后重试', icon: 'none' })
}
return
}
fillIdsFromLoadedTags()
nextTick(() => {
nextTick(() => {
......@@ -608,10 +624,10 @@
}
.section-title {
font-size: 14px;
font-size: 16px;
color: #666666;
font-weight: 700;
margin-bottom: 10px;
margin-bottom: 12px;
text-align: left;
}
......@@ -623,16 +639,16 @@
}
.tag-item {
padding-left: 12px;
padding-right: 12px;
padding-top: 6px;
padding-bottom: 6px;
margin-right: 10px;
margin-bottom: 10px;
padding-left: 14px;
padding-right: 14px;
padding-top: 8px;
padding-bottom: 8px;
margin-right: 12px;
margin-bottom: 12px;
border-width: 1px;
border-style: solid;
border-color: rgba(0, 0, 0, 0.05);
border-radius: 14px;
border-radius: 16px;
background-color: #f8f9fa;
flex-direction: row;
align-items: center;
......@@ -647,7 +663,7 @@
}
.tag-text {
font-size: 13px;
font-size: 15px;
color: #495057;
text-align: center;
font-weight: 400;
......@@ -658,6 +674,6 @@
.tag-item.checked .tag-text {
color: #1677FF;
font-weight: 500;
font-weight: 700;
}
</style>
<template>
<view class="customer-list-panel">
<!-- 筛选区 -->
<view class="filter-bar">
<un-segmented
type="card"
bg-color="rgba(241, 245, 249, 0.5)"
:height="40"
active-color="#000000"
:model-value="entryFilterIndex"
@update:model-value="$emit('switchEntryFilter', $event)"
>
<un-segmented-item text="今日到店"></un-segmented-item>
<un-segmented-item text="全部客户"></un-segmented-item>
</un-segmented>
<un-button
text="预录信息"
icon="plus"
type="primary"
size="small"
@click="$emit('customerEntryClick')"
/>
</view>
<!-- list-view:App 端隐藏滚动条比 scroll-view 更可靠(与 FormDetail 一致) -->
<list-view
class="list-scroll"
direction="vertical"
:bounces="true"
:show-scrollbar="false"
:lower-threshold="120"
@scrolltolower="onScrollToLower"
>
<list-item class="customer-panel-li" :type="0">
<view class="customer-panel-scroll-block">
<view v-if="showEmpty" class="empty-wrap">
<CustomEmpty type="base" title="暂无客户记录" />
</view>
<view v-if="!showEmpty" class="list-container">
<ListCustomer
:customer-list="customerList"
:entry-filter-index="entryFilterIndex"
@entry-click="(item) => $emit('entryClick', item)"
@entry-edit="(item) => $emit('entryEdit', item)"
@entry-delete="(item) => $emit('entryDelete', item)"
/>
</view>
<view class="list-footer">
<text v-if="loadingMore" class="footer-text">加载中...</text>
<text v-else-if="!hasMore && customerList.length > 0" class="footer-text">- 已经到底了 -</text>
</view>
</view>
</list-item>
</list-view>
</view>
</template>
<script setup lang="uts">
import CustomEmpty from '@/components/CustomEmpty/index.uvue'
import ListCustomer from '../lists/ListCustomer.uvue'
const props = defineProps<{
customerList: UTSJSONObject[]
entryFilterIndex: number
showEmpty: boolean
loadingMore: boolean
hasMore: boolean
}>()
defineEmits<{
entryClick: [item: UTSJSONObject]
entryEdit: [item: UTSJSONObject]
entryDelete: [item: UTSJSONObject]
switchEntryFilter: [index: number]
customerEntryClick: []
}>()
function onScrollToLower(): void {
if (props.hasMore && !props.loadingMore) {
// 由父组件处理加载逻辑
}
}
</script>
<style lang="scss" scoped>
.customer-list-panel {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
}
.filter-bar {
padding: 12px 16px;
background-color: #ffffff;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
border-bottom: 1px solid #e2e8f0;
}
.list-scroll {
flex: 1;
min-height: 0;
width: 100%;
}
.customer-panel-li {
width: 100%;
margin: 0;
box-sizing: border-box;
height: auto;
min-height: 0;
align-self: flex-start;
flex-grow: 0;
flex-shrink: 0;
}
.customer-panel-scroll-block {
flex-direction: column;
width: 100%;
}
.empty-wrap {
padding: 80px 24px;
}
.list-container {
padding: 12px;
}
.list-footer {
padding: 16px;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
}
.footer-text {
font-size: 12px;
color: #94A3B8;
}
</style>
<template>
<view class="dashboard-panel">
<scroll-view class="dashboard-scroll" scroll-y>
<!-- 头部控制区 -->
<view class="dashboard-header">
<view class="header-row">
<view class="title-box">
<text class="dashboard-title">业绩看板</text>
<view class="eye-btn" @click="$emit('toggleMetrics')">
<un-icon v-if="metricsVisible" name="eye" color="#333333" size="24"></un-icon>
<un-icon v-if="!metricsVisible" name="eye-off" color="#2979ff" size="24"></un-icon>
</view>
</view>
<view class="brand-tag" @click="$emit('brandSelect')">
<text class="brand-text">{{ selectedBrand }}</text>
<image class="arrow-icon" src="/static/images/reception/icon-select-arrow.png" mode="aspectFit" />
</view>
</view>
<!-- 时间进度条 -->
<view class="progress-section">
<text class="progress-label">时间进度</text>
<view class="progress-bar-bg">
<view class="progress-bar-fill" :style="{ width: timeProgressPercent + '%' }"></view>
</view>
<text class="progress-value">{{ metricsVisible ? timeProgressPercent + '%' : '**' }}</text>
</view>
</view>
<!-- 业务流卡片 -->
<CardFlow :performance-data="performanceData" :metrics-visible="metricsVisible" />
<!-- 产值卡片 -->
<CardOutputValue v-model:tab-index="outputTabIndex" :compare-rows="compareRows" :metrics-visible="metricsVisible" />
<!-- 本月产值卡片 -->
<CardMonthValue
:summary="summary"
:target-value-text="monthValueTargetText"
:achievement-value-text="monthValueAchievementText"
:metrics-visible="metricsVisible"
/>
</scroll-view>
</view>
</template>
<script setup lang="uts">
import { ref, computed } from 'vue'
import CardFlow from '../cards/CardFlow.uvue'
import CardOutputValue from '../cards/CardOutputValue.uvue'
import CardMonthValue from '../cards/CardMonthValue.uvue'
defineProps<{
performanceData: UTSJSONObject
metricsVisible: boolean
selectedBrand: string
selectedBrandValue: number
}>()
defineEmits<{
brandSelect: []
toggleMetrics: []
brandChange: [brand: string, brandValue: number]
}>()
const outputTabIndex = ref(0)
// 时间进度计算
const timeProgress = ref<number>(new Date().getDate())
const timeProgressPercent = computed((): number => {
const now = new Date()
const monthDays = new Date(now.getFullYear(), now.getMonth() + 1, 0).getDate()
const percent = monthDays > 0 ? Math.round(timeProgress.value / monthDays * 100) : 0
return percent < 0 ? 0 : (percent > 100 ? 100 : percent)
})
// 产值卡片数据
const compareRows = computed(() => {
const d = props.performanceData
const idx = outputTabIndex.value
if (idx == 0) {
// 转化率 Tab
return [
{ label: '优秀门店均值', barWidthPercent: `${Math.min(100, getNum(d, 'excellentStoreAvgDealRate'))}%`, barClass: 'bg-blue-500', value: getNum(d, 'excellentStoreAvgDealRate').toFixed(1) + '%' },
{ label: '本门店', barWidthPercent: `${Math.min(100, getNum(d, 'thisStoreDealRate'))}%`, barClass: 'bg-blue-400', value: getNum(d, 'thisStoreDealRate').toFixed(1) + '%' },
{ label: '个人', barWidthPercent: `${Math.min(100, getNum(d, 'personalDealRate'))}%`, barClass: 'bg-blue-400', value: getNum(d, 'personalDealRate').toFixed(1) + '%' }
]
} else {
// 客单价 Tab
const eAvg = getNum(d, 'excellentStoreAvgDeal')
const thisVal = getNum(d, 'thisStoreKdj')
const perVal = getNum(d, 'personalKdj')
const maxDeal = Math.max(eAvg, thisVal, perVal)
return [
{ label: '优秀门店均值', barWidthPercent: `${maxDeal > 0 ? (eAvg / maxDeal * 100) : 0}%`, barClass: 'bg-blue-500', value: '¥' + Math.round(eAvg) },
{ label: '本门店', barWidthPercent: `${maxDeal > 0 ? (thisVal / maxDeal * 100) : 0}%`, barClass: 'bg-blue-400', value: '¥' + Math.round(thisVal) },
{ label: '个人', barWidthPercent: `${maxDeal > 0 ? (perVal / maxDeal * 100) : 0}%`, barClass: 'bg-blue-400', value: '¥' + Math.round(perVal) }
]
}
})
const summary = computed(() => {
const d = props.performanceData
return {
summaryLabel: '实际产值',
summaryValueNum: getNum(d, 'actualProduction').toFixed(1),
summaryValueUnit: '万',
personalLabel: '个人产值',
personalValue: getNum(d, 'personalProduction').toFixed(1) + '万',
ringPercent: getNum(d, 'achievementRatio').toFixed(1) + '%',
ringLabel: '达成率',
ringPercentNum: Math.min(100, getNum(d, 'achievementRatio')),
ringComparePercent: 100
}
})
const monthValueTargetText = computed(() => {
const d = props.performanceData
const v = getNum(d, 'targetProduction')
return v > 0 ? v.toFixed(0) + '万' : '-'
})
const monthValueAchievementText = computed(() => {
const d = props.performanceData
const v = getNum(d, 'productionContribution')
return v > 0 ? v.toFixed(0) + '%' : '-'
})
function getNum(data: UTSJSONObject, key: string): number {
const v = data[key]
if (v == null) return 0
if (typeof v == 'number') return v
const n = parseFloat(`${v}`)
return isNaN(n) ? 0 : n
}
</script>
<style lang="scss" scoped>
.dashboard-panel {
width: 100%;
height: 100%;
}
.dashboard-scroll {
width: 100%;
height: 100%;
}
.dashboard-header {
padding: 16px;
background-color: #ffffff;
margin-bottom: 12px;
}
.header-row {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
margin-bottom: 12px;
}
.title-box {
display: flex;
flex-direction: row;
align-items: center;
}
.dashboard-title {
font-size: 18px;
font-weight: bold;
color: #1E293B;
}
.eye-btn {
margin-left: 8px;
padding: 4px;
}
.brand-tag {
background-color: rgba(255, 255, 255, 0.5);
padding: 6px 12px;
border-radius: 999px;
border: 1px solid rgba(226, 232, 240, 1);
display: flex;
flex-direction: row;
align-items: center;
}
.brand-text {
font-size: 13px;
color: #333333;
}
.arrow-icon {
width: 16px;
height: 16px;
margin-left: 4px;
}
.progress-section {
display: flex;
flex-direction: row;
align-items: center;
}
.progress-label {
font-size: 12px;
color: #94A3B8;
margin-right: 8px;
}
.progress-bar-bg {
flex: 1;
height: 6px;
background-color: rgba(255, 255, 255, 0.5);
border-radius: 999px;
overflow: hidden;
}
.progress-bar-fill {
height: 100%;
background-color: #3B82F6;
border-radius: 999px;
transition: width 0.3s ease;
}
.progress-value {
font-size: 12px;
color: #94A3B8;
margin-left: 8px;
min-width: 40px;
text-align: right;
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!