add random tips on currentTicket card
parent
9931b23337
commit
60f10eaa8f
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -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<number>;
|
||||
currentTicketsId: Array<number>;
|
||||
currentTicketsIdName: Array<Map<number, string>>;
|
||||
}
|
||||
|
||||
const submitInterval = 5000;
|
||||
|
|
@ -56,11 +57,11 @@ export default class RepairPage extends Component<{}, RepairPageState> {
|
|||
isLoading: false,
|
||||
isDisable: true,
|
||||
checkedList: [0],
|
||||
currentTicketsId: [] as Array<number>,
|
||||
currentTicketsIdName: [] as Array<Map<number, string>>,
|
||||
};
|
||||
|
||||
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) => (
|
||||
<AtCard key={idx}>
|
||||
const ticketsRenderer = this.state.currentTicketsIdName.map((pair, idx) => (
|
||||
<AtCard
|
||||
key={idx}
|
||||
title={pair.get(pair.keys()[0])}
|
||||
extra={pt.get().repairPage.currentTicket.extra}
|
||||
note={
|
||||
pt.get().tips.tipsText[
|
||||
randomInt(0, pt.get().tips.tipsText.length - 1)
|
||||
]
|
||||
}
|
||||
>
|
||||
<DetailFramework
|
||||
id={id}
|
||||
id={pair.keys()[0]}
|
||||
isInfoShow={isInfoShow}
|
||||
middleButton={middleButton}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
export interface TipsText {
|
||||
tipsText: Array<string>;
|
||||
}
|
||||
|
||||
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]!',
|
||||
],
|
||||
};
|
||||
|
|
@ -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' | ...;
|
||||
|
|
|
|||
|
|
@ -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<number> = [];
|
||||
let newIdNameList: Array<Map<number, string>> = [];
|
||||
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) => {
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
export const randomInt = (floor: number, ceiling: number) => {
|
||||
return Math.floor(Math.random() * (ceiling - floor + 1) + floor);
|
||||
};
|
||||
Loading…
Reference in New Issue