custom-card-cover.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  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" ref="zoomCom1">
  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 == PlayType.lottery" :src="require('@/assets/svg/img-preview-draw-bg.svg')" />
  25. <img class="cover" v-else-if="data.type == PlayType.common" src="@/assets/subject/001-card.png" />
  26. <img class="cover" v-else-if="data.type == PlayType.treasure" :src="require('@/assets/svg/img-preview-treasure-01-bg.svg')" />
  27. <img class="open-gif"
  28. v-if="data.type == PlayType.lottery"
  29. src="@/assets/img/img-preview-draw-box.png" />
  30. <img class="open-gif"
  31. v-else-if="data.type == PlayType.common"
  32. :src="require('@/assets/gif/001.gif')" />
  33. <img v-if="data.type == PlayType.lottery"
  34. :src="require('@/assets/svg/img-preview-draw-open.svg')"
  35. class="open"
  36. @click="open" />
  37. <img v-else-if="data.type == PlayType.common"
  38. :src="require('@/assets/svg/icon-open.svg')"
  39. class="open"
  40. @click="open"/>
  41. <div class="title" v-if="data.userInfo">
  42. <img :src="data.userInfo.avatarUrl" />
  43. <span v-if="data.type != PlayType.treasure">
  44. {{data.userInfo.nickName || ""}}
  45. </span>
  46. <span class="treasure-info" v-else>
  47. from @{{data.userInfo.nickName || ""}}
  48. </span>
  49. </div>
  50. <div class="money-area" v-if="data.type != PlayType.treasure">
  51. <div class="txt">
  52. <span>{{data.currencyCode == 'USD' ? 'US Dollar' : data.tokenSymbol}} </span>
  53. &nbsp;GIVEAWAY
  54. </div>
  55. <div class="coin">
  56. <component-zoom width="300" fontSize="56" :txt="data.amountValue || 0" ref="zoomCom">
  57. <img v-if="data.currencyIconUrl" :src="data.currencyIconUrl || imgHeaderCover" />
  58. <span id="preview-after-amount">{{ getBit(data.amountValue) || 0 }}</span>
  59. </component-zoom>
  60. </div>
  61. <div class="time-area" v-if="data.type == PlayType.lottery">
  62. <img class="icon-clock" :src="require('@/assets/svg/icon-time.svg')" />
  63. {{data.countDown || formatSecondsAsDaysOrTime(data.validityDuration * 3600)}}
  64. </div>
  65. <div class="people" v-else-if="data.type == PlayType.common">
  66. {{ data.totalCount }} WINNERS TO SHARE
  67. </div>
  68. </div>
  69. <div class="treasure-card-info" v-else>
  70. <div class="treasure-row-1">
  71. <div class="left">Treasure</div>
  72. <component-zoom :width="160" :txt="data.amountValue || 0">
  73. <div class="right">${{ data.usdEstimateOrderAmount || 0 }}</div>
  74. </component-zoom>
  75. </div>
  76. <div class="treasure-row-2">
  77. Your Gain Up to $
  78. <component-zoom :width="160" :txt="data.upGainAmountUsdValue || 0">
  79. <div class="amount">{{data.upGainAmountUsdValue || 0}}</div>
  80. </component-zoom>
  81. </div>
  82. <div class="treasure-row-3" :style="{'visibility': data.currencyCode && data.currencyCode != 'USD'? 'visible' : 'hidden'}">
  83. <img class="img" :src="data.currencyIconUrl" /> <span class="txt"> {{data.tokenSymbol}} <template v-if="data.currencyCode != 'USD'">equivalent (Crypto)</template></span>
  84. </div>
  85. <img class="img-treasure-big" :src="require('@/assets/img/icon-treasure-box.png')">
  86. <div class="treasure-row-4">
  87. <img class="img" :src="require('@/assets/svg/icon-card-cover-treasure-tasks.svg')"> to Hunt Treasure
  88. </div>
  89. <div class="open-btn" @click="open">
  90. <img :src="require('@/assets/svg/icon-card-cover-treasure-small.svg')" alt="">
  91. START
  92. </div>
  93. </div>
  94. </div>
  95. <!-- 改版之后的卡片 -->
  96. <div class="custom-card" v-else>
  97. <img class="cover" v-if="isLottaryCpd" :src="require('@/assets/subject/img-custom-lottary-bg.svg')" />
  98. <img class="cover" v-else :src="require('@/assets/subject/img-custom-common-bg.svg')" />
  99. <img class="gift" :src="require('@/assets/subject/icon-gift.gif')" />
  100. <div class="prize">
  101. <component-zoom width="300" fontSize="22" ref="zoomCom2">
  102. <img class="icon" :src="require('@/assets/subject/icon-gift-inline.svg')"/>
  103. <span class="name" id="custom-name" >
  104. {{data.customizedReward}}
  105. <span class="total" >X{{data.totalCount}}</span>
  106. </span>
  107. </component-zoom>
  108. </div>
  109. <!-- 底部公共模块 -->
  110. <div class="common-bottom">
  111. <div class="theme">
  112. <img v-if="isLottaryCpd" class="icon" :src="require('@/assets/svg/icon-last-time.svg')"/>
  113. <span v-if="isLottaryCpd" class="time" >{{data.countDown || formatSecondsAsDaysOrTime(data.validityDuration * 3600)}}</span>
  114. <span class="info">{{isLottaryCpd ? 'Left' : 'Instant Giveaway'}}</span>
  115. </div>
  116. <div class="winner-info">
  117. <component-zoom width="300" fontSize="12" ref="zoomCom3">
  118. <span class="count">{{data.totalCount}}Winners</span>
  119. <span>to Share </span>
  120. <span class="prize-name">{{isMoneyRewardCpd ? data.amountValue + ' ' + data.tokenSymbol : data.customizedReward}}</span>
  121. </component-zoom>
  122. </div>
  123. <div class="open-btn" @click="open">
  124. {{isLottaryCpd ? 'Participate Now' : 'Open Now'}}
  125. </div>
  126. </div>
  127. </div>
  128. </template>
  129. <script setup>
  130. import { defineProps, defineEmits, ref, computed, onMounted, watch } from "vue";
  131. import { formatSecondsAsDaysOrTime } from "@/uilts/help";
  132. import ComponentZoom from "./component-zoom.vue";
  133. import { RewardType, PlayType } from "@/types";
  134. import { getBit } from "@/uilts/help";
  135. let zoomCom = ref('');
  136. let zoomCom1 = ref('');
  137. let zoomCom2 = ref('');
  138. let zoomCom3 = ref('');
  139. const props = defineProps({
  140. show: {
  141. type: Boolean,
  142. default: true
  143. },
  144. data: {
  145. type: Object,
  146. default: () => {
  147. return {
  148. totalCount: 0,
  149. amountValue: 0,
  150. tokenSymbol: '',
  151. currencyCode: '',
  152. type: 1,
  153. validityDuration: '',
  154. countDown: '',
  155. customPosterUrl: '',
  156. userInfo: {
  157. avatarUrl: "",
  158. nickName: "",
  159. },
  160. rewardType: RewardType.money,
  161. customizedReward: "",
  162. upGainAmountUsdValue: ""
  163. };
  164. },
  165. },
  166. });
  167. watch(() => props.show, (newVal) => {
  168. if(newVal) {
  169. zoomCom.value && zoomCom.value.setFontZoom(0);
  170. zoomCom1.value && zoomCom1.value.setFontZoom(0);
  171. zoomCom2.value && zoomCom2.value.setFontZoom(0);
  172. zoomCom3.value && zoomCom3.value.setFontZoom(0);
  173. }
  174. },
  175. {
  176. deep: true
  177. })
  178. let isMoneyRewardCpd =computed(() => {
  179. return props.data.rewardType === RewardType.money
  180. });
  181. let isLottaryCpd = computed(() => props.data.type === PlayType.lottery);
  182. const defaultBaseWidth = isMoneyRewardCpd.value ? 56 : 22;
  183. const defaultTotalWidth = isMoneyRewardCpd.value ? 360 : 450;
  184. let amount_font_size = ref(defaultBaseWidth);
  185. const setFontSize = () =>{
  186. let id = isMoneyRewardCpd.value ? 'preview-after-amount' : 'custom-name';
  187. let lendom = document.querySelector(`#${id}`);
  188. if (lendom) {
  189. let lenstr = lendom.innerText.length;
  190. let num = parseInt(defaultTotalWidth / lenstr);
  191. amount_font_size.value = num < defaultBaseWidth ? num : defaultBaseWidth;
  192. }
  193. }
  194. const emits = defineEmits(["clickOpenRedPacket"]);
  195. const open = () => {
  196. emits("clickOpenRedPacket", {});
  197. };
  198. onMounted(() => {
  199. // setFontSize()
  200. })
  201. </script>
  202. <style scoped lang="scss">
  203. .not-open {
  204. width: 100%;
  205. height: 100%;
  206. position: relative;
  207. border-radius: 16px;
  208. filter: drop-shadow(0px 2px 20px rgba(0, 0, 0, 0.1));
  209. .money-area {
  210. width: 100%;
  211. position: absolute;
  212. top: 65px;
  213. .txt {
  214. font-weight: 800;
  215. font-size: 16px;
  216. letter-spacing: 0.3px;
  217. color: #ffffff;
  218. display: flex;
  219. align-items: center;
  220. justify-content: center;
  221. span {
  222. color: #F9C545;
  223. }
  224. }
  225. .coin {
  226. text-align: center;
  227. width: 100%;
  228. padding: 3px 0;
  229. margin: 0 auto;
  230. display: flex;
  231. align-items: center;
  232. justify-content: center;
  233. height: 85px;
  234. box-sizing: border-box;
  235. img {
  236. width: 46px;
  237. height: 46px;
  238. border-radius: 50%;
  239. border: 3px solid #ffffff;
  240. }
  241. #preview-after-amount {
  242. margin-left: 15px;
  243. font-weight: 800;
  244. font-size: 60px;
  245. line-height: 76px;
  246. color: #ffffff;
  247. }
  248. }
  249. .people {
  250. font-weight: 800;
  251. font-size: 13px;
  252. line-height: 16px;
  253. letter-spacing: 0.05em;
  254. color: #ffffff;
  255. display: flex;
  256. align-items: center;
  257. justify-content: center;
  258. }
  259. .time-area {
  260. display: flex;
  261. justify-content: center;
  262. align-items: center;
  263. width: 100%;
  264. height: 46px;
  265. background: rgba(0,0,0,.15);
  266. color: #FFCC4D;
  267. font-weight: 900;
  268. font-size: 26px;
  269. margin-top: -10px;
  270. .icon-clock {
  271. width: 26px;
  272. height: 26px;
  273. margin-right: 10px;
  274. }
  275. }
  276. }
  277. .treasure-card-info {
  278. color: #fff;
  279. position: absolute;
  280. top: 86px;
  281. width: 100%;
  282. text-align: center;
  283. .treasure-row-1 {
  284. display: flex;
  285. align-items: center;
  286. justify-content: center;
  287. font-weight: 900;
  288. font-size: 25px;
  289. .left {
  290. margin-right: 7px;
  291. color: #FFC83A;
  292. }
  293. .right {
  294. font-weight: 900;
  295. font-size: 25px;
  296. }
  297. }
  298. .treasure-row-2 {
  299. margin: 6px 0;
  300. background: rgba(255, 255, 255, .1);
  301. width: 100%;
  302. height: 27px;
  303. display: flex;
  304. align-items: center;
  305. justify-content: center;
  306. font-weight: 500;
  307. font-size: 12px;
  308. .amount {
  309. font-weight: 800;
  310. font-size: 17px;
  311. margin-top: -2px;
  312. }
  313. }
  314. .treasure-row-3 {
  315. display: flex;
  316. align-items: center;
  317. justify-content: center;
  318. .img {
  319. width: 13px;
  320. margin-right: 3px;
  321. }
  322. .txt {
  323. zoom: .8;
  324. opacity: 0.7;
  325. }
  326. }
  327. .treasure-row-4 {
  328. display: flex;
  329. align-items:center;
  330. justify-content: center;
  331. color: #65C1FF;
  332. margin-top: 18px;
  333. font-size: 16px;
  334. .img {
  335. width: 76px;
  336. }
  337. }
  338. .img-treasure-big {
  339. width: 200px;
  340. }
  341. .open-btn {
  342. width: 88%;
  343. height: 40px;
  344. background: #1D9BF0;
  345. border-radius: 75px;
  346. display: flex;
  347. align-items:center;
  348. justify-content: center;
  349. cursor: pointer;
  350. font-weight: 800;
  351. font-size: 15px;
  352. margin-top: 12px;
  353. position: relative;
  354. left: 50%;
  355. transform: translateX(-50%);
  356. img {
  357. width: 18px;
  358. margin-right: 5px;
  359. }
  360. }
  361. }
  362. .title {
  363. position: absolute;
  364. top: 15px;
  365. left: 15px;
  366. z-index: 3;
  367. width: 100%;
  368. display: flex;
  369. align-items: center;
  370. img {
  371. width: 24px;
  372. height: 24px;
  373. border: 2px solid #fff;
  374. border-radius: 50%;
  375. }
  376. span {
  377. margin-left: 10px;
  378. font-weight: 600;
  379. font-size: 16px;
  380. letter-spacing: 0.3px;
  381. color: #fff;
  382. }
  383. .treasure-info {
  384. color: #fff;
  385. opacity: 0.7;
  386. font-weight: 300;
  387. }
  388. }
  389. // .txt {
  390. // width: 100%;
  391. // position: absolute;
  392. // font-style: normal;
  393. // font-weight: 700;
  394. // font-size: 42px;
  395. // line-height: 50px;
  396. // text-align: center;
  397. // color: #FFF2D3;
  398. // top: 90px;
  399. // z-index: 3;
  400. // }
  401. img {
  402. width: 100%;
  403. }
  404. .cover {
  405. border-radius: 16px;
  406. }
  407. .up {
  408. position: absolute;
  409. top: 0;
  410. // box-shadow: 0px 4px 44px rgba(0, 0, 0, 0.1);
  411. z-index: 1;
  412. }
  413. .down {
  414. position: absolute;
  415. top: 253px;
  416. }
  417. .open {
  418. width: 335px;
  419. height: 50px;
  420. cursor: pointer;
  421. position: absolute;
  422. bottom: 28px;
  423. left: 50%;
  424. margin-left: -167.5px;
  425. z-index: 2;
  426. }
  427. .open-gif {
  428. width: 200px;
  429. height: 200px;
  430. text-align: center;
  431. position: absolute;
  432. bottom: 90px;
  433. left: 50%;
  434. margin-left: -100px;
  435. z-index: 3;
  436. }
  437. }
  438. .custom-card {
  439. position: relative;
  440. width: 100%;
  441. height: 100%;
  442. overflow: hidden;
  443. background:#111214;
  444. position: relative;
  445. border-radius: 10px;
  446. .customImg {
  447. width: 100%;
  448. min-height: calc(100% - 125px);
  449. }
  450. .cover {
  451. width: 100%;
  452. min-height: 350px;
  453. border-radius: 10px 10px 0 0;
  454. }
  455. .gift {
  456. width: 210px;
  457. position: absolute;
  458. left: 50%;
  459. top: 83px;
  460. transform: translateX(-50%);
  461. }
  462. .prize {
  463. width: 100%;
  464. position: absolute;
  465. top: 57%;
  466. left: 0;
  467. height: 47px;
  468. display: flex;
  469. flex-direction: row;
  470. justify-content: center;
  471. font-style: normal;
  472. font-weight: 800;
  473. font-size: 22px;
  474. line-height: 47px;
  475. letter-spacing: 0.3px;
  476. .icon {
  477. width: 24px;
  478. }
  479. .name {
  480. padding: 0 7px;
  481. color: #fff;
  482. }
  483. .total {
  484. color: #F5C03F;
  485. }
  486. }
  487. .common-bottom {
  488. width: 100%;
  489. height: 125px;
  490. background:#111214;
  491. border-radius: 0 0 10px 10px;
  492. padding: 10px 16px;
  493. font-weight: 500;
  494. font-size: 12px;
  495. line-height: 14px;
  496. letter-spacing: 0.3px;
  497. color: #838383;
  498. line-height: 20px;
  499. .theme {
  500. display: flex;
  501. height: 20px;
  502. align-items: center;
  503. justify-content: flex-start;
  504. .icon {
  505. width: 12px;
  506. }
  507. .time {
  508. margin: 0 4px;
  509. color: #1D9BF0;
  510. }
  511. }
  512. .winner-info {
  513. display: flex;
  514. height: 20px;
  515. align-items: center;
  516. justify-content: flex-start;
  517. margin-bottom: 13px;
  518. font-size: 12px;
  519. .count{
  520. color: #1D9BF0;
  521. margin-right: 4px;
  522. }
  523. .prize-name {
  524. color: #1D9BF0;
  525. margin-left: 4px;
  526. }
  527. }
  528. .open-btn {
  529. width: 100%;
  530. height: 45px;
  531. background: linear-gradient(180deg, #4AB6FF 0%, #1D9BF0 100%, #1D9BF0 100%);
  532. border: 1.5px solid rgba(255, 255, 255, 0.15);
  533. border-radius: 52px;
  534. line-height: 45px;
  535. text-align: center;
  536. cursor: pointer;
  537. font-weight: 800;
  538. font-size: 16px;
  539. color: #FFFFFF;
  540. }
  541. }
  542. }
  543. </style>