apply Network.ts

This commit is contained in:
Timi
2025-12-17 16:56:33 +08:00
parent 369cfe2bf2
commit 62186abdb8
13 changed files with 584 additions and 696 deletions

View File

@ -1,9 +1,10 @@
// pages/main/journal-map/index.ts
import config from "../../../config/index";
import Time from "../../../utils/Time";
import { Journal, JournalPageType } from "../../../types/Journal";
import { JournalPageType } from "../../../types/Journal";
import Toolkit from "../../../utils/Toolkit";
import { MapMarker } from "../../../types/UI";
import { JournalApi } from "../../../api/JournalApi";
interface LocationMarker {
locationKey: string; // 位置键 "lat,lng"
@ -50,28 +51,12 @@ Page({
async loadJournals() {
this.setData({ isLoading: true });
try {
const list: Journal[] = await new Promise((resolve, reject) => {
wx.request({
url: `${config.url}/journal/list`,
method: "POST",
header: {
Key: wx.getStorageSync("key")
},
data: {
page: 0,
size: 9007199254740992,
type: JournalPageType.PREVIEW
},
success: (resp: any) => {
if (resp.data.code === 20000) {
resolve(resp.data.data.list);
} else {
reject(new Error(resp.data.message || "加载失败"));
}
},
fail: reject
});
}) || [];
const result = await JournalApi.getList({
index: 0,
size: 9007199254740992,
type: JournalPageType.PREVIEW
});
const list = result.list || [];
// 过滤有位置信息的记录,并按位置分组
const locationMap = new Map<string, LocationMarker>();
list.filter((journal: any) => journal.lat && journal.lng).forEach((journal: any) => {