indexBasicInfo.jsx 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. import React from "react";
  2. import "./indexBasicInfo.css";
  3. import { Typography, Table, Button } from "antd";
  4. const { Text, Title, Link } = Typography;
  5. function hasClass(para) {
  6. let flag = false;
  7. para.forEach((item) => {
  8. if (item.children) {
  9. flag = true;
  10. }
  11. });
  12. return flag;
  13. }
  14. class indexBasicInfo extends React.Component {
  15. constructor(props) {
  16. super(props);
  17. // this.title = title[props.location.pathname];
  18. }
  19. render() {
  20. const sdkurl = this.props.location.state.sdk_url;
  21. const apiurl = this.props.location.state.apiurl;
  22. const inputPara = this.props.location.state.inputpara.map((item, index) => {
  23. return <Text key={index}>{item}</Text>;
  24. });
  25. const outPutList = this.props.location.state.data.outputResult;
  26. const errorList = this.props.location.state.data.errorResult;
  27. const title = this.props.location.state.name;
  28. return (
  29. <div>
  30. <Title level={4}>{title}</Title>
  31. <div>
  32. <Title className="stocks-title" level={5}>
  33. 输入参数:
  34. </Title>
  35. {inputPara}
  36. </div>
  37. <div>
  38. <Title className="stocks-title" level={5}>
  39. 输出结果:
  40. </Title>
  41. <Table
  42. className={{ "no-tab": hasClass(outPutList), "first-table": true }}
  43. columns={columns}
  44. dataSource={outPutList}
  45. pagination={false}
  46. size="small"
  47. />
  48. </div>
  49. <div>
  50. <Title className={"stocks-title"} level={5}>
  51. 输出结果异常:
  52. </Title>
  53. <Table
  54. columns={errColumns}
  55. dataSource={errorList}
  56. pagination={false}
  57. size="small"
  58. />
  59. </div>
  60. <div>
  61. <Title className="stocks-title" level={5}>
  62. 测试地址:
  63. </Title>
  64. <Button type="primary" className="stocks-button">
  65. <a href={apiurl} target="_blank">
  66. API测试工具
  67. </a>
  68. </Button>
  69. </div>
  70. <div>
  71. <Title className="stocks-title" level={5}>
  72. SDK包:
  73. </Title>
  74. <Link href={sdkurl}>php程序包下载</Link>
  75. </div>
  76. </div>
  77. );
  78. }
  79. }
  80. export default indexBasicInfo;
  81. const columns = [
  82. {
  83. title: "名称",
  84. dataIndex: "name",
  85. key: "name",
  86. render: (text) => <span>{text}</span>
  87. },
  88. {
  89. title: "说明",
  90. dataIndex: "desc",
  91. key: "desc"
  92. }
  93. ];
  94. const errColumns = [
  95. {
  96. title: "错误类型",
  97. dataIndex: "type",
  98. key: "type",
  99. render: (text) => <span>{text}</span>
  100. },
  101. {
  102. title: "message_code",
  103. dataIndex: "code",
  104. key: "code"
  105. },
  106. {
  107. title: "message",
  108. dataIndex: "message",
  109. key: "message"
  110. }
  111. ];