index.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. import React from 'react';
  2. import { Tooltip } from 'antd';
  3. import './index.less';
  4. import Assets from '@src/components/Assets';
  5. import PieChart from '@src/components/PieChart';
  6. import { formatDate } from '@src/services/Tools';
  7. import Module from '../Module';
  8. import ProgressButton from '../ProgressButton';
  9. import Button from '../Button';
  10. function makePie(value, text, subtext) {
  11. return {
  12. title: {
  13. text,
  14. textAlign: 'center',
  15. textVerticalAlign: 'middle',
  16. subtext,
  17. top: '28%',
  18. left: '48%',
  19. },
  20. tooltip: {
  21. show: false,
  22. },
  23. // value < 50 ? '#f19057' :
  24. color: ['#6966fb', '#f7f7f7'],
  25. series: [
  26. {
  27. type: 'pie',
  28. radius: ['90%', '100%'],
  29. label: {
  30. show: false,
  31. },
  32. data: [value, 100 - value],
  33. silent: true,
  34. },
  35. ],
  36. };
  37. }
  38. export default function Panel(props) {
  39. const { style, message, data = {}, col = 3, title, onClick } = props;
  40. return (
  41. <Module style={style} className="panel">
  42. <div className="header">
  43. <span>{title}</span>
  44. {message && (
  45. <Tooltip title={message} trigger="click">
  46. <Assets className="qa" name="QA" svg />
  47. </Tooltip>
  48. )}
  49. </div>
  50. <div className="body">
  51. <div className="chart-info">
  52. <PieChart option={makePie(data.pieValue, data.pieText, data.pieSubText)} width={110} height={110} />
  53. <div className="info">
  54. {(data.info || []).map(row => {
  55. return (
  56. <div className="item">
  57. <div className="title">{row.title}</div>
  58. <div className="data">
  59. <span className="text">{row.number}</span>
  60. {row.unit}
  61. </div>
  62. </div>
  63. );
  64. })}
  65. {(data.desc || []).length > 0 && (
  66. <div className="desc-wrapper">
  67. {(data.desc || []).map(row => {
  68. return <div className="desc">{row}</div>;
  69. })}
  70. </div>
  71. )}
  72. </div>
  73. </div>
  74. <div className={`list col-${col}`}>
  75. {(data.children || []).map(item => {
  76. return (
  77. <ProgressButton
  78. className="item ws-n"
  79. progress={item.progress}
  80. onClick={() => {
  81. if (onClick) onClick(item);
  82. }}
  83. >
  84. {item.title}
  85. </ProgressButton>
  86. );
  87. })}
  88. </div>
  89. </div>
  90. </Module>
  91. );
  92. }
  93. export function WaitPanel(props) {
  94. const { style, message, data = {}, col = 3, title, onClick, onOpen } = props;
  95. return (
  96. <Module style={style} className="panel wait-panel">
  97. <div className="header">
  98. <span>{title}</span>
  99. {message && (
  100. <Tooltip title={message} trigger="click">
  101. <Assets className="qa" name="QA" svg />
  102. </Tooltip>
  103. )}
  104. </div>
  105. <div className="body">
  106. <div className="chart-info">
  107. <div className="info">
  108. <div className="text">您还未开通本月机经</div>
  109. {(data.desc || []).length > 0 && (
  110. <div className="desc-wrapper">
  111. {(data.desc || []).map(row => {
  112. return <div className="desc">{row}</div>;
  113. })}
  114. </div>
  115. )}
  116. {(data.info || []).map(row => {
  117. return (
  118. <div className="item">
  119. <div className="title">{row.title}</div>
  120. <div className="data">
  121. <span className="text">{row.number}</span>
  122. {row.unit}
  123. </div>
  124. </div>
  125. );
  126. })}
  127. </div>
  128. </div>
  129. <div className={`list col-${col}`}>
  130. {(data.children || []).map(item => {
  131. return (
  132. <ProgressButton
  133. className="item"
  134. progress={item.progress}
  135. onClick={() => {
  136. if (onClick) onClick(item);
  137. }}
  138. >
  139. {item.title}
  140. </ProgressButton>
  141. );
  142. })}
  143. </div>
  144. <Button size="lager" radius onClick={() => onOpen && onOpen()}>
  145. 立即开通
  146. </Button>
  147. </div>
  148. </Module>
  149. );
  150. }
  151. export function BuyPanel(props) {
  152. const { style, message, title, onBuy } = props;
  153. return (
  154. <Module style={style} className="panel buy-panel">
  155. <div className="header">
  156. <span>{title}</span>
  157. {message && (
  158. <Tooltip title={message} trigger="click">
  159. <Assets className="qa" name="QA" svg />
  160. </Tooltip>
  161. )}
  162. </div>
  163. <div className="body">
  164. <Assets name="banner" />
  165. <div className="text">您还未购买本月机经</div>
  166. <Button radius size="small" width={80} onClick={() => onBuy && onBuy()}>
  167. 立即购买
  168. </Button>
  169. </div>
  170. </Module>
  171. );
  172. }
  173. export function SmallPanel(props) {
  174. const { style, title, lock, data = {}, onClick } = props;
  175. const { expireTime, needService } = data;
  176. return (
  177. <Module style={style} className="panel small-panel">
  178. <div className="header">
  179. <span>{title}</span>
  180. {lock && <Assets name="lock" />}
  181. </div>
  182. <div className="body" onClick={() => onClick && onClick()}>
  183. <div className="chart-info">
  184. <PieChart option={makePie(data.pieValue, data.pieText, data.pieSubText)} width={110} height={110} />
  185. <div className="info">
  186. {(data.info || []).map(row => {
  187. return (
  188. <div className="item">
  189. <div className="title">{row.title}</div>
  190. <div className="data">
  191. <span className="text">{row.number}</span>
  192. {row.unit}
  193. </div>
  194. </div>
  195. );
  196. })}
  197. {needService && <div className="date">有效期至:{expireTime && formatDate(expireTime, 'YYYY-MM-DD')}</div>}
  198. </div>
  199. </div>
  200. </div>
  201. </Module>
  202. );
  203. }
  204. export function SmallWaitPanel(props) {
  205. const { style, title, lock, data = {}, onOpen } = props;
  206. const { endTime } = data;
  207. return (
  208. <Module style={style} className="panel small-wait-panel">
  209. <div className="header">
  210. <span>{title}</span>
  211. {lock && <Assets name="lock" />}
  212. </div>
  213. <div className="body">
  214. <div className="title">请于{endTime && formatDate(endTime, 'YYYY-MM-DD')}前开通</div>
  215. <div className="btn">
  216. <Button size="lager" width={120} radius onClick={() => onOpen && onOpen()}>
  217. 立即开通
  218. </Button>
  219. </div>
  220. </div>
  221. </Module>
  222. );
  223. }
  224. export function SmallBuyPanel(props) {
  225. const { style, title, lock, onBuy } = props;
  226. return (
  227. <Module style={style} className="panel small-buy-panel">
  228. <div className="header">
  229. <span>{title}</span>
  230. {lock && <Assets name="lock" />}
  231. </div>
  232. <div className="body">
  233. <Assets name="banner_1" />
  234. <Button radius size="small" width={80} onClick={() => onBuy && onBuy()}>
  235. 立即购买
  236. </Button>
  237. </div>
  238. </Module>
  239. );
  240. }