diff --git a/src/components/My/index.vue b/src/components/My/index.vue index 6c9f0a0..a3d3db3 100644 --- a/src/components/My/index.vue +++ b/src/components/My/index.vue @@ -75,7 +75,7 @@ import Taro from "@tarojs/taro"; import { computed } from "vue"; import "./index.scss"; import { storeToRefs } from "pinia"; -import useNewFeatureStore from "@/store/service/newFeature"; +import useNewFeatureStore, { FeatureNode } from "@/store/service/newFeature"; import useUserStore from "@/store/service/user"; import { Image as TaroImage } from "@tarojs/components"; @@ -85,10 +85,11 @@ const { getWXProfile } = userStore; const { isActive, wxProfile, info: userInfo } = storeToRefs(userStore); const options = computed(() => { - const data = [ + const newFeaturesInMinePage = newFeatureStore.tree?.my as FeatureNode; + + return [ [ - // TODO: 修复类型问题 - { title: "绑定", url: "/pages/bind/index", badge: newFeatureStore.tree?.my?.bind }, + { title: "绑定", url: "/pages/bind/index", badge: newFeaturesInMinePage.bind as string }, { title: "主题", url: "/pages/theme/index" } ], [ @@ -99,20 +100,14 @@ const options = computed(() => { { title: "设置", url: "/pages/setting/index" } ] ]; - return data; }); function nav2activation() { - Taro.navigateTo({ - url: "/pages/activation/index" - }); + Taro.navigateTo({ url: "/pages/activation/index" }); } function nav2url(url: string | undefined) { - if (url) - Taro.navigateTo({ - url: url - }); + if (url) Taro.navigateTo({ url }); } diff --git a/src/pages/lostfound/index.vue b/src/pages/lostfound/index.vue index 0c159ab..39aba74 100644 --- a/src/pages/lostfound/index.vue +++ b/src/pages/lostfound/index.vue @@ -67,7 +67,6 @@ import { LostfoundService } from "@/services"; import { LostfoundRecord } from "@/types/Lostfound"; import { ref } from "vue"; import PreviewCard from "./PreviewCard/index.vue"; -import { omit } from "lodash-es"; import "./index.scss"; import WModal from "../../components/Modal/index.vue"; import { helpText } from "@/constants/copywriting"; @@ -127,7 +126,7 @@ const { data: kindList } = useRequestNext( } ); -const { loading, run } = useRequestNext( +const { loading, run: fetchRecords } = useRequestNext( LostfoundService.getRecords, { defaultParams: { campus: selectCampus.value, @@ -161,8 +160,10 @@ const getRecords = (data: { lost_or_found?: string; }) => { isEmpty.value = false; - // TODO: 修复类型问题 - run(omit(data, [data.kind === "全部" ? "kind" : null, data.lost_or_found === "全部" ? "lost_or_found" : ""])); + if (data.kind === "全部") + fetchRecords({ campus: data.campus, page_num: data.page_num, page_size: data.page_size }); + else + fetchRecords(data); }; const handleSelectCampus = (campus: string) => { diff --git a/src/services/index.ts b/src/services/index.ts index 6649aa2..ff90ec2 100644 --- a/src/services/index.ts +++ b/src/services/index.ts @@ -5,7 +5,6 @@ import LibraryService from "./services/libraryService"; import YxyService from "./services/yxyService"; import LostfoundService from "./services/lostfoundService"; import SuitService from "./services/suitService"; -import errCodeHandler from "./utils/errHandler"; import { api } from "./api/apiList"; export { @@ -16,6 +15,5 @@ export { YxyService, LostfoundService, SuitService, - errCodeHandler, api }; diff --git a/src/services/utils/errHandler.ts b/src/services/utils/errHandler.ts deleted file mode 100644 index e14adf8..0000000 --- a/src/services/utils/errHandler.ts +++ /dev/null @@ -1,80 +0,0 @@ -import { ServerCode } from "../api/codes"; -import Taro from "@tarojs/taro"; -import store, { serviceStore } from "@/store"; - -/** - * @deprecated - * 微信相关登录异常处理 - * TODO: 迁移处理逻辑至具体的业务模块 - */ -export default async function errCodeHandler(code: number, showModal = true) { - console.error("Error code", code); - if (showModal) - switch (code) { - case ServerCode.UsernamePasswordUnmatched: - await Taro.showToast({ - icon: "none", - title: "密码错误" - }); - break; - case ServerCode.UserNotLogin: - if (serviceStore.user.isActive) { - store.commit("clearUserInfo"); - await Taro.showModal({ - title: "错误", - content: "未登录" - }); - } - break; - case ServerCode.SystemError_1: - await Taro.showToast({ - icon: "none", - title: "请求超时,请重试" - }); - break; - case ServerCode.SystemError_2: - await Taro.showToast({ - icon: "none", - title: "请求超时,请重试" - }); - break; - case ServerCode.UserAlreadyExisted: - await Taro.showModal({ - title: "提示", - content: "用户已存在", - confirmText: "去登录" - }); - break; - case ServerCode.activation.passportExisted: - await Taro.showToast({ - icon: "none", - title: "通行证已存在" - }); - break; - case ServerCode.activation.schoolIdOrIdNotExistNotMatch: - await Taro.showToast({ - icon: "none", - title: "学号或身份证号不存在或者不匹配" - }); - break; - case ServerCode.activation.passwordLenghtError: - await Taro.showToast({ - icon: "none", - title: "密码长度请在6~20位之间" - }); - break; - case ServerCode.activation.schooldIdError: - await Taro.showToast({ - icon: "none", - title: "学号格式错误" - }); - break; - default: - if (import.meta.env.DEV) - await Taro.showToast({ - icon: "none", - title: `${code}` - }); - break; - } -} diff --git a/src/store/service/newFeature.ts b/src/store/service/newFeature.ts index 70df3ef..9fe9e92 100644 --- a/src/store/service/newFeature.ts +++ b/src/store/service/newFeature.ts @@ -2,7 +2,7 @@ import { persistedStorage } from "@/utils"; import { defineStore } from "pinia"; import { computed, ref } from "vue"; -type FeatureNode = { +export type FeatureNode = { [key: string]: string | null | FeatureNode; };