fix: 完善记录错误状态与缓存失效策略

This commit is contained in:
que01 committed 2026-10-15 13:58:39 +08:00
1 parent 476e3d93dd
commit 8973338c64
13 files changed
+53 -29

No files matched your search

@@ -1,6 +1,7 @@
Component({
properties: {
records: { type: Array, value: [] },
loadError: { type: String, value: "" },
presentation: { type: Object, value: {} },
},
methods: {
@@ -1 +1 @@
<view class="records"><view wx:if="{{!records.length}}" class="empty"><text class="empty-title">{{presentation.emptyTitle}}</text><text>{{presentation.emptyDescription}}</text><button bindtap="create">{{presentation.emptyAction}}</button></view><view wx:else><view class="record" wx:for="{{records}}" wx:key="id"><view class="record-head"><text>{{item.type}}</text><text class="status">{{item.status}}</text></view><text class="project">{{item.project}} · {{item.offeringName}}</text><text class="meta">档案编号 {{item.id}} {{item.createdAt}}</text><view wx:if="{{item.timeline.length}}" class="timeline"><view wx:for="{{item.timeline}}" wx:key="createdAt" class="timeline-item"><text class="timeline-dot">●</text><text>{{item.status}} · {{item.createdAt}}</text></view></view></view></view></view>
<view class="records"><view wx:if="{{loadError}}" class="empty"><text class="empty-title">记录加载失败</text><text>{{loadError}}</text></view><view wx:elif="{{!records.length}}" class="empty"><text class="empty-title">{{presentation.emptyTitle}}</text><text>{{presentation.emptyDescription}}</text><button bindtap="create">{{presentation.emptyAction}}</button></view><view wx:else><view class="record" wx:for="{{records}}" wx:key="id"><view class="record-head"><text>{{item.type}}</text><text class="status">{{item.status}}</text></view><text class="project">{{item.project}} · {{item.offeringName}}</text><text class="meta">档案编号 {{item.id}} {{item.createdAt}}</text><view wx:if="{{item.timeline.length}}" class="timeline"><view wx:for="{{item.timeline}}" wx:key="createdAt" class="timeline-item"><text class="timeline-dot">●</text><text>{{item.status}} · {{item.createdAt}}</text></view></view></view></view></view>
+5 -5
View File
@@ -12,7 +12,7 @@ const statusLabels = {
};
Page({
data: { records: [], loading: false, presentation: {} },
data: { records: [], loading: false, loadError: "", presentation: {} },
onLoad() {
loadWorkspaceWithFallback()
.then((workspace) =>
@@ -21,12 +21,13 @@ Page({
.catch(() => {});
},
onShow() {
if (!wx.getStorageSync(customerTokenKey())) return this.setData({ records: [] });
this.setData({ loading: true });
if (!wx.getStorageSync(customerTokenKey())) return this.setData({ records: [], loadError: "" });
this.setData({ loading: true, loadError: "" });
customerRequest("/customer/inquiry-submissions")
.then((items) =>
this.setData({
loading: false,
loadError: "",
records: items.map((item) => ({
...item,
type: item.inquiryForm?.name || "品牌咨询",
@@ -42,8 +43,7 @@ Page({
}),
)
.catch((error) => {
this.setData({ loading: false });
wx.showToast({ title: error.message || "记录加载失败", icon: "none" });
this.setData({ loading: false, loadError: error.message || "记录加载失败" });
});
},
inquire() {
+1 -1
View File
@@ -1 +1 @@
<view class="page"><view class="head"><text class="title">{{presentation.title}}</text><button bindtap="inquire">{{presentation.createAction}}</button></view><records-module records="{{records}}" presentation="{{presentation}}" bind:create="inquire" /></view>
<view class="page"><view class="head"><text class="title">{{presentation.title}}</text><button bindtap="inquire">{{presentation.createAction}}</button></view><records-module records="{{records}}" load-error="{{loadError}}" presentation="{{presentation}}" bind:create="inquire" /></view>