apply Network.ts
This commit is contained in:
@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user