diff --git a/mock/uncompleted.json b/mock/uncompleted.json index fefffa8..253b379 100644 --- a/mock/uncompleted.json +++ b/mock/uncompleted.json @@ -1,7 +1,7 @@ { "list": [ { - "id": 6830, + "id": 6832, "type": 1, "status": 2, "device": "ROG", diff --git a/src/components/DetailFramework/DetailFramework.tsx b/src/components/DetailFramework/DetailFramework.tsx index 950e6a6..fc2175d 100644 --- a/src/components/DetailFramework/DetailFramework.tsx +++ b/src/components/DetailFramework/DetailFramework.tsx @@ -1,15 +1,36 @@ import { View } from '@tarojs/components'; import { Component, ReactNode } from 'react'; import Taro from '@tarojs/taro'; -import { ShowElements } from '@/pages/TicketDetail/TicketNote'; -import PageFooter from '@/components/PageFooter/PageFooter'; +import { + ShowElements, + TicketInfo, + TicketNote, +} from '@/pages/TicketDetail/TicketNote'; import pt from '@/plain-text'; import { RequestState } from '@/service'; import { getTicketInfo } from '@/service/ticketsInfo'; +import { FixStatus } from '@/common'; +import { AtCard, AtSteps } from 'taro-ui'; +import NoteList from '../NoteList/NoteList'; + +interface StepItemData { + title: string; +} + +const mapStatusStep: Map = new Map([ + [1, 0], + [2, 1], + [3, 2], + [4, 2], + [5, 3], +]); interface DetailFrameworkState { + current: number; + items: Array; + ticketInfo: TicketInfo; + notes: Array; rs: RequestState; - elements: ShowElements; } interface DetailFrameworkProps { @@ -23,8 +44,11 @@ export default class DetailFramework extends Component< DetailFrameworkState > { state = { + current: 0, + items: [], + ticketInfo: new TicketInfo(), + notes: [new TicketNote()], rs: new RequestState(), - elements: new ShowElements(), }; componentDidMount(): void { @@ -32,7 +56,7 @@ export default class DetailFramework extends Component< Taro.setNavigationBarTitle({ title: navBar.ticketDetail, }); - getTicketInfo(this, this.props.id, this.props.isInfoShow); + getTicketInfo(this, this.props.id); } props: Readonly = { @@ -55,15 +79,74 @@ export default class DetailFramework extends Component< return Request failed; } + const status = this.state.ticketInfo.status; + this.setState({ + current: mapStatusStep.get(status) || 0, + items: pt.get().ticketDetail.stepItems, + }); + + const elements: ShowElements = { + device: this.props.isInfoShow['device'] ? ( + + {this.state.ticketInfo.device + + ' ' + + this.state.ticketInfo.deviceModel} + + ) : ( + + ), + createdTime: this.props.isInfoShow['createdTime'] ? ( + + {pt.get().common.createdAtText(this.state.ticketInfo.createdTime)} + + ) : ( + + ), + description: this.props.isInfoShow['description'] ? ( + + + + {this.state.ticketInfo.description} + + + + ) : ( + + ), + current: this.props.isInfoShow['current'] ? ( + + {}} + /> + + ) : ( + + ), + notelist: this.props.isInfoShow['notelist'] ? ( + this.props.isInfoShow['showAllNotes'] ? ( + + + + ) : ( + + + + ) + ) : ( + + ), + }; + return ( - {this.state.elements.device} - {this.state.elements.createdTime} - {this.state.elements.description} - {this.state.elements.current} + {elements.device} + {elements.createdTime} + {elements.description} + {elements.current} {this.props.middleButton} - {this.state.elements.notelist} - + {elements.notelist} ); } diff --git a/src/pages/TicketDetail/TicketDetail.tsx b/src/pages/TicketDetail/TicketDetail.tsx index ac2bf9a..0d61d5c 100644 --- a/src/pages/TicketDetail/TicketDetail.tsx +++ b/src/pages/TicketDetail/TicketDetail.tsx @@ -4,6 +4,7 @@ import { getCurrentInstance } from '@tarojs/runtime'; import pt from '@/plain-text'; import { AtButton } from 'taro-ui'; import DetailFramework from '@/components/DetailFramework/DetailFramework'; +import PageFooter from '@/components/PageFooter/PageFooter'; interface TicketDetailState { id: number; @@ -59,6 +60,7 @@ export default class TicketDetail extends Component<{}, TicketDetailState> { id={this.state.id} isInfoShow={isInfoShow} /> + ); } diff --git a/src/pages/repair/repair.tsx b/src/pages/repair/repair.tsx index 2d2fd2d..f0f78cb 100644 --- a/src/pages/repair/repair.tsx +++ b/src/pages/repair/repair.tsx @@ -15,6 +15,7 @@ import PageFooter from '@/components/PageFooter/PageFooter'; import { submitTicket } from '@/service/submitTicket'; import type CustomTabBar from '@/custom-tab-bar'; import repairLogo from '@/assets/icons/RepairPage/repair.svg'; +import DetailFramework from '@/components/DetailFramework/DetailFramework'; import './repair.scss'; interface RepairPageState { @@ -145,6 +146,16 @@ export default class RepairPage extends Component<{}, RepairPageState> { } render(): ReactNode { + const middleButton = ; + + const isInfoShow = { + device: true, + createdTime: true, + description: false, + current: true, + notelist: true, + showAllNotes: false, + }; return ( diff --git a/src/service/currentTicket.ts b/src/service/currentTicket.ts new file mode 100644 index 0000000..4768fbf --- /dev/null +++ b/src/service/currentTicket.ts @@ -0,0 +1,19 @@ +import RepairPage from '@/pages/repair/repair'; +import Taro from '@tarojs/taro'; +import { getUrl } from '.'; + +export function getCurrentTicket(that: RepairPage) { + Taro.request({ + url: getUrl('/user/mytickets'), + method: 'GET', + data: { + token: 'token_test', + }, + }) + .then((res) => { + const data = res.data.data; + }) + .catch((err) => { + console.log(err); + }); +} diff --git a/src/service/ticketsInfo.tsx b/src/service/ticketsInfo.tsx index ad6a292..9e6c42d 100644 --- a/src/service/ticketsInfo.tsx +++ b/src/service/ticketsInfo.tsx @@ -1,36 +1,10 @@ -import { - TicketInfo, - TicketNote, - ShowElements, -} from '@/pages/TicketDetail/TicketNote'; +import { TicketInfo, TicketNote } from '@/pages/TicketDetail/TicketNote'; import DetailFramework from '@/components/DetailFramework/DetailFramework'; import Taro from '@tarojs/taro'; -import { View } from '@tarojs/components'; -import pt from '@/plain-text'; -import { AtCard, AtSteps } from 'taro-ui'; import moment from 'moment'; -import NoteList from '@/components/NoteList/NoteList'; -import { FixStatus } from '@/common'; import { getUrl } from '.'; -const mapStatusStep: Map = new Map([ - [1, 0], - [2, 1], - [3, 2], - [4, 2], - [5, 3], -]); - -interface StepItemData { - title: string; -} - -export function getTicketInfo( - that: DetailFramework, - id: number, - isInfoShow: { [key: string]: boolean }, -) { - const items: Array = pt.get().ticketDetail.stepItems; +export function getTicketInfo(that: DetailFramework, id: number) { Taro.request({ url: getUrl('/tickets/info'), method: 'GET', @@ -65,60 +39,10 @@ export function getTicketInfo( createdTime: moment(item.createdTime as string), }); }); - const elements: ShowElements = { - device: isInfoShow['device'] ? ( - - {ticketDetail.device + ' ' + ticketDetail.deviceModel} - - ) : ( - - ), - createdTime: isInfoShow['createdTime'] ? ( - - {pt.get().common.createdAtText(ticketDetail.createdTime)} - - ) : ( - - ), - description: isInfoShow['description'] ? ( - - - - {ticketDetail.description} - - - - ) : ( - - ), - current: isInfoShow['current'] ? ( - - {}} - /> - - ) : ( - - ), - notelist: isInfoShow['notelist'] ? ( - isInfoShow['showAllNotes'] ? ( - - - - ) : ( - - - - ) - ) : ( - - ), - }; that.setState({ + ticketInfo: ticketDetail, + notes: notes, rs: former.trans(true), - elements: elements, }); } })