index.js 7.2 KB

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