Files
weicw-dshsa 2ff8d42207 fix(自主填报): 修正重提跳转按填报类型、补 wx:key 并清理废弃 API 调用
一、填报记录「重新提交」跳错表单(用户反馈)

records.vue 原先按 activeType(当前 tab)决定跳驻店还是跑店表单,
但列表请求无守卫:切 tab 会连发请求且响应顺序不保证,
旧响应回来会盖掉当前 tab 的数据,导致 tab 与实际数据错位。
此时点「重新提交」会拿 A 表的 id 去打开 B 表的表单
(两表 id 各自从 1 开始,撞号常见,故不报错、只静默进错页面)。

改法:把填报类型钉在记录上,而不是靠 tab 状态猜
- fetchList 拉到数据后给每条记录打 reportType
- 新增 recordType(item):优先取记录自带类型,异常数据回退当前 tab
- 归一化、筛选、卡片标题/副标题、展开详情形态、重新提交跳转全部改走它
- 列表请求加自增 listRequestId 守卫,丢弃过期响应(loading 同理)

二、visit.vue 缺 wx:key 告警

小程序 wx:key 只接受简单属性路径,模板字面量写法
(:key="`store-${idx}`")会被编译器静默丢弃,四处循环因此无 key。
按项目既有 _rowKey 模式改:
- 巡店列表 :key="item._rowKey",新增 buildStoreKey/ensureStoreKeys
  (重提与草稿的旧数据无该字段,加载时补齐;提交走显式白名单,不外泄)
- 照片 :key="photo",两个 picker :key="item.id"

三、getSystemInfoSync 废弃告警

该调用在 AppNavbar 的 render(getSafeTop)里,每渲染一次告警一次。
改为挂载时取一次并缓存,优先用新接口 uni.getWindowInfo,
取不到再回退旧接口;select.vue 同源调用一并处理。

注:uview 组件库内部 u-overlay/u-popup 的 mode 传 null 告警
(u-popup 的 position computed 无 else 分支)未改,
uni_modules 已被 gitignore 且会被依赖重装覆盖,属组件库问题。
2026-10-12 13:47:03 +08:00

143 lines
3.1 KiB
Vue

<template>
<view class="app-navbar" :style="{'padding-top': `${getSafeTop()}px`, 'padding-bottom': '40px'}">
<view class="navbar-left" :style="{top: `${getSafeTop()}px`}" v-if="showBack" @click="back">
<u-icon name="arrow-left" color="white" size="40rpx" v-if="currentPages.length > 1"/>
<u-icon name="home" color="white" size="40rpx" v-else/>
</view>
<text class="navbar-title" :style="{ fontSize: titleSize }">{{ title }}</text>
</view>
</template>
<script>
export default {
props: {
title: {
type: String,
default: ''
},
titleSize: {
type: String,
default: '34rpx'
},
showBack: {
type: Boolean,
default: false
}
},
data() {
return {
currentPages: [],
// 状态栏高度只在挂载时取一次:getSafeTop 在 render 中被调用,
// 每次都同步读系统信息会反复触发 wx.getSystemInfoSync 废弃告警。
safeTop: 0
}
},
methods: {
getSafeTop() {
return this.safeTop
},
back(){
if (this.currentPages.length === 1) uni.switchTab({url: '/pages/index/index'})
else uni.navigateBack()
},
// 优先用新接口,取不到时回退旧接口,避免旧接口的废弃告警
readSafeTop() {
try {
if (uni.getWindowInfo) {
const info = uni.getWindowInfo()
if (info && info.statusBarHeight !== undefined) return info.statusBarHeight
}
} catch (error) {
// ignore:新接口不可用时走下面的回退
}
try {
const systemInfo = uni.getSystemInfoSync()
return (systemInfo && systemInfo.statusBarHeight) || 0
} catch (error) {
return 0
}
}
},
mounted() {
this.currentPages = getCurrentPages()
this.safeTop = this.readSafeTop()
}
}
</script>
<style lang="scss" scoped>
.app-navbar {
position: relative;
display: flex;
align-items: center;
justify-content: center;
padding: 0 10rpx;
min-height: 56rpx;
background: url('https://yaodongxiao.oss-cn-guangzhou.aliyuncs.com/20260126/202ad055d8706f14cd94fae4a8bbc14c.png') no-repeat center/cover;
}
.navbar-left {
width: 50rpx;
height: 50rpx;
display: flex;
align-items: center;
justify-content: center;
position: absolute;
left: 20rpx;
background-color: rgba(0, 0, 0, 0.5);
border-radius: 999rpx;
}
.navbar-right {
display: flex;
align-items: center;
}
.navbar-title {
position: absolute;
left: 50%;
transform: translateX(-50%);
font-size: 34rpx;
font-weight: 700;
color: #111827;
letter-spacing: 2rpx;
}
.navbar-capsule {
display: flex;
align-items: center;
gap: 12rpx;
height: 52rpx;
padding: 0 16rpx;
background: #ffffff;
border-radius: 999rpx;
box-shadow: 0 8rpx 16rpx rgba(0, 0, 0, 0.08);
}
.capsule-dots {
display: flex;
gap: 6rpx;
}
.capsule-dot {
width: 8rpx;
height: 8rpx;
border-radius: 50%;
background: #111827;
}
.capsule-divider {
width: 1rpx;
height: 24rpx;
background: #d1d5db;
}
.capsule-ring {
width: 26rpx;
height: 26rpx;
border-radius: 50%;
border: 3rpx solid #111827;
}
</style>