custom-card-horizontal-cover.vue 9.1 KB

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