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());