Skip to content

Commit

Permalink
Merge branch 'zjutjh:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
xixiIBN5100 authored Dec 17, 2024
2 parents 07e667b + 83879ed commit 7e12579
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 16 deletions.
28 changes: 21 additions & 7 deletions src/components/ElectricityQuickView/index.vue
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<template>
<quick-view title="电费查询" icon-name="electricity" @tap="nav2electricity">
<quick-view title="电量查询" icon-name="electricity" @tap="nav2electricity">
<view class="text-view">
<text class="sub-text-left">
当前电费({{ updateTimeString }})
当前电量({{ updateTimeString }})
</text>
<text v-if="isUrgent" class="sub-text-right">
温馨提示: 电量较低
</text>
</view>
<card class="electricity-card">
<view v-if="!loading" class="text-wrapper">
<text>寝室剩余电费</text>
<text>寝室剩余电量</text>
<text :class="isUrgent ? 'dangerous' : 'normal'">
{{ balanceData?.data.soc || 0 }}
</text>
Expand All @@ -27,7 +27,7 @@
import { QuickView } from "@/components";
import Taro from "@tarojs/taro";
import "./index.scss";
import { computed } from "vue";
import { computed, watch } from "vue";
import { YxyService } from "@/services";
import store, { serviceStore } from "@/store";
import Card from "../Card/index.vue";
Expand All @@ -37,17 +37,31 @@ import { useRequest } from "@/hooks";
function nav2electricity() {
Taro.navigateTo({ url: "/pages/electricity/index" });
}
const campus = computed(() => serviceStore.electricity.electricityCampus);
const { data: balanceData, loading, error } = useRequest(
YxyService.queryBalance, {
const { data: balanceData, loading, error, run } = useRequest(
YxyService.queryBalance,
{
manual: true,
onSuccess: (res) => {
if (res.data.data?.soc) {
serviceStore.electricity.lastCampus = campus.value;
store.commit("setBalance", res.data.data.soc);
} else throw new Error();
} else {
throw new Error(res.data.msg);
}
}
}
);
watch(
campus,
(newCampus) => {
run({ campus: newCampus });
},
{ immediate: true }
);
const isUrgent = computed(() => {
if (balanceData.value)
return balanceData.value.data.soc < 20;
Expand Down
2 changes: 1 addition & 1 deletion src/constants/copywriting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const helpText = {
oauth: "1.统一验证系统是什么?\n统一验证系统是你的选课系统哦~\n那么密码就是你的统一验证密码~\n\n2.忘记密码?\n请联系学院教务老师重置密码。 \n\n 23级及以后的同学改用统一验证系统登录",
library:
"新生图书馆绑定异常——新生需要在接受图书馆培训并通过入馆考试后,才能正常绑定图书馆账号",
yxy: "丨绑定此项以使用校园卡查询等功能\n丨请确保已下载过易校园 APP 且将手机号与学号、宿舍绑定\n丨若图形验证码加载失败,请过一段时间再来绑定"
yxy: "丨绑定此项以使用校园卡查询等功能\n\n丨请确保已下载过易校园 APP 且将手机号与学号、宿舍绑定"
},
exam: "丨微精弘的数据全部来源于正方教务系统,如果有误,请向正方教务系统提出更正意见。\n丨考试信息以实际为准,常见考试时长是2h,但也有部分考试时长为1.5h,请大家务必仔细注意考场黑板上的考试时间噢~",
examCard: "若信息长时间无法更新或总是刷新失败,可能是因为更改过正方教务系统的密码,请前往我的-绑定-重新绑定正方账号。\n丨考试安排中的信息全部来自正方教务系统,数据录入可能会有延迟,请耐心等待。如有疑问请联系教务处,本程序仅作信息展示。\n丨仅展示 近3日 的考试",
Expand Down
2 changes: 1 addition & 1 deletion src/constants/homeCards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const homeCards: {
},
"electricity-quick-view": {
name: "electricity-quick-view",
label: "电费查询",
label: "电量查询",
icon: "electricity",
backgroundColor: "yellow",
require: "isBindYXY"
Expand Down
2 changes: 1 addition & 1 deletion src/pages/electricity/index.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export default {
navigationBarTitleText: "寝室电费查询",
navigationBarTitleText: "寝室电量查询",
backgroundColor: "#F9D8BE",
disableScroll: true,
navigationStyle: "custom"
Expand Down
22 changes: 19 additions & 3 deletions src/pages/electricity/index.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<theme-config>
<title-bar title="寝室电费查询" back-button />
<title-bar title="寝室电量查询" back-button />
<scroll-view :scroll-y="true">
<view class="header-view">
<image src="@/assets/photos/electricity.svg" />
Expand Down Expand Up @@ -96,7 +96,7 @@ import {
} from "@/components";
import { useRequest } from "@/hooks";
import { YxyService } from "@/services";
import { computed, ref } from "vue";
import { computed, ref, watch } from "vue";
import store, { serviceStore } from "@/store";
import Taro from "@tarojs/taro";
Expand All @@ -107,10 +107,26 @@ const valueMap = {
"莫干山": "mgs"
};
// eslint-disable-next-line no-warning-comments
// TODO: 优化双向同步操作
// 双向同步 selectedIndex 和 serviceStore.electricity.selectedIndex
watch(
selectedIndex,
(newValue) => {
serviceStore.electricity.selectIndex = newValue;
}
);
watch(
() => serviceStore.electricity.selectIndex,
(newValue) => {
selectedIndex.value = newValue;
}
);
const selectedOption = computed(() => options.value[selectedIndex.value]);
const onPickerChange = (event: { detail: { value: number } }) => {
selectedIndex.value = event.detail.value;
serviceStore.electricity.selectedIndex = selectedIndex.value;
const selectedValue = valueMap[selectedOption.value];
serviceStore.electricity.electricityCampus = selectedValue;
getQueryBalance({ campus: selectedValue });
Expand Down
2 changes: 1 addition & 1 deletion src/pages/electricity/subscribe/index.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<theme-config>
<title-bar title="寝室电费查询" back-button />
<title-bar title="寝室电量查询" back-button />
<view class="flex-column">
<card title="订阅消息说明">
<text>
Expand Down
10 changes: 8 additions & 2 deletions src/pages/exam/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
{{ item.examTime }}
</view>
<view
v-if="item.examTime !== '未放开不可查'"
class="exam-place"
:style="
timeInterval(item.examTime) === 0
Expand All @@ -79,7 +80,7 @@
{{ getDetailedTime(item.examTime) }}
</w-descriptions-item>
<w-descriptions-item label="考试地点" :label-span="6">
{{ `${item.examPlace} - 座位号:${item.seatNum}` }}
<text>{{ item.examPlace }}</text><text v-if="item.seatNum !== '未放开不可查'"> {{ ` - 座位号:${item.seatNum}` }}</text>

Check warning on line 83 in src/pages/exam/index.vue

View workflow job for this annotation

GitHub Actions / cache-and-install

Expected 1 line break after opening tag (`<text>`), but no line breaks found

Check warning on line 83 in src/pages/exam/index.vue

View workflow job for this annotation

GitHub Actions / cache-and-install

Expected 1 line break before closing tag (`</text>`), but no line breaks found
</w-descriptions-item>
<w-descriptions-item label="考试全称" :label-span="6">
{{ item.className }}
Expand Down Expand Up @@ -166,7 +167,12 @@ async function refresh() {
function getDetailedTime(timeString: string) {
const tmp: ConfigType = timeString.split("(")[0];
const dayChars = ["", "", "", "", "", "", ""];
return `${tmp} - 周${dayChars[dayjs(tmp).day()]}`;
if (dayChars[dayjs(tmp).day()]) {
return `${tmp} - 周${dayChars[dayjs(tmp).day()]}`;
} else {
return `${tmp}`;
}
}
function timeInterval(timeString: string) {
Expand Down
1 change: 1 addition & 0 deletions src/store/service/electricity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const ElectricityServiceStore = {
balance: undefined,
electricityCampus: "zhpf",
selectIndex: 0,
lastCampus: "zhpf",
todayConsumption: undefined,
updateTime: {
balance: undefined
Expand Down

0 comments on commit 7e12579

Please sign in to comment.