From 60f10eaa8f146762058f014f142019e8a5527218 Mon Sep 17 00:00:00 2001 From: Dawn1Ocean <1785590531@qq.com> Date: Thu, 14 Mar 2024 23:30:48 +0800 Subject: [PATCH] add random tips on currentTicket card --- mock/api.ts | 2 +- src/pages/repair/repair.tsx | 22 ++++++++++++++++------ src/plain-text/RepairPage.ts | 6 +++--- src/plain-text/Tips.ts | 25 +++++++++++++++++++++++++ src/plain-text/index.ts | 4 ++++ src/service/currentTicket.ts | 14 +++++++++----- src/service/dutyInfo.ts | 2 +- src/utils/random.ts | 3 +++ 8 files changed, 62 insertions(+), 16 deletions(-) create mode 100644 src/plain-text/Tips.ts create mode 100644 src/utils/random.ts diff --git a/mock/api.ts b/mock/api.ts index ecb938f..cfc9328 100644 --- a/mock/api.ts +++ b/mock/api.ts @@ -3,7 +3,7 @@ import ticketInfo from './ticketInfo.json'; import uncompleted from './uncompleted.json'; export default { - 'GET /dutyinfo': { + 'GET /duty/info': { success: true, data: { token: 'token_test', diff --git a/src/pages/repair/repair.tsx b/src/pages/repair/repair.tsx index 2ed6942..3446d98 100644 --- a/src/pages/repair/repair.tsx +++ b/src/pages/repair/repair.tsx @@ -17,6 +17,7 @@ import type CustomTabBar from '@/custom-tab-bar'; import repairLogo from '@/assets/icons/RepairPage/repair.svg'; import DetailFramework from '@/components/DetailFramework/DetailFramework'; import { getCurrentTicket } from '@/service/currentTicket'; +import { randomInt } from '@/utils/random'; import './repair.scss'; interface RepairPageState { @@ -29,7 +30,7 @@ interface RepairPageState { isLoading: boolean; isDisable: boolean; checkedList: Array; - currentTicketsId: Array; + currentTicketsIdName: Array>; } const submitInterval = 5000; @@ -56,11 +57,11 @@ export default class RepairPage extends Component<{}, RepairPageState> { isLoading: false, isDisable: true, checkedList: [0], - currentTicketsId: [] as Array, + currentTicketsIdName: [] as Array>, }; componentDidMount(): void { - getCurrentTicket(this, middleButton, isInfoShow); + getCurrentTicket(this); setTimeout(() => { this.setState({ @@ -162,10 +163,19 @@ export default class RepairPage extends Component<{}, RepairPageState> { } render(): ReactNode { - const ticketsRenderer = this.state.currentTicketsId.map((id, idx) => ( - + const ticketsRenderer = this.state.currentTicketsIdName.map((pair, idx) => ( + diff --git a/src/plain-text/RepairPage.ts b/src/plain-text/RepairPage.ts index 6750f3f..e9a93f8 100644 --- a/src/plain-text/RepairPage.ts +++ b/src/plain-text/RepairPage.ts @@ -50,7 +50,7 @@ export const repairPageZhCn: RepairPageText = { errorMessage: '未获取到工单!', title: '', note: '', - extra: '', + extra: '详细信息', }, typeText: { computer: '电脑', @@ -94,10 +94,10 @@ export const repairPageZhCn: RepairPageText = { export const repairPageEnUs: RepairPageText = { currentTicket: { - errorMessage: '未获取到工单!', + errorMessage: 'Cannot get the ticket!', title: '', note: '', - extra: '', + extra: 'Details', }, typeText: { computer: 'Computer', diff --git a/src/plain-text/Tips.ts b/src/plain-text/Tips.ts new file mode 100644 index 0000000..db6ff8f --- /dev/null +++ b/src/plain-text/Tips.ts @@ -0,0 +1,25 @@ +export interface TipsText { + tipsText: Array; +} + +export const tipsZhCn: TipsText = { + tipsText: [ + '提示:请在 20:30 之前取走自己的物品哦!', + '提示:戴尔/外星人、Surface、苹果电脑不能拆机哦~', + '提示:数据无价,请随时做好数据备份哦~', + '提示:204 也是实验室,请勿在内饮食~', + '提示:我们是志愿服务,不收取任何礼物哦~', + '提示:无论是有关于小程序的建议,还是关于E志者协会的建议,都可以在【意见反馈】处提出来哦!', + ], +}; + +export const tipsEnUs: TipsText = { + tipsText: [ + 'Tips: Please retrieve your devices before 20:30!', + 'Tips: Dell/Alienware, Surface, Apple cannot be dissassembled.', + 'Tips: Data is priceless, please backup your data at any time!', + 'Tips: 204 is also a laboratory. Do not eat inside.', + 'Tips: We are volunteers and do not take any gifts.', + 'Tips: Feel free to post your suggestions about the weapp or about us at [Account-Report]!', + ], +}; diff --git a/src/plain-text/index.ts b/src/plain-text/index.ts index 57a2859..4e213c8 100644 --- a/src/plain-text/index.ts +++ b/src/plain-text/index.ts @@ -16,6 +16,7 @@ import { ticketDetailZhCn, } from './TicketDetail'; import { CommonText, commonTextEnUs, commonTextZhCn } from './common'; +import { TipsText, tipsEnUs, tipsZhCn } from './Tips'; interface TextRecord { common: CommonText; @@ -32,6 +33,7 @@ interface TextRecord { navBar: NavBarTitle; repairPage: RepairPageText; ticketDetail: TicketDetailText; + tips: TipsText; } const textZhCn: TextRecord = { @@ -49,6 +51,7 @@ const textZhCn: TextRecord = { navBar: navBarTitleZhCn, repairPage: repairPageZhCn, ticketDetail: ticketDetailZhCn, + tips: tipsZhCn, }; const textEnUs: TextRecord = { @@ -66,6 +69,7 @@ const textEnUs: TextRecord = { navBar: navBarTitleEnUs, repairPage: repairPageEnUs, ticketDetail: ticketDetailEnUs, + tips: tipsEnUs, }; // type Lang = 'zh_CN' | 'en_US' | ...; diff --git a/src/service/currentTicket.ts b/src/service/currentTicket.ts index e261c99..8e42b55 100644 --- a/src/service/currentTicket.ts +++ b/src/service/currentTicket.ts @@ -2,10 +2,9 @@ import RepairPage from '@/pages/repair/repair'; import Taro from '@tarojs/taro'; import { TicketListItem } from '@/components/TicketListItem/TicketListItem'; import pt from '@/plain-text'; -import DetailFramework from '@/components/DetailFramework/DetailFramework'; import { getUrl } from '.'; -export function getCurrentTicket(that: RepairPage, middleButton, isInfoShow) { +export function getCurrentTicket(that: RepairPage) { Taro.request({ url: getUrl('/user/mytickets'), method: 'GET', @@ -15,14 +14,19 @@ export function getCurrentTicket(that: RepairPage, middleButton, isInfoShow) { }) .then((res) => { const data = res.data.data; - let newIdList: Array = []; + let newIdNameList: Array> = []; data.list.map((ticket: TicketListItem) => { if (ticket['status'] !== 5) { - newIdList.push(ticket.id); + newIdNameList.push( + new Map([ + [ticket['id'], ticket['device'] + ' ' + ticket['deviceModel']], + ]), + ); } }); + console.log(newIdNameList); that.setState({ - currentTicketsId: newIdList, + currentTicketsIdName: newIdNameList, }); }) .catch((err) => { diff --git a/src/service/dutyInfo.ts b/src/service/dutyInfo.ts index a714a4e..1d6da5f 100644 --- a/src/service/dutyInfo.ts +++ b/src/service/dutyInfo.ts @@ -4,7 +4,7 @@ import { getUrl } from '.'; export function getDutyInfo(that: MainPage) { Taro.request({ - url: getUrl('/dutyinfo'), + url: getUrl('/duty/info'), method: 'GET', data: { token: 'token_test', diff --git a/src/utils/random.ts b/src/utils/random.ts new file mode 100644 index 0000000..f2db933 --- /dev/null +++ b/src/utils/random.ts @@ -0,0 +1,3 @@ +export const randomInt = (floor: number, ceiling: number) => { + return Math.floor(Math.random() * (ceiling - floor + 1) + floor); +};