Skip to content

Commit

Permalink
perf: 小优化
Browse files Browse the repository at this point in the history
  • Loading branch information
foliet committed Dec 19, 2023
1 parent 8a965ac commit 6a58a0e
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 97 deletions.
1 change: 0 additions & 1 deletion src/apis/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ export interface Moment {
}

export const enum PlanType {
TypeOther = 0,
TypeCastrate = 1,
TypeHeal = 2,
TypeFeed = 3,
Expand Down
29 changes: 0 additions & 29 deletions src/pages/plan/CheckInTaskPanel.vue

This file was deleted.

17 changes: 3 additions & 14 deletions src/pages/plan/GoToMyPlans.vue
Original file line number Diff line number Diff line change
@@ -1,31 +1,20 @@
<template>
<view class="goToMyPlans">
<img
src="https://static-1308722423.cos.ap-shanghai.myqcloud.com/static/meowchat/helped_plan_logo.png"
<image
:src="Pictures.HelpedPlanLogo"
class="small-icon"
@click="goToHelpedPlans()"
/>
</view>
</template>

<script setup lang="ts">
import { Icons, Pages } from "@/utils/url";
import { ref } from "vue";
import { getCountDonate } from "@/apis/plan/plan";
import { Pages, Pictures } from "@/utils/url";
const goToHelpedPlans = () => {
uni.navigateTo({
url: Pages.HelpedPlans
});
};
// const donateNum = ref(0);
// const getDonateCount = async () => {
// const data = await getCountDonate({});
// if (data.total) {
// donateNum.value = data.total;
// }
// };
// getDonateCount();
</script>

<style scoped lang="scss">
Expand Down
70 changes: 18 additions & 52 deletions src/pages/plan/PlanEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
@click="onClickPlan(props.plan.id)"
>
<view class="small-icon">
<img
<image
:src="
planTypeMap(props.plan.planType) === '零食奖励' ||
planTypeMap(props.plan.planType) === '物资补给'
props.plan.planType === PlanType.TypeFeed ||
props.plan.planType === PlanType.TypeSupply
? Icons.Plan_PlanSnacksTag
: Icons.Plan_PlanHealthTag
"
Expand All @@ -20,14 +20,15 @@
<view>
<view class="bar-content">
<text class="txt1">帮助</text>
<text :class="getHelpCatClass(props.plan.planType)">{{
props.plan?.cat?.name || "全体猫猫"
}}</text>
<text
:class="`helped-cat-${planKeyMap[props.plan.planType] || 'health'}`"
>{{ props.plan?.cat?.name || "全体猫猫" }}</text
>
<text class="txt2">{{ props.plan.name }}</text>
</view>
<view class="progress-out"
><view
:class="getProgressClass(props.plan.planType)"
:class="`progress-${planKeyMap[props.plan.planType] || 'health'}`"
:style="{
width: (55 * props.plan.nowFish) / props.plan.maxFish + 'vw'
}"
Expand All @@ -38,61 +39,27 @@
}}小鱼干
</view>
</view>
<view :class="getHelpButClass(props.plan.planType)"> 去助力 </view>
<view :class="`help-but-${planKeyMap[props.plan.planType] || 'health'}`">
去助力
</view>
</view>
</view>
<!-- </div>-->
</template>

<script setup lang="ts">
import { Plan, PlanType } from "@/apis/schemas";
import { Icons } from "@/utils/url";
import { planTypeMap, onClickPlan } from "@/pages/plan/utils";
import { onClickPlan, planTypeMap } from "@/pages/plan/utils";

const props = defineProps<{
plan: Plan;
}>();
const getProgressClass = (planType: PlanType): string => {
switch (planType) {
case 1:
return "progress-castrate";
case 2:
return "progress-health";
case 3:
return "progress-snacks";
case 4:
return "progress-supply";
default:
return "progress-health";
}
};
const getHelpButClass = (planType: PlanType): string => {
switch (planType) {
case 0:
return "help-but-castrate";
case 1:
return "help-but-health";
case 2:
return "help-but-snacks";
case 3:
return "help-but-supply";
default:
return "help-but-health";
}
};
const getHelpCatClass = (planType: PlanType): string => {
switch (planType) {
case 0:
return "helped-cat-castrate";
case 1:
return "helped-cat-health";
case 2:
return "helped-cat-snacks";
case 3:
return "helped-cat-supply";
default:
return "helped-cat-health";
}

const planKeyMap: Record<PlanType, string> = {
[PlanType.TypeCastrate]: "castrate",
[PlanType.TypeHeal]: "health",
[PlanType.TypeFeed]: "snacks",
[PlanType.TypeSupply]: "supply"
};
</script>

Expand All @@ -104,7 +71,6 @@ const getHelpCatClass = (planType: PlanType): string => {
border-radius: 2vw;
width: 95vw;
height: 60vw;
//background-color: #a2a4a7;
background-size: 100% 100%;
display: flex;
flex-direction: column;
Expand Down
3 changes: 2 additions & 1 deletion src/utils/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ export const enum Pictures {
NoData = "https://static.xhpolaris.com/nodata.png",
ProfileBackground = "https://static.xhpolaris.com/static/meowchat/profile_background.png",
NoCatHere = "/static/images/no_cat_here.png",
NoMore = "/static/images/nomore.png"
NoMore = "/static/images/nomore.png",
HelpedPlanLogo = "https://static.xhpolaris.com/static/meowchat/helped_plan_logo.png"
}

export const enum Icons {
Expand Down

0 comments on commit 6a58a0e

Please sign in to comment.