From 168dc2825a9af05b578fd382d464400a8c99b68d Mon Sep 17 00:00:00 2001 From: popWheat <49830650+j10ccc@users.noreply.github.com> Date: Fri, 10 Feb 2023 00:10:09 +0800 Subject: [PATCH] =?UTF-8?q?perf(*):=20=E4=BC=98=E5=8C=96=E6=A0=A1=E5=9B=AD?= =?UTF-8?q?=E5=8D=A1=E4=BD=BF=E7=94=A8=E4=BD=93=E9=AA=8C=EF=BC=8Cyxy=20?= =?UTF-8?q?=E7=BB=91=E5=AE=9A=E6=B7=BB=E5=8A=A0=20beta=20=E6=A0=87?= =?UTF-8?q?=E5=BE=BD=20(#30)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(electricity): change property `surplus` to `soc` of response * fix(school-card): disable show modal when requset error in home page * chore(bind): add beta badge to yxy bind item --- src/components/ElectricityQuickView/index.vue | 8 +++---- src/components/SchoolCardQuickView/index.vue | 13 ++--------- src/pages/bind/index.scss | 23 +++++++++++++++++++ src/pages/bind/index.vue | 5 ++-- src/pages/electricity/index.vue | 2 +- src/services/services/yxyService.ts | 4 ++-- 6 files changed, 35 insertions(+), 20 deletions(-) diff --git a/src/components/ElectricityQuickView/index.vue b/src/components/ElectricityQuickView/index.vue index 7f8c2d4d..770b8622 100644 --- a/src/components/ElectricityQuickView/index.vue +++ b/src/components/ElectricityQuickView/index.vue @@ -8,7 +8,7 @@ 寝室剩余电费 - {{ balanceData?.data.surplus || 0 }} + {{ balanceData?.data.soc || 0 }} @@ -35,8 +35,8 @@ function nav2electricity() { const { data: balanceData, loading, error } = useRequest( YxyService.queryBalance, { onSuccess: (res) => { - if (res.data.data?.surplus) { - store.commit("setBalance",res.data.data.surplus); + if (res.data.data?.soc) { + store.commit("setBalance",res.data.data.soc); } else throw new Error(); } } @@ -44,7 +44,7 @@ const { data: balanceData, loading, error } = useRequest( const isUrgent = computed(() => { if (balanceData.value) - return balanceData.value.data.surplus < 20; + return balanceData.value.data.soc < 20; else return false; }); diff --git a/src/components/SchoolCardQuickView/index.vue b/src/components/SchoolCardQuickView/index.vue index 2cc3b4e6..d1305b19 100644 --- a/src/components/SchoolCardQuickView/index.vue +++ b/src/components/SchoolCardQuickView/index.vue @@ -31,18 +31,9 @@ const { error } = useRequest(YxyService.querySchoolCardBalance, { if (Number.isFinite(parseFloat(res.data.data))) store.commit("setCardBalance", res.data.data); else throw new Error("无效余额值"); - } else if (res.data.code === 200514) { - Taro.showModal({ - title: "查询余额失败", - content: res.data.msg, - confirmText: "重新登录", - success: (res) => { - if (res.confirm) - Taro.navigateTo({ url: "/pages/bind/index" }); - } - }); + } else { + throw new Error(res.data.msg); } - else throw new Error(res.data.msg); }, onError: (error) => { if (!(error instanceof Error)) return `查询校园卡余额\r\n${error.errMsg}`; diff --git a/src/pages/bind/index.scss b/src/pages/bind/index.scss index bd83e276..bbf16474 100644 --- a/src/pages/bind/index.scss +++ b/src/pages/bind/index.scss @@ -26,6 +26,10 @@ @include radius; background-color: var(--wjh-color-week); color: var(--wjh-color-white); + + .wjh-list-item-content-main { + align-items: center; + } } .binded { @@ -47,3 +51,22 @@ } } } + +.beta-badge::before { + position: absolute; + content: "beta"; + top: -1rem; + right: 0; + padding: 4Px 8Px; + line-height: 100%; + background-color: var(--wjh-color-red); + border-radius: 16Px; +} + +.badge { + font-size: .8rem; + padding: 4Px 8Px; + line-height: 100%; + background-color: var(--wjh-color-red); + border-radius: 16Px; +} diff --git a/src/pages/bind/index.vue b/src/pages/bind/index.vue index a2b4aaf9..b603693b 100644 --- a/src/pages/bind/index.vue +++ b/src/pages/bind/index.vue @@ -27,11 +27,12 @@ - 一卡通账号 + 一卡通账号 + 测试 diff --git a/src/pages/electricity/index.vue b/src/pages/electricity/index.vue index d59d9da7..3dfd4cbb 100644 --- a/src/pages/electricity/index.vue +++ b/src/pages/electricity/index.vue @@ -89,7 +89,7 @@ useRequest(YxyService.queryBalance, { store.commit("setElectricityStore", { roomName: response.data.data.display_room_name, roomCode: response.data.data.room_code, - balance: response.data.data.surplus + balance: response.data.data.soc }); } else { throw new Error(response.data.msg || response.errMsg); diff --git a/src/services/services/yxyService.ts b/src/services/services/yxyService.ts index d16e63fb..b0cab199 100644 --- a/src/services/services/yxyService.ts +++ b/src/services/services/yxyService.ts @@ -61,8 +61,8 @@ export default class YxyService { display_room_name: string; md_name: string; room_code: string; - surplus: number; //kwh - surplus_amount: number; // rmb + soc: number; //kwh + soc_amount: number; // rmb }>( api.electricity.balance, { method: "GET",