From 0dc87d06d67cc016c70d6cfc03092c219cfd59b0 Mon Sep 17 00:00:00 2001 From: Dawn1Ocean <1785590531@qq.com> Date: Tue, 23 Apr 2024 15:59:22 +0800 Subject: [PATCH] fix: dutyinfo display; relaunch to Loading page --- src/pages/Loading/Loading.tsx | 6 ++++++ src/plain-text/common.ts | 6 ++++++ src/service/dutyInfo.ts | 10 ++++++++++ 3 files changed, 22 insertions(+) diff --git a/src/pages/Loading/Loading.tsx b/src/pages/Loading/Loading.tsx index 2fd46bc..60bdc2b 100644 --- a/src/pages/Loading/Loading.tsx +++ b/src/pages/Loading/Loading.tsx @@ -3,6 +3,7 @@ import { Component, ReactNode } from 'react'; import Taro from '@tarojs/taro'; import pt from '@/plain-text'; import { View } from '@tarojs/components'; +import wechatUser from '@/wechat'; import './Loading.scss'; export default class LoadingPage extends Component { @@ -10,6 +11,11 @@ export default class LoadingPage extends Component { Taro.setNavigationBarTitle({ title: pt.get().navBar.loading, }); + if (wechatUser.getToken()) { + Taro.reLaunch({ + url: '/pages/index/index', + }); + } } render(): ReactNode { return ( diff --git a/src/plain-text/common.ts b/src/plain-text/common.ts index 2f50c7b..827b04c 100644 --- a/src/plain-text/common.ts +++ b/src/plain-text/common.ts @@ -2,16 +2,22 @@ import { Moment } from 'moment'; export interface CommonText { createdAtText(time: Moment): string; + offDutyReason: string; + place: string; } export const commonTextZhCn: CommonText = { createdAtText(time: Moment): string { return '创建于 ' + time.format('YYYY-MM-DD HH:mm'); }, + offDutyReason: '正常值班下班', + place: '东三-204', }; export const commonTextEnUs: CommonText = { createdAtText(time: Moment): string { return 'Created at ' + time.format('YYYY-MM-DD HH:mm'); }, + offDutyReason: 'Normal Shift', + place: 'E3-204', }; diff --git a/src/service/dutyInfo.ts b/src/service/dutyInfo.ts index ef45f81..5220bee 100644 --- a/src/service/dutyInfo.ts +++ b/src/service/dutyInfo.ts @@ -1,6 +1,7 @@ import MainPage from '@/pages/index'; import Taro from '@tarojs/taro'; import wechatUser from '@/wechat'; +import pt from '@/plain-text'; import { getUrl } from '.'; export function getDutyInfo(that: MainPage) { @@ -24,6 +25,15 @@ export function getDutyInfo(that: MainPage) { rs: former.trans(true), dutyData: data, }); + if (data.currentDuty === '0') { + that.setState({ + dutyData: { + ...that.state.dutyData, + place: pt.get().common.place, + offDutyReason: pt.get().common.offDutyReason, + }, + }); + } }) .catch((err) => { console.log(err.errMsg);