custom-card-cover.vue 12 KB

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