custom-card-cover.vue 17 KB

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