custom-card-horizontal-cover.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. <!-- 自定义卡片红包封面 -->
  2. <template>
  3. <div class="card-wrapper" :class="{'custom-card-in-poster': !showBottom}" >
  4. <template v-if="data.customPosterUrl">
  5. <img class="customImg" :src="data.customPosterUrl" />
  6. </template>
  7. <template v-else-if="isMoneyRewardCpd">
  8. <img :src="require('@/assets/img/img-preview-draw-after-bg.png')"
  9. v-if="data.type == PlayType.lottery"
  10. class="card-cover">
  11. <img :src="require('@/assets/subject/img-card-cover-blue.png')"
  12. v-else-if="data.type == PlayType.common"
  13. class="card-cover"/>
  14. <img :src="require('@/assets/img/img-preview-treasure-link-bg.png')"
  15. v-else-if="data.type == PlayType.treasure"
  16. class="card-cover"/>
  17. <div class="bottom-bar">
  18. <div class="title">
  19. DeNet.me
  20. </div>
  21. <div class="desc">
  22. DeNet: An Easy Web3 Tool For GIVEAWAY / AIRDROP
  23. <!-- 🎁 <template v-if="data.tokenSymbol=='USD'">$</template>{{data.amountValue}} GIVEAWAY -->
  24. </div>
  25. </div>
  26. <div class="user-info">
  27. <img :src="data.userInfo.avatarUrl"
  28. class="avatar"/>
  29. <template v-if="data.type != PlayType.treasure">
  30. {{data.userInfo.nickName}}
  31. </template>
  32. <span class="treasure-info" style="color: #fff; opacity: 0.7;font-weight: 300;" v-else>
  33. from @{{data.userInfo.nickName || ""}}
  34. </span>
  35. </div>
  36. <div class="content-text">
  37. <template v-if="data.type != PlayType.treasure">
  38. <div class="title">
  39. <span>{{data.currencyCode == 'USD' ? 'US Dollar' : data.tokenSymbol}} </span>
  40. &nbsp;GIVEAWAY
  41. </div>
  42. <div class="center"
  43. :style="{
  44. fontSize: amountFontSize + 'px'
  45. }">
  46. <img :src="data.currencyIconUrl" class="icon">
  47. <span id="preview-before-amount">
  48. {{data.amountValue}}
  49. </span>
  50. </div>
  51. <div class="desc">
  52. <template v-if="data.type == PlayType.lottery">
  53. <img class="icon-clock"
  54. :src="require('@/assets/svg/icon-preview-clock.svg')" /> {{data.validityDuration}} H
  55. <img class="icon-trophy"
  56. :src="require('@/assets/svg/icon-preview-trophy.svg')" /> <span class="trophy-count">{{data.totalCount}} WINNERS</span>
  57. </template>
  58. <template v-else-if="data.type == PlayType.common">
  59. {{data.totalCount}} WINNERS TO SHARE
  60. </template>
  61. </div>
  62. </template>
  63. <div class="treasure-layout" v-else>
  64. <div class="treasure-row-1">
  65. <span class="left">Treasure</span>
  66. <component-zoom width="160">
  67. <span class="right">${{data.amountValue}}</span>
  68. </component-zoom>
  69. </div>
  70. <div class="treasure-desc-data">
  71. <div class="item">
  72. <img class="icon"
  73. :src="require('@/assets/svg/icon-preview-trophy.svg')" />
  74. {{data.totalCount}} Winners
  75. </div>
  76. <div class="item">
  77. <img class="icon" :src="data.currencyIconUrl">
  78. {{data.currencyCode == 'USD' ? 'US Dollar' : data.tokenSymbol}} equivalent
  79. </div>
  80. </div>
  81. </div>
  82. </div>
  83. </template>
  84. <template class="custom-card" v-else>
  85. <img class="custom-card-cover" v-if="isLottaryCpd" :src="require('@/assets/subject/img-custom-lottary-bg.png')" />
  86. <img class="custom-card-cover" v-else :src="require('@/assets/subject/img-custom-common-bg.png')" />
  87. <div class="bottom-bar" v-if="showBottom">
  88. <div class="title">
  89. DeNet.me
  90. </div>
  91. <div class="desc">
  92. 🎁 <template v-if="data.tokenSymbol=='USD'">$</template>{{data.amountValue}} GIVEAWAY
  93. </div>
  94. </div>
  95. <div class="custom-card-prize">
  96. <component-zoom width="showBottom ? 210 : 300">
  97. <span class="custom-card-prize-name" id="custom-name" >
  98. <img class="custom-card-prize-gift-inline" :src="require('@/assets/subject/icon-gift-inline.svg')" />
  99. {{data.customizedReward}}
  100. <span class="custom-card-prize-name-total">X{{data.totalCount}}</span>
  101. </span>
  102. </component-zoom>
  103. </div>
  104. <div class="custom-card-desc" :class="{'custom-card-desc-lottary': !isLottaryCpd}">
  105. <span class="last-time" v-if="isLottaryCpd">
  106. <img class="custom-card-desc-clock-icon" :src="require('@/assets/subject/icon-clock.png')" />
  107. {{data.validityDuration}} H
  108. </span>
  109. <span class="trophy-count">
  110. <img class="custom-card-desc-prize-icon" :src="require('@/assets/subject/icon-prize.png')" />
  111. {{data.totalCount}} WINNERS
  112. </span>
  113. </div>
  114. </template>
  115. </div>
  116. </template>
  117. <script setup>
  118. import { defineProps, defineEmits, watch, ref, computed } from "vue";
  119. import ComponentZoom from "./component-zoom.vue";
  120. import { RewardType, PlayType } from "@/types";
  121. const imgHeaderCover = require('@/assets/img/icon-header-cover.png');
  122. const props = defineProps({
  123. data: {
  124. type: Object,
  125. default: () => {
  126. return {
  127. totalCount: 0,
  128. amountValue: 0,
  129. tokenSymbol: '',
  130. currencyCode: '',
  131. type: 1,
  132. validityDuration: '',
  133. customPosterUrl: '',
  134. userInfo: {
  135. avatarUrl: "",
  136. nickName: "",
  137. },
  138. rewardType: RewardType.money,
  139. customizedReward: ""
  140. };
  141. },
  142. },
  143. showBottom: {
  144. type: Boolean,
  145. default: true
  146. }
  147. });
  148. let isMoneyRewardCpd =computed(() => props.data.rewardType === RewardType.money);
  149. let isLottaryCpd = computed(() => props.data.type === PlayType.lottery);
  150. let amountFontSize = ref(60);
  151. watch(() => props.data, () => {
  152. let lenstr = document.querySelector('#preview-before-amount')?.innerHTML?.length;
  153. let num = parseInt(360/lenstr);
  154. amountFontSize.value = num < 56 ? num : 56;
  155. })
  156. </script>
  157. <style scoped lang="scss">
  158. .card-wrapper {
  159. width: 491px;
  160. border: 1px solid #D1D9DD;
  161. background: #ffffff;
  162. box-sizing: border-box;
  163. overflow: hidden;
  164. position: relative;
  165. box-sizing: border-box;
  166. border-radius: 16px;
  167. left: 73px;
  168. top: 238px;
  169. .customImg {
  170. width: 100%;
  171. min-height: 200px;
  172. }
  173. .user-info {
  174. position: absolute;
  175. left: 8px;
  176. top: 8px;
  177. z-index: 100;
  178. display: flex;
  179. align-items: center;
  180. font-size: 16px;
  181. color: #FFF;
  182. width: max-content;
  183. img {
  184. width: 24px;
  185. height: 24px;
  186. border: 2px solid #FFF4DB;
  187. box-sizing: border-box;
  188. border-radius: 50%;
  189. margin-right: 10px;
  190. }
  191. .treasure-info {
  192. color: #fff;
  193. opacity: 0.7;
  194. font-weight: 300;
  195. }
  196. }
  197. .content-text {
  198. position: absolute;
  199. top: 53px;
  200. left: 35px;
  201. .title {
  202. font-weight: 800;
  203. font-size: 16px;
  204. color: #ffffff;
  205. span {
  206. color: #F9C545;
  207. }
  208. }
  209. .center {
  210. padding: 12px 0;
  211. box-sizing: border-box;
  212. font-weight: 800;
  213. font-size: 56px;
  214. color: #fff;
  215. display: flex;
  216. align-items: center;
  217. .icon {
  218. width: 46px;
  219. height: 46px;
  220. margin-right: 10px;
  221. border: 3px solid #fff;
  222. border-radius: 50%;
  223. }
  224. }
  225. .desc {
  226. font-weight: 800;
  227. font-size: 13px;
  228. color: #ffffff;
  229. display: flex;
  230. align-items: center;
  231. .icon-clock {
  232. margin-right: 4px;
  233. }
  234. .icon-trophy {
  235. margin-left: 8px;
  236. margin-right: 4px;
  237. }
  238. .trophy-count {
  239. color: #FFCC4D;
  240. }
  241. }
  242. .treasure-layout {
  243. margin-top: -8px;
  244. .treasure-row-1 {
  245. display: flex;
  246. align-items: center;
  247. justify-content: center;
  248. font-weight: 900;
  249. font-size: 35px;
  250. color: #fff;
  251. .left {
  252. margin-right: 7px;
  253. color: #FFC83A;
  254. }
  255. .right {
  256. font-weight: 900;
  257. font-size: 35px;
  258. color: #fff;
  259. }
  260. }
  261. .treasure-desc-data {
  262. margin-top: 18px;
  263. .item {
  264. font-weight: 500;
  265. font-size: 14px;
  266. color: #E1D4C5;
  267. margin-bottom: 10px;
  268. display: flex;
  269. align-items: center;
  270. .icon {
  271. width: 20px;
  272. margin-right: 8px;
  273. }
  274. }
  275. }
  276. }
  277. }
  278. .card-cover {
  279. width: 100%;
  280. object-fit: contain;
  281. }
  282. .bottom-bar {
  283. padding: 12px;
  284. box-sizing: border-box;
  285. .title {
  286. color: #566370;
  287. font-weight: 400;
  288. font-size: 14px;
  289. margin-bottom: 6px;
  290. }
  291. .desc {
  292. font-weight: 500;
  293. font-size: 15px;
  294. color: #101419;
  295. }
  296. }
  297. }
  298. .custom-card {
  299. width: 100%;
  300. height: 100%;
  301. &-cover {
  302. width: 100%;
  303. }
  304. &-prize {
  305. position: absolute;
  306. left: 0%;
  307. top: 16%;
  308. width: 65%;
  309. line-height: 42px;
  310. display: flex;
  311. background-image: url('@/assets/subject/icon-uninstall-bg.svg');
  312. background-size: 100% 100%;
  313. padding-left: 5px;
  314. &-name {
  315. font-weight: 800;
  316. font-size: 16px;
  317. // line-height: 20px;
  318. letter-spacing: 0.22px;
  319. color: #FFFFFF;
  320. text-shadow: 0px 1.46341px 0px rgba(0, 0, 0, 0.15);
  321. display: flex;
  322. justify-content: center;
  323. align-items: center;
  324. &-total {
  325. color: #F5C03F;
  326. }
  327. }
  328. &-gift-inline {
  329. width: 30px;
  330. height: 30px;
  331. padding: 0 5px;
  332. }
  333. }
  334. &-desc {
  335. font-size: 12px;
  336. line-height: 13px;
  337. letter-spacing: 0.219512px;
  338. color: #FFFFFF;
  339. opacity: 0.7;
  340. position: absolute;
  341. left: 0;
  342. top: 37%;
  343. display: flex;
  344. padding-left: 4%;
  345. .last-time {
  346. display: flex;
  347. align-items: center;
  348. margin-right: 12px;
  349. img {
  350. width: 12px;
  351. margin-right: 2px;
  352. }
  353. }
  354. .trophy-count {
  355. display: flex;
  356. align-items: center;
  357. img {
  358. width: 12px;
  359. margin-right: 2px;
  360. }
  361. }
  362. }
  363. }
  364. .custom-card-in-poster {
  365. .custom-card-prize {
  366. top: 24%;
  367. line-height: 54px;
  368. }
  369. .custom-card-desc{
  370. top: 50%;
  371. }
  372. }
  373. </style>