- 观影人:
+ 观影人 :
收货地址:
diff --git a/src/component/login.tsx b/src/component/login.tsx
index ec6d0dd..d58d6eb 100644
--- a/src/component/login.tsx
+++ b/src/component/login.tsx
@@ -1,9 +1,9 @@
import React from "react";
import {Button, Form, Input, message} from "antd";
import {post} from "../util/http";
-import {LOGIN_PWD} from "../network/request";
import {ApiParams} from "../network/apiParams";
import {store} from "../constant/store";
+import {LOGIN_PWD} from "../network/api/login";
class LoginForm extends React.Component {
diff --git a/src/component/search.tsx b/src/component/search.tsx
index 6ffd043..552482f 100644
--- a/src/component/search.tsx
+++ b/src/component/search.tsx
@@ -1,60 +1,53 @@
import React, {useState} from "react";
-import {Button, Card, Input, Select, Form} from "antd";
-// import jsonp from 'reques';
-import qs from 'qs';
+import {Select, Form} from "antd";
+import {post} from "../util/http";
+import {ACTIVITY_DETAIL, ActivityDetail, SEARCH, SearchResult} from "../network/api/search";
+import {ApiParams} from "../network/apiParams";
-const Search: React.FC = () => {
- const {Option} = Select;
+export type SearchProps = {
+ activityChange : (value: number) => void
+}
- let timeout: ReturnType | null;
- let currentValue: string;
+const Search: React.FC = (props) => {
- const fetchData = (value: string, callback: (data: { value: string; text: string }[]) => void) => {
- if (timeout) {
- clearTimeout(timeout);
- timeout = null;
- }
- currentValue = value;
-
- const fake = () => {
- const str = qs.stringify({
- code: 'utf-8',
- q: value,
- });
- fetch(`https://suggest.taobao.com/sug?${str}`)
- .then((response: any) => response.json())
- .then((d: any) => {
- if (currentValue === value) {
- const {result} = d;
- const data = result.map((item: any) => ({
- value: item[0],
- text: item[0],
- }));
- callback(data);
- }
- });
- };
+ const {Option} = Select;
- timeout = setTimeout(fake, 300);
+ // 演出搜索
+ const fetchData = (value: string, callback: (data: any[]) => void) => {
+ // 判断value 是否是纯数字,纯数字调用activity_detail接口,否则调用activity_search接口
+ if (/^\d+$/.test(value)) {
+ let apiParams = new ApiParams();
+ apiParams.set("activityId", value);
+ post(ACTIVITY_DETAIL, apiParams, (data: ActivityDetail) => {
+ callback([data])
+ })
+ } else {
+ let apiParams = new ApiParams();
+ apiParams.set("keyword", value);
+ apiParams.set("pageNo", 1);
+ apiParams.set("pageSize", 20);
+ post(SEARCH, apiParams, (data: SearchResult) => {
+ callback(data.activityInfo)
+ })
+ }
};
const [data, setData] = useState([]);
- const [value, setValue] = useState();
+ const [value, setValue] = useState();
const handleSearch = (newValue: string) => {
if (newValue) {
fetchData(newValue, setData);
- } else {
- setData([]);
}
};
- const handleChange = (newValue: string) => {
+ const handleChange = (newValue: number) => {
setValue(newValue);
+ props.activityChange(newValue)
};
- const options = data.map(d => );
+ const options = data.map(d => );
return (
<>
@@ -66,7 +59,6 @@ const Search: React.FC = () => {
showSearch
value={value}
placeholder="搜索"
- // style={props.style}
defaultActiveFirstOption={false}
showArrow={false}
filterOption={false}
@@ -77,7 +69,6 @@ const Search: React.FC = () => {
{options}
-
>
);
}
diff --git a/src/component/ticket.tsx b/src/component/ticket.tsx
index 8fb3e73..36ca457 100644
--- a/src/component/ticket.tsx
+++ b/src/component/ticket.tsx
@@ -1,22 +1,96 @@
-import React from "react";
-import {Form, Select} from "antd";
+import React, {useEffect, useState} from "react";
+import {Cascader, Form, FormInstance, InputNumber} from "antd";
+import {post} from "../util/http";
+import {TICKET_LIST, TicketInfo, TicketListResult} from "../network/api/ticket";
+import {ApiParams} from "../network/apiParams";
-const Ticket: React.FC = () => {
+
+export type TicketProps = {
+ activityId: number | undefined
+ ticketChange: (tickerInfo: TicketInfo) => void
+ form: FormInstance
+}
+
+const Ticket: React.FC = (props) => {
+ const [options, setOptions] = useState