template.tsx 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. import { Card, Col, Row } from "antd";
  2. import jb from '../../../../../public/jb.png';
  3. import vip from '../../../../../public/vip.png';
  4. import top from '../../../../../public/top-r1.png';
  5. import { createStyles } from "antd-style";
  6. import { useModel } from "@umijs/max";
  7. export function Template(params: { data: any }) {
  8. let { data } = params
  9. let { getEnum } = useModel("global")
  10. let { firstRecharge, rechargeConfigList } = data
  11. const useStyles = createStyles((props) => {
  12. let { token } = props
  13. let navTheme = localStorage.getItem("navTheme")//全局 2亮色 3黑色
  14. return {
  15. cardBox: {
  16. position: 'relative'
  17. },
  18. bgVip: {
  19. backgroundImage: "linear-gradient(180deg, #fff1dc 60%, #fffdfa 100%)",
  20. color: navTheme == "3" ? "#000" : "unset"
  21. },
  22. bg: {
  23. backgroundImage: 'linear-gradient(180deg, #ffeced 60%, #fffafa 100%)',
  24. color: navTheme == "3" ? "#000" : "unset"
  25. },
  26. topRight: {
  27. lineHeight: '20px',
  28. background: "#ff2441",
  29. position: 'absolute',
  30. top: 0,
  31. right: 0,
  32. fontSize: 12,
  33. borderRadius: "0px 8px 0 8px",
  34. },
  35. topRightVip: {
  36. background: "#ffd89d !important",
  37. },
  38. //
  39. topRightSpan1: { display: 'inline-block', background: `url(${top}) no-repeat`, minWidth: 40, height: 20, padding: "0 10px 0 6px", backgroundSize: "100% 100%", color: "#fff" },
  40. topRightSpan2: { color: "#fff", display: 'inline-block', padding: "0 5px" },
  41. del: { fontSize: 14, textDecoration: 'line-through', marginLeft: 7, color: token.colorTextTertiary, fontWeight: "500" }
  42. }
  43. });
  44. let { styles } = useStyles()
  45. return <Card bordered={false} >
  46. <Row gutter={[0, 15]}>
  47. {
  48. rechargeConfigList?.map((item: any, index: any) => {
  49. let {
  50. color,//背景色
  51. description,//整数购买文案
  52. extra,//右上角描述值
  53. gearType,//充值类型
  54. gift,//赠送
  55. obtain,//获得书币/vip每天价格
  56. price,//价格
  57. subscript,//右上角文案 首充|超值等
  58. vipDays,//vip天数
  59. } = item
  60. switch (gearType) {
  61. case 1://充值
  62. return <Col key={index} span={11} offset={index % 2 === 0 ? 0 : 1} >
  63. <Card className={`${styles.cardBox} ${color && styles.bg}`} styles={{ body: { maxHeight: 90, padding: '20px 15px' } }}>
  64. {/* 右上角 */}
  65. <div className={`${styles.topRight}`} style={subscript ? { borderRadius: "8px 8px 0 8px", } : {}} >
  66. {
  67. <>
  68. {subscript && <span className={styles.topRightSpan1}>{subscript}</span>}
  69. <span className={styles.topRightSpan2} style={subscript ? { transform: 'translateX(-4px)' } : {}}>多送{extra}元</span>
  70. </>
  71. }
  72. </div>
  73. <div style={{ display: 'flex', flexFlow: 'column' }}>
  74. <strong >
  75. <span style={{ fontSize: '20px', marginRight: 3 }} >¥</span>
  76. <span style={{ fontSize: 22, fontFamily: 'Yuewen Font' }}>{price}</span>
  77. </strong>
  78. <span style={{ fontSize: 12, marginTop: 2, color: "#777", display: 'block' }}>{obtain}书币 送{gift}书券</span>
  79. </div>
  80. {color && <img src={jb} style={{ position: 'absolute', right: 0, bottom: 0, width: 50 }} />}
  81. </Card>
  82. </Col>
  83. case 2://vip
  84. let vipEnum = getEnum("VIP_DAYS","arr")
  85. let vipStr = vipEnum?.find((i: { value: any; }) => i.value === vipDays)?.label || ""
  86. return <Col key={index} span={11} offset={index % 2 === 0 ? 0 : 1} >
  87. <Card className={`${styles.cardBox} ${color && styles.bgVip}`} styles={{ body: { maxHeight: 90, padding: '20px 15px' } }}>
  88. {/* 右上角 */}
  89. <div className={`${styles.topRight} ${styles.topRightVip}`} style={subscript ? { borderRadius: "8px 8px 0 8px", } : {}}>
  90. {
  91. <>
  92. {subscript && <span className={styles.topRightSpan1}>{subscript}</span>}
  93. <span className={styles.topRightSpan2}>{vipStr}</span>
  94. </>
  95. }
  96. </div>
  97. <div style={{ display: 'flex', flexFlow: 'column' }}>
  98. <strong >
  99. <span style={{ fontSize: '20px', marginRight: 3 }} >¥</span>
  100. <span style={{ fontSize: 22, fontFamily: 'Yuewen Font' }}>{price}</span>
  101. </strong>
  102. <span style={{ fontSize: 12, marginTop: 2, color: "#777", display: 'block' }}>¥{obtain}元/天</span>
  103. </div>
  104. {color && <img src={vip} style={{ position: 'absolute', right: 0, bottom: 0, width: 30 }} />}
  105. </Card>
  106. </Col>
  107. case 3://整本
  108. return <Col key={index} span={11} offset={index % 2 === 0 ? 0 : 1} >
  109. <Card className={`${styles.cardBox} `} styles={{ body: { maxHeight: 90, padding: '20px 15px' } }}>
  110. {/* 右上角 */}
  111. <div className={styles.topRight}>
  112. {
  113. subscript ? <> <span>{item.description}</span></> : <>
  114. <span className={styles.topRightSpan1}>{subscript}</span>
  115. <span className={styles.topRightSpan2}>{item.description}</span>
  116. </>
  117. }
  118. </div>
  119. <div style={{ display: 'flex', flexFlow: 'column' }}>
  120. <strong >
  121. <span style={{ fontSize: '20px', marginRight: 3 }} >¥</span>
  122. <span style={{ fontSize: 22, fontFamily: 'Yuewen Font' }}>{price}</span>
  123. {/* {isVip && item.gift && <span className={styles.del}>¥{item.gift}</span>} */}
  124. </strong>
  125. {/* {isVip ?
  126. <span style={{ fontSize: 12, marginTop: 2, color: "#777", display: 'block' }}>{isOne ? "仅" : "¥"}{item.extra}元/天</span>
  127. :
  128. <span style={{ fontSize: 12, marginTop: 2, color: "#777", display: 'block' }}>{item.gift}书币 送{item.extra}书券</span>} */}
  129. </div>
  130. {/* {isOne && <img src={isVip ? vip : jb} style={{ position: 'absolute', right: 0, bottom: 0, width: isVip ? 30 : 50 }} />} */}
  131. </Card>
  132. </Col>
  133. default:
  134. break;
  135. }
  136. })
  137. }
  138. </Row>
  139. </Card >
  140. }