custom-card-cover.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  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 == 2" :src="require('@/assets/svg/img-preview-draw-bg.svg')" />
  25. <img class="cover" v-else :src="require('@/assets/subject/001-card.png')" />
  26. <img class="open-gif"
  27. v-if="data.type == 2"
  28. src="@/assets/img/img-preview-draw-box.png" />
  29. <img class="open-gif"
  30. v-else
  31. :src="require('@/assets/gif/001.gif')" />
  32. <img v-if="data.type == 2"
  33. :src="require('@/assets/svg/img-preview-draw-open.svg')"
  34. class="open"
  35. @click="open" />
  36. <img v-else
  37. :src="require('@/assets/svg/icon-open.svg')"
  38. class="open"
  39. @click="open"/>
  40. <div class="title" v-if="data.userInfo">
  41. <img :src="data.userInfo.avatarUrl" />
  42. <span>{{
  43. data.userInfo.nickName || ""
  44. }}</span>
  45. </div>
  46. <div class="money-area">
  47. <div class="txt">{{data.currencyCode == 'USD' ? 'USD' : data.tokenSymbol}} GIVEAWAY</div>
  48. <div class="coin">
  49. <img :src="data.currencyIconUrl || imgHeaderCover" />
  50. <span id="preview-after-amount"
  51. :style="{
  52. fontSize: amount_font_size + 'px'
  53. }">{{ data.amountValue }}</span>
  54. </div>
  55. <div class="time-area" v-if="data.type == 2">
  56. <img class="icon-clock" :src="require('@/assets/svg/icon-time.svg')" />
  57. {{data.countDown || formatSecondsAsDaysOrTime(data.validityDuration * 3600)}}
  58. </div>
  59. <div class="people" v-else>
  60. {{ data.totalCount }} WINNERS TO SHARE
  61. </div>
  62. </div>
  63. </div>
  64. <!-- 改版之后的卡片 -->
  65. <div class="custom-card" v-else>
  66. <img class="cover" v-if="isLottaryCpd" :src="require('@/assets/subject/img-custom-lottary-bg.svg')" />
  67. <img class="cover" v-else :src="require('@/assets/subject/img-custom-common-bg.svg')" />
  68. <img class="gift" :src="require('@/assets/subject/icon-gift.gif')" />
  69. <div class="prize">
  70. <component-zoom width="300" fontSize="22">
  71. <img class="icon" :src="require('@/assets/subject/icon-gift-inline.svg')"/>
  72. <span class="name" id="custom-name" >
  73. {{data.customizedReward}}
  74. <span class="total" >X{{data.totalCount}}</span>
  75. </span>
  76. </component-zoom>
  77. </div>
  78. <!-- 底部公共模块 -->
  79. <div class="common-bottom">
  80. <div class="theme">
  81. <img v-if="isLottaryCpd" class="icon" :src="require('@/assets/svg/icon-last-time.svg')"/>
  82. <span v-if="isLottaryCpd" class="time" >{{data.countDown || formatSecondsAsDaysOrTime(data.validityDuration * 3600)}}</span>
  83. <span class="info">{{isLottaryCpd ? 'Left' : 'Instant Giveaway'}}</span>
  84. </div>
  85. <div class="winner-info">
  86. <component-zoom width="300" fontSize="12">
  87. <span class="count">{{data.totalCount}}Winners</span>
  88. <span>to Share </span>
  89. <span class="prize-name">{{isMoneyRewardCpd ? data.amountValue + ' ' + data.tokenSymbol : data.customizedReward}}</span>
  90. </component-zoom>
  91. </div>
  92. <div class="open-btn" @click="open">
  93. {{isLottaryCpd ? 'Participate Now' : 'Open Now'}}
  94. </div>
  95. </div>
  96. </div>
  97. </template>
  98. <script setup>
  99. import { defineProps, defineEmits, ref, computed, onMounted } from "vue";
  100. import { formatSecondsAsDaysOrTime } from "@/uilts/help";
  101. import ComponentZoom from "./component-zoom.vue";
  102. import { RewardType, PlayType } from "@/types";
  103. const props = defineProps({
  104. data: {
  105. type: Object,
  106. default: () => {
  107. return {
  108. totalCount: 0,
  109. amountValue: 0,
  110. tokenSymbol: "",
  111. type: 1,
  112. validityDuration: '',
  113. countDown: '',
  114. customPosterUrl: '',
  115. userInfo: {
  116. avatarUrl: "",
  117. nickName: "",
  118. },
  119. rewardType: RewardType.money,
  120. customizedReward: "",
  121. };
  122. },
  123. },
  124. });
  125. let isMoneyRewardCpd =computed(() => {
  126. return props.data.rewardType === RewardType.money
  127. });
  128. let isLottaryCpd = computed(() => props.data.type === PlayType.lottery);
  129. const defaultBaseWidth = isMoneyRewardCpd.value ? 56 : 22;
  130. const defaultTotalWidth = isMoneyRewardCpd.value ? 360 : 450;
  131. let amount_font_size = ref(defaultBaseWidth);
  132. const setFontSize = () =>{
  133. let id = isMoneyRewardCpd.value ? 'preview-after-amount' : 'custom-name';
  134. let lendom = document.querySelector(`#${id}`);
  135. if (lendom) {
  136. let lenstr = lendom.innerText.length;
  137. let num = parseInt(defaultTotalWidth / lenstr);
  138. amount_font_size.value = num < defaultBaseWidth ? num : defaultBaseWidth;
  139. }
  140. }
  141. const emits = defineEmits(["clickOpenRedPacket"]);
  142. const open = () => {
  143. emits("clickOpenRedPacket", {});
  144. };
  145. onMounted(() => {
  146. setFontSize()
  147. })
  148. </script>
  149. <style scoped lang="scss">
  150. .not-open {
  151. width: 100%;
  152. height: 100%;
  153. position: relative;
  154. border-radius: 16px;
  155. filter: drop-shadow(0px 2px 20px rgba(0, 0, 0, 0.1));
  156. .money-area {
  157. width: 100%;
  158. position: absolute;
  159. top: 65px;
  160. .txt {
  161. font-weight: 800;
  162. font-size: 16px;
  163. text-align: center;
  164. letter-spacing: 0.3px;
  165. color: #ffffff;
  166. }
  167. .coin {
  168. text-align: center;
  169. width: 100%;
  170. padding: 6px 0;
  171. margin: 0 auto;
  172. display: flex;
  173. align-items: center;
  174. justify-content: center;
  175. img {
  176. width: 46px;
  177. height: 46px;
  178. border-radius: 50%;
  179. border: 3px solid #ffffff;
  180. }
  181. span {
  182. margin-left: 15px;
  183. font-weight: 800;
  184. font-size: 60px;
  185. line-height: 76px;
  186. color: #ffffff;
  187. }
  188. }
  189. .people {
  190. font-weight: 800;
  191. font-size: 13px;
  192. line-height: 16px;
  193. letter-spacing: 0.05em;
  194. color: #ffffff;
  195. display: flex;
  196. align-items: center;
  197. justify-content: center;
  198. }
  199. .time-area {
  200. display: flex;
  201. justify-content: center;
  202. align-items: center;
  203. width: 100%;
  204. height: 46px;
  205. background: rgba(0,0,0,.15);
  206. color: #FFCC4D;
  207. font-weight: 900;
  208. font-size: 26px;
  209. margin-top: -10px;
  210. .icon-clock {
  211. width: 26px;
  212. height: 26px;
  213. margin-right: 10px;
  214. }
  215. }
  216. }
  217. .title {
  218. position: absolute;
  219. top: 15px;
  220. left: 15px;
  221. z-index: 3;
  222. width: 100%;
  223. display: flex;
  224. align-items: center;
  225. img {
  226. width: 24px;
  227. height: 24px;
  228. border: 2px solid #fff;
  229. border-radius: 50%;
  230. }
  231. span {
  232. margin-left: 10px;
  233. font-weight: 600;
  234. font-size: 16px;
  235. letter-spacing: 0.3px;
  236. color: #fff;
  237. }
  238. }
  239. // .txt {
  240. // width: 100%;
  241. // position: absolute;
  242. // font-style: normal;
  243. // font-weight: 700;
  244. // font-size: 42px;
  245. // line-height: 50px;
  246. // text-align: center;
  247. // color: #FFF2D3;
  248. // top: 90px;
  249. // z-index: 3;
  250. // }
  251. img {
  252. width: 100%;
  253. }
  254. .cover {
  255. border-radius: 16px;
  256. }
  257. .up {
  258. position: absolute;
  259. top: 0;
  260. // box-shadow: 0px 4px 44px rgba(0, 0, 0, 0.1);
  261. z-index: 1;
  262. }
  263. .down {
  264. position: absolute;
  265. top: 253px;
  266. }
  267. .open {
  268. width: 335px;
  269. height: 50px;
  270. cursor: pointer;
  271. position: absolute;
  272. bottom: 28px;
  273. left: 50%;
  274. margin-left: -167.5px;
  275. z-index: 2;
  276. }
  277. .open-gif {
  278. width: 200px;
  279. height: 200px;
  280. text-align: center;
  281. position: absolute;
  282. bottom: 90px;
  283. left: 50%;
  284. margin-left: -100px;
  285. z-index: 3;
  286. }
  287. }
  288. .custom-card {
  289. position: relative;
  290. width: 100%;
  291. height: 100%;
  292. overflow: hidden;
  293. background:#111214;
  294. position: relative;
  295. border-radius: 10px;
  296. .customImg {
  297. width: 100%;
  298. min-height: calc(100% - 125px);
  299. }
  300. .cover {
  301. width: 100%;
  302. min-height: 350px;
  303. border-radius: 10px 10px 0 0;
  304. }
  305. .gift {
  306. width: 210px;
  307. position: absolute;
  308. left: 50%;
  309. top: 83px;
  310. transform: translateX(-50%);
  311. }
  312. .prize {
  313. width: 100%;
  314. position: absolute;
  315. top: 57%;
  316. left: 0;
  317. height: 47px;
  318. display: flex;
  319. flex-direction: row;
  320. justify-content: center;
  321. font-style: normal;
  322. font-weight: 800;
  323. font-size: 22px;
  324. line-height: 47px;
  325. letter-spacing: 0.3px;
  326. .icon {
  327. width: 24px;
  328. }
  329. .name {
  330. padding: 0 7px;
  331. color: #fff;
  332. }
  333. .total {
  334. color: #F5C03F;
  335. }
  336. }
  337. .common-bottom {
  338. width: 100%;
  339. height: 125px;
  340. background:#111214;
  341. border-radius: 0 0 10px 10px;
  342. padding: 10px 16px;
  343. font-weight: 500;
  344. font-size: 12px;
  345. line-height: 14px;
  346. letter-spacing: 0.3px;
  347. color: #838383;
  348. line-height: 20px;
  349. .theme {
  350. display: flex;
  351. height: 20px;
  352. align-items: center;
  353. justify-content: flex-start;
  354. .icon {
  355. width: 12px;
  356. }
  357. .time {
  358. margin: 0 4px;
  359. color: #1D9BF0;
  360. }
  361. }
  362. .winner-info {
  363. display: flex;
  364. height: 20px;
  365. align-items: center;
  366. justify-content: flex-start;
  367. margin-bottom: 13px;
  368. font-size: 12px;
  369. .count{
  370. color: #1D9BF0;
  371. margin-right: 4px;
  372. }
  373. .prize-name {
  374. color: #1D9BF0;
  375. margin-left: 4px;
  376. }
  377. }
  378. .open-btn {
  379. width: 100%;
  380. height: 45px;
  381. background: linear-gradient(180deg, #4AB6FF 0%, #1D9BF0 100%, #1D9BF0 100%);
  382. border: 1.5px solid rgba(255, 255, 255, 0.15);
  383. border-radius: 52px;
  384. line-height: 45px;
  385. text-align: center;
  386. cursor: pointer;
  387. font-weight: 800;
  388. font-size: 16px;
  389. color: #FFFFFF;
  390. }
  391. }
  392. }
  393. </style>