Skip to content

Commit

Permalink
fix: 修复小鱼干计划若干问题
Browse files Browse the repository at this point in the history
  • Loading branch information
foliet committed Dec 2, 2023
1 parent bcd1373 commit a3f6ebd
Show file tree
Hide file tree
Showing 32 changed files with 350 additions and 768 deletions.
22 changes: 13 additions & 9 deletions src/apis/like/like-interface.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TargetType } from "@/apis/schemas";
import { Comment, Moment, Post, TargetType, User } from "@/apis/schemas";

export interface DoLikeReq {
targetId: string;
Expand Down Expand Up @@ -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;
}
17 changes: 6 additions & 11 deletions src/apis/like/like.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
GetCountResp,
GetUserLikedReq,
GetUserLikedResp,
GetUserLikesReq,
GetUserLikesResp
GetLikeContentsReq,
GetLikeContentsResp
} from "@/apis/like/like-interface";

/**
Expand Down Expand Up @@ -75,22 +75,17 @@ export async function getCount(req: GetCountReq) {
});
}

/**
* @description
* 获取点赞内容
* @param req
*/
export async function getUserLikes(req: GetUserLikesReq) {
return await new Promise<GetUserLikesResp>((resolve, reject) => {
export async function getLikeContents(req: GetLikeContentsReq) {
return await new Promise<GetLikeContentsResp>((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);
}
});
Expand Down
1 change: 0 additions & 1 deletion src/apis/moment/moment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export async function newMoment(req: NewMomentReq): Promise<NewMomentResp> {
method: "POST",
success(res: UniNamespace.RequestSuccessCallbackResult) {
if (res.statusCode !== 200) {
console.log("here", res);
reject(res);
}
const data = res.data as NewMomentResp;
Expand Down
17 changes: 7 additions & 10 deletions src/apis/plan/plan-interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Plan, PlanType, User } from "../schemas";
import { Plan, PlanPreview, PlanType, User } from "../schemas";

export interface DeletePlanReq {
planId: string;
Expand Down Expand Up @@ -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[];
}
7 changes: 4 additions & 3 deletions src/apis/plan/plan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
GetPlanPreviewsReq,
GetPlanPreviewsResp,
GetUserDonateCountReq,
GetUserDonateCountResp,
GetUserFishReq,
GetUserFishResp,
ListDonateByUserReq,
Expand Down Expand Up @@ -135,7 +136,7 @@ export async function donateFish(req: DonateFishReq) {
}

export async function getCountDonate(req: GetUserDonateCountReq) {
return await new Promise<GetUserDonateCountReq>((resolve, reject) => {
return await new Promise<GetUserDonateCountResp>((resolve, reject) => {
uni.request({
url: "/plan/count_donate_by_user",
data: req,
Expand All @@ -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<ListDonateByUserResp>((resolve, reject) => {
uni.request({
url: "/plan/list_donate_by_user",
Expand Down
13 changes: 6 additions & 7 deletions src/apis/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion src/components/BottomBar/BottomBarContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 7 additions & 2 deletions src/components/SchoolSelectBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@

<script lang="ts" setup>
import { reactive, ref } from "vue";
import { Icons } from "@/utils/url";
import { onClickSwitch } from "@/pages/community/utils";
import { Icons, Pages } from "@/utils/url";
import { listCommunity } from "@/apis/community/community";
import { StorageKeys } from "@/utils/const";
import { Community } from "@/apis/schemas";
Expand Down Expand Up @@ -55,6 +54,12 @@ async function getCampus() {
}
}
const onClickSwitch = () => {
uni.navigateTo({
url: Pages.SchoolSelect
});
};
getCampus();
</script>

Expand Down
2 changes: 1 addition & 1 deletion src/pages/community/Carousel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<script lang="ts" setup>
import { reactive, ref } from "vue";
import { News } from "@/apis/schemas";
import { onClickCarousel } from "@/pages/community/utils";
import { onClickCarousel } from "@/pages/community/event";
const props = defineProps<{
contents: News[];
Expand Down
15 changes: 7 additions & 8 deletions src/pages/community/Masonry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@
</view>

<view class="tile-info">
<view class="title">
{{ moment.title }}
</view>
<view class="title">{{ moment.title }}</view>
<view class="other-info">
<view class="user-info">
<template v-if="moment.user">
Expand Down Expand Up @@ -62,16 +60,17 @@
</template>
</view>
</view>
<view v-if="isNoData" class="no-cat-here-frame">
<image :src="Pictures.NoCatHere" class="no-cat-here" />
<view v-if="isNoData">
<view class="no-cat-here-frame">
<image :src="Pictures.NoCatHere" class="no-cat-here" />
</view>
</view>
<view v-else class="blue-background" />
</template>

<script lang="ts" setup>
import { getCurrentInstance, onBeforeMount, reactive, ref } from "vue";
import { Moment } from "@/apis/schemas";
import { onClickMoment } from "@/pages/community/utils";
import { onClickMoment } from "@/pages/community/event";
import { onReachBottom } from "@dcloudio/uni-app";
import { displayTime } from "@/utils/time";
import { Pictures } from "@/utils/url";
Expand Down Expand Up @@ -355,7 +354,7 @@ $avatarWidth: calc(21 / 390 * 100vw);
.no-cat-here-frame {
width: 100vw;
margin-top: 20vh;
margin-top: 50rpx;
display: flex;
justify-content: center;
Expand Down
60 changes: 0 additions & 60 deletions src/pages/community/MasonryFrame.vue

This file was deleted.

5 changes: 3 additions & 2 deletions src/pages/community/community.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<view style="height: 4vw"></view>

<view v-if="!isRefreshing">
<MasonryFrame></MasonryFrame>
<Masonry :get-previews="buildLoader()"></Masonry>
</view>

<view style="height: 18vw"></view>
Expand All @@ -53,14 +53,15 @@ 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";
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(["", "", "", "", "", ""]);
Expand Down
19 changes: 19 additions & 0 deletions src/pages/community/event.ts
Original file line number Diff line number Diff line change
@@ -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}`
});
}
Loading

0 comments on commit a3f6ebd

Please sign in to comment.