diff --git a/src/apis/like/like-interface.ts b/src/apis/like/like-interface.ts index ce9a18e8..6328507f 100644 --- a/src/apis/like/like-interface.ts +++ b/src/apis/like/like-interface.ts @@ -1,4 +1,4 @@ -import { TargetType } from "@/apis/schemas"; +import { Comment, Moment, Post, TargetType, User } from "@/apis/schemas"; export interface DoLikeReq { targetId: string; @@ -33,18 +33,22 @@ export interface GetCountResp { count: number; } -export interface GetUserLikesReq { +export interface GetLikeContentsReq { userId?: string; targetType: TargetType; + lastToken?: string; + limit?: number; + backward?: boolean; + page?: number; } -export interface GetUserLikesResp { +export interface GetLikeContentsResp { code: number; - likes: Like[]; msg: string; -} - -export interface Like { - associatedId: string; - targetId: string; + posts: Post[]; + moments: Moment[]; + users: User[]; + comments: Comment[]; + total: number; + token: string; } diff --git a/src/apis/like/like.ts b/src/apis/like/like.ts index 4df56c4c..d4dd1f48 100644 --- a/src/apis/like/like.ts +++ b/src/apis/like/like.ts @@ -5,8 +5,8 @@ import { GetCountResp, GetUserLikedReq, GetUserLikedResp, - GetUserLikesReq, - GetUserLikesResp + GetLikeContentsReq, + GetLikeContentsResp } from "@/apis/like/like-interface"; /** @@ -75,22 +75,17 @@ export async function getCount(req: GetCountReq) { }); } -/** - * @description - * 获取点赞内容 - * @param req - */ -export async function getUserLikes(req: GetUserLikesReq) { - return await new Promise((resolve, reject) => { +export async function getLikeContents(req: GetLikeContentsReq) { + return await new Promise((resolve, reject) => { uni.request({ - url: "/like/get_user_likes", + url: "/like/get_user_like_contents", data: req, method: "GET", success(res: UniNamespace.RequestSuccessCallbackResult) { if (res.statusCode !== 200) { reject(res); } - const data = res.data as GetUserLikesResp; + const data = res.data as GetLikeContentsResp; resolve(data); } }); diff --git a/src/apis/moment/moment.ts b/src/apis/moment/moment.ts index 87a3b3ad..0ceaa383 100644 --- a/src/apis/moment/moment.ts +++ b/src/apis/moment/moment.ts @@ -45,7 +45,6 @@ export async function newMoment(req: NewMomentReq): Promise { method: "POST", success(res: UniNamespace.RequestSuccessCallbackResult) { if (res.statusCode !== 200) { - console.log("here", res); reject(res); } const data = res.data as NewMomentResp; diff --git a/src/apis/plan/plan-interfaces.ts b/src/apis/plan/plan-interfaces.ts index 8a97dd82..419fd413 100644 --- a/src/apis/plan/plan-interfaces.ts +++ b/src/apis/plan/plan-interfaces.ts @@ -1,4 +1,4 @@ -import { Plan, PlanType, User } from "../schemas"; +import { Plan, PlanPreview, PlanType, User } from "../schemas"; export interface DeletePlanReq { planId: string; @@ -70,27 +70,24 @@ export interface GetUserFishResp { export interface DonateFishReq { fish?: number; planId?: string; - [property: string]: any; } export interface GetUserDonateCountReq { userId?: string; - [property: string]: any; } export interface GetUserDonateCountResp { - total: string; - [property: string]: any; + total: number; } export interface ListDonateByUserReq { - limit: 999; - page: 0; - [property: string]: any; + page?: number; + lastToken?: string; + limit?: number; + userId?: string; } export interface ListDonateByUserResp { total: number; token: string; - planPreviews: object; - [property: string]: any; + planPreviews: PlanPreview[]; } diff --git a/src/apis/plan/plan.ts b/src/apis/plan/plan.ts index 5340be1e..119601ec 100644 --- a/src/apis/plan/plan.ts +++ b/src/apis/plan/plan.ts @@ -6,6 +6,7 @@ import { GetPlanPreviewsReq, GetPlanPreviewsResp, GetUserDonateCountReq, + GetUserDonateCountResp, GetUserFishReq, GetUserFishResp, ListDonateByUserReq, @@ -135,7 +136,7 @@ export async function donateFish(req: DonateFishReq) { } export async function getCountDonate(req: GetUserDonateCountReq) { - return await new Promise((resolve, reject) => { + return await new Promise((resolve, reject) => { uni.request({ url: "/plan/count_donate_by_user", data: req, @@ -144,14 +145,14 @@ export async function getCountDonate(req: GetUserDonateCountReq) { if (res.statusCode !== 200) { reject(res); } - const data = res.data as GetUserDonateCountReq; + const data = res.data as GetUserDonateCountResp; resolve(data); } }); }); } -export async function list_donate_by_user(req: ListDonateByUserReq) { +export async function ListDonateByUser(req: ListDonateByUserReq) { return await new Promise((resolve, reject) => { uni.request({ url: "/plan/list_donate_by_user", diff --git a/src/apis/schemas.ts b/src/apis/schemas.ts index a6f3ceaf..a129cc4e 100644 --- a/src/apis/schemas.ts +++ b/src/apis/schemas.ts @@ -17,11 +17,10 @@ export interface User { id: string; nickname: string; avatarUrl: string; - motto: string; - article: number; - follower: number; - following: number; - enableDebug?: boolean; + motto?: string; + article?: number; + follower?: number; + following?: number; } export interface Auth { @@ -178,13 +177,13 @@ export interface Plan { summary: string; [property: string]: any; } -export interface planpreviews { +export interface PlanPreview { id: string; name: string; catName: string; donateNum: number; donateTime: number; - [property: string]: any; + coverUrl: string; } export const enum TargetType { Post = 1, diff --git a/src/components/BottomBar/BottomBarContent.vue b/src/components/BottomBar/BottomBarContent.vue index 07a3f0a3..e3901945 100644 --- a/src/components/BottomBar/BottomBarContent.vue +++ b/src/components/BottomBar/BottomBarContent.vue @@ -101,7 +101,6 @@ const tabChange = (path: string) => { left: 0; bottom: 0; width: 100%; - z-index: 200; background: #fdfdfd; box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2), 0 3px 10px 0 rgba(0, 0, 0, 0.19); height: 18vw; diff --git a/src/components/SchoolSelectBar.vue b/src/components/SchoolSelectBar.vue index f34dd245..5be2373c 100644 --- a/src/components/SchoolSelectBar.vue +++ b/src/components/SchoolSelectBar.vue @@ -14,8 +14,7 @@ diff --git a/src/pages/community/Carousel.vue b/src/pages/community/Carousel.vue index 266967a1..186554b2 100644 --- a/src/pages/community/Carousel.vue +++ b/src/pages/community/Carousel.vue @@ -25,7 +25,7 @@ - - diff --git a/src/pages/community/community.vue b/src/pages/community/community.vue index 9233c183..157e3bc0 100644 --- a/src/pages/community/community.vue +++ b/src/pages/community/community.vue @@ -28,7 +28,7 @@ - + @@ -53,7 +53,6 @@ import BottomBar from "@/components/BottomBar.vue"; import { nextTick, reactive, ref } from "vue"; import TopBar from "@/components/TopBar.vue"; import SchoolSelectBar from "@/components/SchoolSelectBar.vue"; -import MasonryFrame from "@/pages/community/MasonryFrame.vue"; import Cards from "@/pages/community/cards/cards.vue"; import CarouselFrame from "@/pages/community/CarouselFrame.vue"; import { onLoad, onPullDownRefresh, onReady, onShow } from "@dcloudio/uni-app"; @@ -61,6 +60,8 @@ import { StorageKeys } from "@/utils/const"; import { needChooseCommunity } from "@/utils/init"; import { Pages } from "@/utils/url"; import ToastBoxWithShadow from "@/components/ToastBoxWithShadow.vue"; +import { buildLoader } from "@/pages/community/utils"; +import Masonry from "@/pages/community/Masonry.vue"; const communityId = ref(uni.getStorageSync(StorageKeys.CommunityId)); const cardList = reactive(["", "", "", "", "", ""]); diff --git a/src/pages/community/event.ts b/src/pages/community/event.ts index aa8f59bc..7f6d964e 100644 --- a/src/pages/community/event.ts +++ b/src/pages/community/event.ts @@ -1,7 +1,26 @@ import { Pages } from "@/utils/url"; +import { News } from "@/apis/schemas"; export function onClickMessage() { uni.navigateTo({ url: Pages.Message }); } + +export function onClickCarousel(c: News) { + if (c.type === "inner") { + uni.navigateTo({ + url: c.linkUrl + }); + } else if (c.type === "article") { + uni.navigateTo({ + url: `${Pages.WebView}?url=${c.linkUrl}` + }); + } +} + +export function onClickMoment(id: string) { + uni.navigateTo({ + url: `${Pages.Moment}?id=${id}` + }); +} diff --git a/src/pages/community/utils.ts b/src/pages/community/utils.ts index e54eff57..e6ae2117 100644 --- a/src/pages/community/utils.ts +++ b/src/pages/community/utils.ts @@ -1,26 +1,43 @@ -import { News } from "@/apis/schemas"; -import { Pages } from "@/utils/url"; +import { getMomentPreviews } from "@/apis/moment/moment"; +import { StorageKeys } from "@/utils/const"; +import { GetMomentPreviewsReq } from "@/apis/moment/moment-components"; +import { getPrefetchData, PrefetchResp } from "@/apis/prefetch"; -export function onClickCarousel(c: News) { - if (c.type === "inner") { - uni.navigateTo({ - url: c.linkUrl - }); - } else if (c.type === "article") { - uni.navigateTo({ - url: `${Pages.WebView}?url=${c.linkUrl}` - }); - } -} +export function buildLoader(keyword?: string) { + let lastToken: string; // 每次记录上个token + const communityId = uni.getStorageSync(StorageKeys.CommunityId); -export function onClickMoment(id: string) { - uni.navigateTo({ - url: `${Pages.Moment}?id=${id}` - }); -} + const fetch = async (keyword?: string) => { + const req: GetMomentPreviewsReq = { + communityId: communityId + }; + if (lastToken) { + req.lastToken = lastToken; + } + if (keyword) { + req.keyword = keyword; + } + const res = await getMomentPreviews(req); + lastToken = res.token; + return res.moments; + }; -export function onClickSwitch() { - uni.navigateTo({ - url: Pages.SchoolSelect - }); + return async () => { + if (lastToken || keyword) { + return fetch(); + } + let res: PrefetchResp; + try { + res = await getPrefetchData({ communityId: communityId }); + } catch (reason) { + return fetch(); + } + if (!res.firstMomentPreviewsResp?.moments) { + return fetch(); + } + lastToken = res.firstMomentPreviewsResp.token; + const moments = res.firstMomentPreviewsResp.moments; + res.firstMomentPreviewsResp = undefined; + return moments; + }; } diff --git a/src/pages/plan/GoToMyPlans.vue b/src/pages/plan/GoToMyPlans.vue index 5976a630..f4f0fcf8 100644 --- a/src/pages/plan/GoToMyPlans.vue +++ b/src/pages/plan/GoToMyPlans.vue @@ -7,14 +7,14 @@ diff --git a/src/pages/profile/my-publish/my-posts.vue b/src/pages/profile/my-publish/my-posts.vue index de2de0c8..1aab065d 100644 --- a/src/pages/profile/my-publish/my-posts.vue +++ b/src/pages/profile/my-publish/my-posts.vue @@ -47,35 +47,26 @@ {{ post.likes }}位喵友觉得很赞 - - - - 删除帖子 - - - - + -