fix: 完善记录错误状态与缓存失效策略
This commit is contained in:
1 parent
476e3d93dd
commit
8973338c64
13 files changed
+53
-29
No files matched your search
@@ -2,7 +2,7 @@ const { loadWorkspaceWithFallback } = require("../../utils/runtime-workspace");
|
||||
const { customerRequest, customerTokenKey } = require("../../utils/request");
|
||||
|
||||
Page({
|
||||
data: { brand: {}, records: [], error: "" },
|
||||
data: { brand: {}, records: [], error: "", recordsError: "" },
|
||||
onLoad() {
|
||||
loadWorkspaceWithFallback()
|
||||
.then((workspace) =>
|
||||
@@ -17,10 +17,15 @@ Page({
|
||||
this.loadRecords();
|
||||
},
|
||||
loadRecords() {
|
||||
if (!wx.getStorageSync(customerTokenKey())) return this.setData({ records: [] });
|
||||
if (!wx.getStorageSync(customerTokenKey()))
|
||||
return this.setData({ records: [], recordsError: "" });
|
||||
customerRequest("/customer/inquiry-submissions")
|
||||
.then((records) => this.setData({ records: Array.isArray(records) ? records : [] }))
|
||||
.catch(() => this.setData({ records: [] }));
|
||||
.then((records) =>
|
||||
this.setData({ records: Array.isArray(records) ? records : [], recordsError: "" }),
|
||||
)
|
||||
.catch((error) =>
|
||||
this.setData({ recordsError: error.message || "记录加载失败,请稍后重试" }),
|
||||
);
|
||||
},
|
||||
call() {
|
||||
wx.makePhoneCall({
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<view class="page">
|
||||
<view wx:if="{{error}}" class="runtime-error">{{error}}</view>
|
||||
<view wx:if="{{recordsError}}" class="runtime-error">{{recordsError}}</view>
|
||||
<view wx:elif="{{error}}" class="runtime-error">{{error}}</view>
|
||||
<linjing-profile wx:else brand="{{brand}}" trust-items="{{trustItems}}" presentation="{{brand.visualPresentation.profile}}" records-count="{{records.length}}" bind:call="call" bind:copy="copyWechat" bind:records="recordsPage" />
|
||||
</view>
|
||||
Reference in new issue
Block a user