Skip to content

Commit

Permalink
feat: 修改签到url并完善签到页面功能 (#392)
Browse files Browse the repository at this point in the history
* feat: 完成小鱼干签到页面

* feat: 修改签到url并完善签到页面功能

* feat: 修改一些bug

* perf: 小优化

* perf: 将一些图标放入图床

---------

Co-authored-by: foliet <[email protected]>
  • Loading branch information
python-No2 and foliet committed Dec 20, 2023
1 parent 2eb672d commit 7344238
Show file tree
Hide file tree
Showing 27 changed files with 1,177 additions and 155 deletions.
16 changes: 16 additions & 0 deletions src/apis/incentive/incentive-interfaces.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export interface UserCheckInResp {
getFish: boolean;
getFishNum: number;
getFishTimes: number;
}

export interface getMissionResp {
SignInTime: number;
LikeTime: number;
CommentTime: number;
ContentTime: number;
SignInFishes: number[];
LikeFishes: number[];
CommentFishes: number[];
ContentFishes: number[];
}
36 changes: 36 additions & 0 deletions src/apis/incentive/incentive.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import {
UserCheckInResp,
getMissionResp
} from "@/apis/incentive/incentive-interfaces";

export async function userCheckIn() {
return await new Promise<UserCheckInResp>((resolve, reject) => {
uni.request({
url: "/incentive/check_in",
method: "GET",
success(res: UniNamespace.RequestSuccessCallbackResult) {
if (res.statusCode !== 200) {
reject(res);
}
const data = res.data as UserCheckInResp;
resolve(data);
}
});
});
}

export async function getUserMission() {
return await new Promise<getMissionResp>((resolve, reject) => {
uni.request({
url: "/incentive/get_mission",
method: "GET",
success(res: UniNamespace.RequestSuccessCallbackResult) {
if (res.statusCode !== 200) {
reject(res);
}
const data = res.data as getMissionResp;
resolve(data);
}
});
});
}
4 changes: 2 additions & 2 deletions src/apis/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ export interface Moment {
}

export const enum PlanType {
TypeOther = 0,
TypeCastrate = 1,
TypeHeal = 2,
TypeFeed = 3
TypeFeed = 3,
TypeSupply
}

export const enum PlanState {
Expand Down
5 changes: 0 additions & 5 deletions src/apis/user/user-interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,3 @@ export interface UpdateUserInfoResp {
code: number;
msg: string;
}

export interface UserCheckInResp {
getFish: boolean;
getFishNum: number;
}
19 changes: 1 addition & 18 deletions src/apis/user/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import {
GetUserInfoReq,
GetUserInfoResp,
UpdateUserInfoReq,
UpdateUserInfoResp,
UserCheckInResp
UpdateUserInfoResp
} from "./user-interfaces";
import { PictureStyle } from "@/apis/cos/cos-interface";
import { getPrefetchData } from "@/apis/prefetch";
Expand Down Expand Up @@ -51,19 +50,3 @@ export async function updateUserInfo(req: UpdateUserInfoReq) {
});
});
}

export async function userCheckIn() {
return await new Promise<UserCheckInResp>((resolve, reject) => {
uni.request({
url: "/user/check_in",
method: "GET",
success(res: UniNamespace.RequestSuccessCallbackResult) {
if (res.statusCode !== 200) {
reject(res);
}
const data = res.data as UserCheckInResp;
resolve(data);
}
});
});
}
3 changes: 2 additions & 1 deletion src/pages/community/community.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
</template>

<script lang="ts" setup>
import { userCheckIn } from "@/apis/user/user";
import { userCheckIn } from "@/apis/incentive/incentive";
import CollectionEntry from "@/pages/community/CollectionEntry.vue";
import BottomBar from "@/components/BottomBar.vue";
import { nextTick, reactive, ref } from "vue";
Expand All @@ -58,6 +58,7 @@ 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
160 changes: 160 additions & 0 deletions src/pages/plan/CommentTask.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
<template>
<view class="moment-task-box">
<view class="content">
<text class="title">每日评论</text>
<text class="detail"
>评论可以获得{{
userData.CommentFishes[0]
}}小鱼干,每日可共获得3次</text
>
<view class="finish-times">
<text class="times">完成情况:</text>
<image
v-for="commenttime in commentTimes"
:key="commenttime"
:src="
userData.CommentTime >= commenttime
? Icons.FinishedTask
: Icons.UnFinishedTask
"
class="icon"
:style="{ marginLeft: commenttime === 1 ? '0' : '1vw' }"
/>
</view>
</view>
<view class="get-fish-number">
<img :src="Icons.LittleFish" class="fish-unit" />
<text class="fish-num">X{{ userData.CommentFishes[0] }}</text>
</view>
<view
v-if="userData.CommentTime >= 3"
class="button"
style="background-color: #cccccc"
>
<view class="option">已完成</view>
</view>
<view v-else class="button" @click="goToCommunity()">
<view class="option">去完成</view>
</view>
</view>
</template>

<script setup lang="ts">
import { Icons, Pages } from "@/utils/url";
import { ref } from "vue";
import { getMissionResp } from "@/apis/incentive/incentive-interfaces";
import { getUserMission } from "@/apis/incentive/incentive";
const goToCommunity = () => {
uni.navigateTo({
url: Pages.FirstPage
});
};
const userData = ref<getMissionResp>({
SignInTime: 0,
LikeTime: 0,
CommentTime: 0,
ContentTime: 0,
SignInFishes: [],
LikeFishes: [],
CommentFishes: [],
ContentFishes: []
});
// const a = ref([]);
// getUserMission().then((res) => {
// a.value = res.SignInFishes;
// });
getUserMission().then((res) => {
userData.value.SignInTime = res.SignInTime;
userData.value.LikeTime = res.LikeTime;
userData.value.CommentTime = res.CommentTime;
userData.value.ContentTime = res.ContentTime;
userData.value.SignInFishes = res.SignInFishes;
userData.value.ContentFishes = res.ContentFishes;
userData.value.LikeFishes = res.LikeFishes;
userData.value.CommentFishes = res.CommentFishes;
});
const commentTimes = Array.from({ length: 3 }, (_, index) => index + 1);
</script>

<style scoped lang="scss">
.moment-task-box {
display: flex;
flex-direction: row;
width: 95vw;
height: 21.28vw;
border-radius: 3vw;
background-color: #f4f9ff;
margin-left: 2.5vw;
.content {
display: flex;
flex-direction: column;
.title {
margin-left: 5vw;
margin-top: 3.5vw;
font-weight: bold;
font-size: 4.5vw;
letter-spacing: 0.1vw;
}
.detail {
color: #00000078;
font-size: 2.8vw;
font-weight: bold;
margin-left: 5vw;
margin-top: 1vw;
}
.finish-times {
margin-left: 5vw;
display: flex;
flex-direction: row;
.times {
color: #00000078;
font-size: 2.8vw;
font-weight: bold;
}
.icon {
margin-top: 1vw;
width: 2.56vw;
height: 2.56vw;
}
}
}
.get-fish-number {
margin-left: 8vw;
margin-top: 6.5vw;
display: flex;
flex-direction: row;
.fish-unit {
width: 6vw;
height: 6vw;
}
.fish-num {
color: #48282d;
font-size: 3.5vw;
font-weight: bold;
margin-top: 0.5vw;
}
}
.button {
display: flex;
align-items: center;
justify-content: center;
margin-top: 5.5vw;
margin-left: 2vw;
width: 16.15vw;
height: 6.67vw;
background-color: #1f6bff;
border-radius: 5.89vw;
.option {
color: #ffffff;
font-size: 3.5vw;
font-weight: bold;
letter-spacing: 0.1vw;
}
}
}
</style>
33 changes: 19 additions & 14 deletions src/pages/plan/FishAmount.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
<view class="frame">
<img :src="Icons.LittleFish" class="small-icon" />
<text class="text"
>剩余<text style="color: dodgerblue">{{ fishNum }}</text
>小鱼干</text
>剩余<text
style="color: dodgerblue; font-size: 3.8vw; font-style: italic"
>{{ fishNum }}</text
></text
>
</view>
</template>
Expand All @@ -23,25 +25,28 @@ getFishNum();

<style scoped lang="scss">
.frame {
border-radius: 2vw;
background-color: #feffff;
border-radius: 5vw;
//border: 0.5px solid;
background: #ecf2ff;
display: flex;
flex-direction: row;
align-items: center;
width: 46vw;
height: 12vw;
width: 26.41vw;
height: 9.23vw;
position: relative;
z-index: 1;
box-shadow: 0 2px 4px -1px #1f6bff1f;
.small-icon {
height: 7vw;
width: 7vw;
margin-left: 3vw;
margin-right: 2vw;
height: 8.46vw;
width: 8.46vw;
margin-top: -2.5vw;
position: absolute;
z-index: 2;
}
.text {
color: #00365c;
font-size: 4vw;
margin-right: 2.5vw;
font-size: 3.2vw;
margin-left: 9vw;
font-weight: bold;
letter-spacing: 0.1vw;
}
Expand Down
Loading

0 comments on commit 7344238

Please sign in to comment.