From ad5ceca2a52d68308c2a2e696d9030a40c3a9c8f Mon Sep 17 00:00:00 2001 From: "fuqihao.foliet" Date: Thu, 14 Dec 2023 21:07:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=88=86=E4=BA=AB=E8=87=B3=E6=9C=8B?= =?UTF-8?q?=E5=8F=8B=E5=9C=88=E6=97=B6=E5=8F=AF=E4=BB=A5=E6=AD=A3=E7=A1=AE?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=86=85=E5=AE=B9=EF=BC=8C=E8=8C=83=E5=9B=B4?= =?UTF-8?q?=E4=B8=BA=E6=89=80=E6=9C=89=E7=A4=BE=E5=8C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/plan/plan-interfaces.ts | 2 +- src/components/SchoolSelectBar.vue | 4 ++-- src/pages/community/community.vue | 14 ++++++++------ src/pages/community/utils.ts | 7 ++++--- src/pages/plan/PlanEntries.vue | 13 ++++++++----- src/utils/init.ts | 2 +- 6 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/apis/plan/plan-interfaces.ts b/src/apis/plan/plan-interfaces.ts index 8dc6eb40..ba183258 100644 --- a/src/apis/plan/plan-interfaces.ts +++ b/src/apis/plan/plan-interfaces.ts @@ -26,7 +26,7 @@ export interface GetPlanPreviewsReq { limit?: number; onlyUserId?: string; page: number; - [property: string]: any; + onlyCommunityId?: string; } export interface GetPlanPreviewsResp { diff --git a/src/components/SchoolSelectBar.vue b/src/components/SchoolSelectBar.vue index 9c243300..13aed299 100644 --- a/src/components/SchoolSelectBar.vue +++ b/src/components/SchoolSelectBar.vue @@ -3,9 +3,9 @@ {{ - currentSchool !== currentCampus + (currentSchool !== currentCampus ? currentSchool + currentCampus - : currentSchool + : currentSchool) || "MeowChat大家庭" }} diff --git a/src/pages/community/community.vue b/src/pages/community/community.vue index f9278f48..d3183fb8 100644 --- a/src/pages/community/community.vue +++ b/src/pages/community/community.vue @@ -94,12 +94,14 @@ onLoad(() => { onReady(() => { uni.hideLoading(); //签到获取小鱼干 - userCheckIn().then((res) => { - if (res.getFish) { - gottenFishAmount.value = res.getFishNum; - showToastBox.value = true; - } - }); + if (uni.getStorageSync(StorageKeys.UserId)) { + userCheckIn().then((res) => { + if (res.getFish) { + gottenFishAmount.value = res.getFishNum; + showToastBox.value = true; + } + }); + } }); onShow(() => { diff --git a/src/pages/community/utils.ts b/src/pages/community/utils.ts index 39a1f2a1..1ff39f61 100644 --- a/src/pages/community/utils.ts +++ b/src/pages/community/utils.ts @@ -8,9 +8,10 @@ export function buildLoader(keyword?: string) { const communityId = uni.getStorageSync(StorageKeys.CommunityId); const fetch = async () => { - const req: GetMomentPreviewsReq = { - communityId: communityId - }; + const req: GetMomentPreviewsReq = {}; + if (communityId) { + req.communityId = communityId; + } if (lastToken) { req.lastToken = lastToken; } diff --git a/src/pages/plan/PlanEntries.vue b/src/pages/plan/PlanEntries.vue index c01aea55..60ff909c 100644 --- a/src/pages/plan/PlanEntries.vue +++ b/src/pages/plan/PlanEntries.vue @@ -10,10 +10,13 @@ import PlanEntry from "@/pages/plan/PlanEntry.vue"; import { ref, reactive } from "vue"; import { onReachBottom } from "@dcloudio/uni-app"; import { StorageKeys } from "@/utils/const"; +const communityId = uni.getStorageSync(StorageKeys.CommunityId); const getPlanPreviewsReq = reactive({ - page: 0, - onlyCommunityId: uni.getStorageSync(StorageKeys.CommunityId) + page: 0 }); +if (communityId) { + getPlanPreviewsReq.onlyCommunityId = communityId; +} let allPreviewsLoaded = false; let isPreviewsLoaded = true; @@ -23,12 +26,12 @@ const plans = ref([]); const localGetPlanPreviews = async () => { let res = await getPlanPreviews(getPlanPreviewsReq); isPreviewsLoaded = false; - for (let i = 0; i < res?.total; i++) { - plans.value.push(res.plans[i]); + for (const plan of res.plans) { + plans.value.push(plan); } isPreviewsLoaded = true; getPlanPreviewsReq.page += 1; - if (res?.total < 10) { + if (res.plans.length) { allPreviewsLoaded = true; } }; diff --git a/src/utils/init.ts b/src/utils/init.ts index f89f7ff3..63d22905 100644 --- a/src/utils/init.ts +++ b/src/utils/init.ts @@ -15,7 +15,7 @@ export async function init() { const tasks: Promise[] = []; // 距离token过期不到一天时重新获取token const expireTime = uni.getStorageSync(StorageKeys.AccessToken).expireTime; - if (!expireTime || expireTime - new Date().getTime() / 1000 < 86400) { + if (!expireTime || expireTime - new Date().getTime() / 1000 < 7 * 86400) { tasks.push(refreshToken(accountInfo.appId)); } tasks.push(checkCommunityId());