From 0250ae5601752bddbb51db8677611d018780c040 Mon Sep 17 00:00:00 2001 From: Haodong Ju InnerKenMac Date: Wed, 29 Jan 2020 12:07:03 +0100 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E5=89=8D=E7=AB=AF=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E8=8F=9C=E5=8D=95=E6=A0=8F=E6=A0=87=E9=A2=98=EF=BC=8C?= =?UTF-8?q?=E6=B3=A8=E9=87=8A=E6=8E=89=E4=BA=86=E9=9C=80=E8=A6=81=E9=9A=90?= =?UTF-8?q?=E8=97=8F=E7=9A=84=E9=83=A8=E5=88=86=E3=80=82=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E4=BA=86=E5=9F=8E=E5=B8=82=E5=88=97=E8=A1=A8=E5=92=8C=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix #23 --- source/page/Hospital/index.tsx | 46 ++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/source/page/Hospital/index.tsx b/source/page/Hospital/index.tsx index b932490..48b2297 100644 --- a/source/page/Hospital/index.tsx +++ b/source/page/Hospital/index.tsx @@ -1,5 +1,5 @@ import * as clipboard from 'clipboard-polyfill'; -import { component, mixin, createCell, Fragment } from 'web-cell'; +import { component, createCell, Fragment, mixin } from 'web-cell'; import { observer } from 'mobx-web-cell'; import { SpinnerBox } from 'boot-cell/source/Prompt/Spinner'; @@ -10,7 +10,7 @@ import 'boot-cell/source/Content/EdgeDetector'; import { EdgeEvent } from 'boot-cell/source/Content/EdgeDetector'; import { relativeTimeTo, TimeUnitName } from '../../utility'; -import { suppliesRequirement, SuppliesRequirement, session } from '../../model'; +import { session, SuppliesRequirement, suppliesRequirement } from '../../model'; interface HospitalPageState { loading?: boolean; @@ -32,8 +32,25 @@ export class HospitalPage extends mixin<{}, HospitalPageState>() { const data = await suppliesRequirement.getNextPage(); + this.getAllCities(data); await this.setState({ loading: false, noMore: !data }); }; + cities = []; + getAllCities = data => { + for (let i of data) { + let currentCity = i.address.city; + if (this.cities.indexOf(currentCity) === -1) { + this.cities.push(currentCity); + } + } + + this.cities = this.cities.map(name => { + return { + title: name, + href: `hospital/index?filter=${name}` + }; + }); + }; async clip2board(raw: string) { await clipboard.writeText(raw); @@ -126,8 +143,9 @@ export class HospitalPage extends mixin<{}, HospitalPageState>() { render(_, { loading, noMore }: HospitalPageState) { return ( - -
+ + {/*// */} +

医院急需物资

+
+ + 选择 + +
- {suppliesRequirement.list.map(this.renderItem)} + {(() => { + console.log('reloadData'); + let urlParams = new URLSearchParams( + window.location.search + ); + let filter = urlParams.get('filter'); + let data = suppliesRequirement.list; + if (filter) { + data = data.filter(item => { + item.address.city === filter; + }); + } + return data.map(this.renderItem); + })()}

{noMore ? '没有更多数据了' : '加载更多...'}