custom-card-cover.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  1. <!-- 自定义卡片红包封面 -->
  2. <template>
  3. <div class="custom-card" v-if="data.customPosterUrl">
  4. <img class="customImg" :src="data.customPosterUrl" />
  5. <div class="common-bottom">
  6. <div class="theme">
  7. <img v-if="isLottaryCpd" class="icon" :src="require('@/assets/svg/icon-last-time.svg')"/>
  8. <span v-if="isLottaryCpd" class="time" >{{data.countDown || formatSecondsAsDaysOrTime(data.validityDuration * 3600)}}</span>
  9. <span class="info">{{isLottaryCpd ? 'Left' : 'Instant Giveaway'}}</span>
  10. </div>
  11. <div class="winner-info">
  12. <component-zoom width="320" fontSize="12">
  13. <span class="count">{{data.totalCount}} Winners</span>
  14. <span>to Share </span>
  15. <span class="prize-name">{{isMoneyRewardCpd ? data.amountValue + ' ' + data.tokenSymbol : data.customizedReward}}</span>
  16. </component-zoom>
  17. </div>
  18. <div class="open-btn" @click="open">
  19. {{isLottaryCpd ? 'Participate Now' : 'Open Now'}}
  20. </div>
  21. </div>
  22. </div>
  23. <div class="not-open" v-else-if="isMoneyRewardCpd">
  24. <img class="cover" v-if="data.type == 2" :src="require('@/assets/svg/img-preview-draw-bg.svg')" />
  25. <img class="cover" v-else :src="require('@/assets/subject/001-card.png')" />
  26. <img class="open-gif"
  27. v-if="data.type == 2"
  28. src="@/assets/img/img-preview-draw-box.png" />
  29. <img class="open-gif"
  30. v-else
  31. :src="require('@/assets/gif/001.gif')" />
  32. <img v-if="data.type == 2"
  33. :src="require('@/assets/svg/img-preview-draw-open.svg')"
  34. class="open"
  35. @click="open" />
  36. <img v-else
  37. :src="require('@/assets/svg/icon-open.svg')"
  38. class="open"
  39. @click="open"/>
  40. <div class="title" v-if="data.userInfo">
  41. <img :src="data.userInfo.avatarUrl" />
  42. <span>{{
  43. data.userInfo.nickName || ""
  44. }}</span>
  45. </div>
  46. <div class="money-area">
  47. <div class="txt">
  48. <span>{{data.currencyCode == 'USD' ? 'US Dollar' : data.tokenSymbol}} </span>
  49. &nbsp;GIVEAWAY
  50. </div>
  51. <div class="coin">
  52. <img :src="data.currencyIconUrl || imgHeaderCover" />
  53. <span id="preview-after-amount"
  54. :style="{
  55. fontSize: amount_font_size + 'px'
  56. }">{{ data.amountValue }}</span>
  57. </div>
  58. <div class="time-area" v-if="data.type == 2">
  59. <img class="icon-clock" :src="require('@/assets/svg/icon-time.svg')" />
  60. {{data.countDown || formatSecondsAsDaysOrTime(data.validityDuration * 3600)}}
  61. </div>
  62. <div class="people" v-else>
  63. {{ data.totalCount }} WINNERS TO SHARE
  64. </div>
  65. </div>
  66. </div>
  67. <!-- 改版之后的卡片 -->
  68. <div class="custom-card" v-else>
  69. <img class="cover" v-if="isLottaryCpd" :src="require('@/assets/subject/img-custom-lottary-bg.svg')" />
  70. <img class="cover" v-else :src="require('@/assets/subject/img-custom-common-bg.svg')" />
  71. <img class="gift" :src="require('@/assets/subject/icon-gift.gif')" />
  72. <div class="prize">
  73. <component-zoom width="300" fontSize="22">
  74. <img class="icon" :src="require('@/assets/subject/icon-gift-inline.svg')"/>
  75. <span class="name" id="custom-name" >
  76. {{data.customizedReward}}
  77. <span class="total" >X{{data.totalCount}}</span>
  78. </span>
  79. </component-zoom>
  80. </div>
  81. <!-- 底部公共模块 -->
  82. <div class="common-bottom">
  83. <div class="theme">
  84. <img v-if="isLottaryCpd" class="icon" :src="require('@/assets/svg/icon-last-time.svg')"/>
  85. <span v-if="isLottaryCpd" class="time" >{{data.countDown || formatSecondsAsDaysOrTime(data.validityDuration * 3600)}}</span>
  86. <span class="info">{{isLottaryCpd ? 'Left' : 'Instant Giveaway'}}</span>
  87. </div>
  88. <div class="winner-info">
  89. <component-zoom width="300" fontSize="12">
  90. <span class="count">{{data.totalCount}}Winners</span>
  91. <span>to Share </span>
  92. <span class="prize-name">{{isMoneyRewardCpd ? data.amountValue + ' ' + data.tokenSymbol : data.customizedReward}}</span>
  93. </component-zoom>
  94. </div>
  95. <div class="open-btn" @click="open">
  96. {{isLottaryCpd ? 'Participate Now' : 'Open Now'}}
  97. </div>
  98. </div>
  99. </div>
  100. </template>
  101. <script setup>
  102. import { defineProps, defineEmits, ref, computed, onMounted } from "vue";
  103. import { formatSecondsAsDaysOrTime } from "@/uilts/help";
  104. import ComponentZoom from "./component-zoom.vue";
  105. import { RewardType, PlayType } from "@/types";
  106. const props = defineProps({
  107. data: {
  108. type: Object,
  109. default: () => {
  110. return {
  111. totalCount: 0,
  112. amountValue: 0,
  113. tokenSymbol: '',
  114. currencyCode: '',
  115. type: 1,
  116. validityDuration: '',
  117. countDown: '',
  118. customPosterUrl: '',
  119. userInfo: {
  120. avatarUrl: "",
  121. nickName: "",
  122. },
  123. rewardType: RewardType.money,
  124. customizedReward: "",
  125. };
  126. },
  127. },
  128. });
  129. let isMoneyRewardCpd =computed(() => {
  130. return props.data.rewardType === RewardType.money
  131. });
  132. let isLottaryCpd = computed(() => props.data.type === PlayType.lottery);
  133. const defaultBaseWidth = isMoneyRewardCpd.value ? 56 : 22;
  134. const defaultTotalWidth = isMoneyRewardCpd.value ? 360 : 450;
  135. let amount_font_size = ref(defaultBaseWidth);
  136. const setFontSize = () =>{
  137. let id = isMoneyRewardCpd.value ? 'preview-after-amount' : 'custom-name';
  138. let lendom = document.querySelector(`#${id}`);
  139. if (lendom) {
  140. let lenstr = lendom.innerText.length;
  141. let num = parseInt(defaultTotalWidth / lenstr);
  142. amount_font_size.value = num < defaultBaseWidth ? num : defaultBaseWidth;
  143. }
  144. }
  145. const emits = defineEmits(["clickOpenRedPacket"]);
  146. const open = () => {
  147. emits("clickOpenRedPacket", {});
  148. };
  149. onMounted(() => {
  150. setFontSize()
  151. })
  152. </script>
  153. <style scoped lang="scss">
  154. .not-open {
  155. width: 100%;
  156. height: 100%;
  157. position: relative;
  158. border-radius: 16px;
  159. filter: drop-shadow(0px 2px 20px rgba(0, 0, 0, 0.1));
  160. .money-area {
  161. width: 100%;
  162. position: absolute;
  163. top: 65px;
  164. .txt {
  165. font-weight: 800;
  166. font-size: 16px;
  167. letter-spacing: 0.3px;
  168. color: #ffffff;
  169. display: flex;
  170. align-items: center;
  171. justify-content: center;
  172. span {
  173. color: #F9C545;
  174. }
  175. }
  176. .coin {
  177. text-align: center;
  178. width: 100%;
  179. padding: 6px 0;
  180. margin: 0 auto;
  181. display: flex;
  182. align-items: center;
  183. justify-content: center;
  184. img {
  185. width: 46px;
  186. height: 46px;
  187. border-radius: 50%;
  188. border: 3px solid #ffffff;
  189. }
  190. span {
  191. margin-left: 15px;
  192. font-weight: 800;
  193. font-size: 60px;
  194. line-height: 76px;
  195. color: #ffffff;
  196. }
  197. }
  198. .people {
  199. font-weight: 800;
  200. font-size: 13px;
  201. line-height: 16px;
  202. letter-spacing: 0.05em;
  203. color: #ffffff;
  204. display: flex;
  205. align-items: center;
  206. justify-content: center;
  207. }
  208. .time-area {
  209. display: flex;
  210. justify-content: center;
  211. align-items: center;
  212. width: 100%;
  213. height: 46px;
  214. background: rgba(0,0,0,.15);
  215. color: #FFCC4D;
  216. font-weight: 900;
  217. font-size: 26px;
  218. margin-top: -10px;
  219. .icon-clock {
  220. width: 26px;
  221. height: 26px;
  222. margin-right: 10px;
  223. }
  224. }
  225. }
  226. .title {
  227. position: absolute;
  228. top: 15px;
  229. left: 15px;
  230. z-index: 3;
  231. width: 100%;
  232. display: flex;
  233. align-items: center;
  234. img {
  235. width: 24px;
  236. height: 24px;
  237. border: 2px solid #fff;
  238. border-radius: 50%;
  239. }
  240. span {
  241. margin-left: 10px;
  242. font-weight: 600;
  243. font-size: 16px;
  244. letter-spacing: 0.3px;
  245. color: #fff;
  246. }
  247. }
  248. // .txt {
  249. // width: 100%;
  250. // position: absolute;
  251. // font-style: normal;
  252. // font-weight: 700;
  253. // font-size: 42px;
  254. // line-height: 50px;
  255. // text-align: center;
  256. // color: #FFF2D3;
  257. // top: 90px;
  258. // z-index: 3;
  259. // }
  260. img {
  261. width: 100%;
  262. }
  263. .cover {
  264. border-radius: 16px;
  265. }
  266. .up {
  267. position: absolute;
  268. top: 0;
  269. // box-shadow: 0px 4px 44px rgba(0, 0, 0, 0.1);
  270. z-index: 1;
  271. }
  272. .down {
  273. position: absolute;
  274. top: 253px;
  275. }
  276. .open {
  277. width: 335px;
  278. height: 50px;
  279. cursor: pointer;
  280. position: absolute;
  281. bottom: 28px;
  282. left: 50%;
  283. margin-left: -167.5px;
  284. z-index: 2;
  285. }
  286. .open-gif {
  287. width: 200px;
  288. height: 200px;
  289. text-align: center;
  290. position: absolute;
  291. bottom: 90px;
  292. left: 50%;
  293. margin-left: -100px;
  294. z-index: 3;
  295. }
  296. }
  297. .custom-card {
  298. position: relative;
  299. width: 100%;
  300. height: 100%;
  301. overflow: hidden;
  302. background:#111214;
  303. position: relative;
  304. border-radius: 10px;
  305. .customImg {
  306. width: 100%;
  307. min-height: calc(100% - 125px);
  308. }
  309. .cover {
  310. width: 100%;
  311. min-height: 350px;
  312. border-radius: 10px 10px 0 0;
  313. }
  314. .gift {
  315. width: 210px;
  316. position: absolute;
  317. left: 50%;
  318. top: 83px;
  319. transform: translateX(-50%);
  320. }
  321. .prize {
  322. width: 100%;
  323. position: absolute;
  324. top: 57%;
  325. left: 0;
  326. height: 47px;
  327. display: flex;
  328. flex-direction: row;
  329. justify-content: center;
  330. font-style: normal;
  331. font-weight: 800;
  332. font-size: 22px;
  333. line-height: 47px;
  334. letter-spacing: 0.3px;
  335. .icon {
  336. width: 24px;
  337. }
  338. .name {
  339. padding: 0 7px;
  340. color: #fff;
  341. }
  342. .total {
  343. color: #F5C03F;
  344. }
  345. }
  346. .common-bottom {
  347. width: 100%;
  348. height: 125px;
  349. background:#111214;
  350. border-radius: 0 0 10px 10px;
  351. padding: 10px 16px;
  352. font-weight: 500;
  353. font-size: 12px;
  354. line-height: 14px;
  355. letter-spacing: 0.3px;
  356. color: #838383;
  357. line-height: 20px;
  358. .theme {
  359. display: flex;
  360. height: 20px;
  361. align-items: center;
  362. justify-content: flex-start;
  363. .icon {
  364. width: 12px;
  365. }
  366. .time {
  367. margin: 0 4px;
  368. color: #1D9BF0;
  369. }
  370. }
  371. .winner-info {
  372. display: flex;
  373. height: 20px;
  374. align-items: center;
  375. justify-content: flex-start;
  376. margin-bottom: 13px;
  377. font-size: 12px;
  378. .count{
  379. color: #1D9BF0;
  380. margin-right: 4px;
  381. }
  382. .prize-name {
  383. color: #1D9BF0;
  384. margin-left: 4px;
  385. }
  386. }
  387. .open-btn {
  388. width: 100%;
  389. height: 45px;
  390. background: linear-gradient(180deg, #4AB6FF 0%, #1D9BF0 100%, #1D9BF0 100%);
  391. border: 1.5px solid rgba(255, 255, 255, 0.15);
  392. border-radius: 52px;
  393. line-height: 45px;
  394. text-align: center;
  395. cursor: pointer;
  396. font-weight: 800;
  397. font-size: 16px;
  398. color: #FFFFFF;
  399. }
  400. }
  401. }
  402. </style>