custom-card-horizontal-cover.vue 12 KB

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