custom-card-cover.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  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" @click="open">
  17. {{isLottaryCpd ? 'Participate Now' : 'Open Now'}}
  18. </div>
  19. </div>
  20. </div>
  21. <div class="not-open" v-else>
  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: amountFontSize + '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. {{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. </template>
  63. <script setup>
  64. import { defineProps, defineEmits, watch, ref, computed } from "vue";
  65. import { formatSecondsAsDaysOrTime } from "@/uilts/help";
  66. import { RewardType, PlayType } from "@/types";
  67. const imgHeaderCover = require('@/assets/img/icon-header-cover.png');
  68. const props = defineProps({
  69. data: {
  70. type: Object,
  71. default: () => {
  72. return {
  73. totalCount: 0,
  74. amountValue: 0,
  75. tokenSymbol: "",
  76. type: 1,
  77. validityDuration: '',
  78. customPosterUrl: '',
  79. userInfo: {
  80. avatarUrl: "",
  81. nickName: "",
  82. },
  83. };
  84. },
  85. },
  86. });
  87. let amountFontSize = ref(60);
  88. let isMoneyRewardCpd =computed(() => {
  89. return props.data.rewardType === RewardType.money
  90. });
  91. let isLottaryCpd = computed(() => props.data.type === PlayType.lottery);
  92. watch(() => props.data, () => {
  93. let id = isMoneyRewardCpd.value ? 'preview-after-amount' : 'custom-name';
  94. let baseWidth = isMoneyRewardCpd.value ? 56 : 22;
  95. let lendom = document.querySelector(`#${id}`)
  96. if(lendom) {
  97. let lenstr = lendom.innerHTML.length;
  98. let num = parseInt(360/lenstr);
  99. amountFontSize.value = num < baseWidth ? num : baseWidth;
  100. }
  101. })
  102. const emits = defineEmits(["clickOpenRedPacket"]);
  103. const open = () => {
  104. emits("clickOpenRedPacket", {});
  105. };
  106. </script>
  107. <style scoped lang="scss">
  108. .not-open {
  109. width: 100%;
  110. height: 100%;
  111. position: relative;
  112. border-radius: 16px;
  113. filter: drop-shadow(0px 2px 20px rgba(0, 0, 0, 0.1));
  114. .money-area {
  115. width: 100%;
  116. position: absolute;
  117. top: 65px;
  118. .txt {
  119. font-weight: 800;
  120. font-size: 16px;
  121. text-align: center;
  122. letter-spacing: 0.3px;
  123. color: #ffffff;
  124. }
  125. .coin {
  126. text-align: center;
  127. width: 100%;
  128. padding: 6px 0;
  129. margin: 0 auto;
  130. display: flex;
  131. align-items: center;
  132. justify-content: center;
  133. img {
  134. width: 46px;
  135. height: 46px;
  136. border-radius: 50%;
  137. border: 3px solid #ffffff;
  138. }
  139. span {
  140. margin-left: 15px;
  141. font-weight: 800;
  142. font-size: 60px;
  143. line-height: 76px;
  144. color: #ffffff;
  145. }
  146. }
  147. .people {
  148. font-weight: 800;
  149. font-size: 13px;
  150. line-height: 16px;
  151. letter-spacing: 0.05em;
  152. color: #ffffff;
  153. display: flex;
  154. align-items: center;
  155. justify-content: center;
  156. }
  157. .time-area {
  158. display: flex;
  159. justify-content: center;
  160. align-items: center;
  161. width: 100%;
  162. height: 46px;
  163. background: rgba(0,0,0,.15);
  164. color: #FFCC4D;
  165. font-weight: 900;
  166. font-size: 26px;
  167. margin-top: -10px;
  168. .icon-clock {
  169. width: 26px;
  170. height: 26px;
  171. margin-right: 10px;
  172. }
  173. }
  174. }
  175. .title {
  176. position: absolute;
  177. top: 15px;
  178. left: 15px;
  179. z-index: 3;
  180. width: 100%;
  181. display: flex;
  182. align-items: center;
  183. img {
  184. width: 24px;
  185. height: 24px;
  186. border: 2px solid #fff;
  187. border-radius: 50%;
  188. }
  189. span {
  190. margin-left: 10px;
  191. font-weight: 600;
  192. font-size: 16px;
  193. letter-spacing: 0.3px;
  194. color: #fff;
  195. }
  196. }
  197. // .txt {
  198. // width: 100%;
  199. // position: absolute;
  200. // font-style: normal;
  201. // font-weight: 700;
  202. // font-size: 42px;
  203. // line-height: 50px;
  204. // text-align: center;
  205. // color: #FFF2D3;
  206. // top: 90px;
  207. // z-index: 3;
  208. // }
  209. img {
  210. width: 100%;
  211. }
  212. .cover {
  213. border-radius: 16px;
  214. }
  215. .up {
  216. position: absolute;
  217. top: 0;
  218. // box-shadow: 0px 4px 44px rgba(0, 0, 0, 0.1);
  219. z-index: 1;
  220. }
  221. .down {
  222. position: absolute;
  223. top: 253px;
  224. }
  225. .open {
  226. width: 335px;
  227. height: 50px;
  228. cursor: pointer;
  229. position: absolute;
  230. bottom: 28px;
  231. left: 50%;
  232. margin-left: -167.5px;
  233. z-index: 2;
  234. }
  235. .open-gif {
  236. width: 200px;
  237. height: 200px;
  238. text-align: center;
  239. position: absolute;
  240. bottom: 90px;
  241. left: 50%;
  242. margin-left: -100px;
  243. z-index: 3;
  244. }
  245. }
  246. .custom-card {
  247. position: relative;
  248. width: 100%;
  249. overflow: hidden;
  250. position: relative;
  251. border-radius: 20px;
  252. .customImg {
  253. width: 100%;
  254. min-height: 200px;
  255. }
  256. .cover {
  257. width: 100%;
  258. min-height: 350px;
  259. border-radius: 20px 20px 0 0;
  260. }
  261. .gift {
  262. width: 210px;
  263. position: absolute;
  264. left: 50%;
  265. top: 83px;
  266. transform: translateX(-50%);
  267. }
  268. .prize {
  269. width: 100%;
  270. position: absolute;
  271. top: 284px;
  272. left: 0;
  273. height: 47px;
  274. display: flex;
  275. flex-direction: row;
  276. justify-content: center;
  277. font-style: normal;
  278. font-weight: 800;
  279. font-size: 22px;
  280. line-height: 47px;
  281. letter-spacing: 0.3px;
  282. .icon {
  283. width: 24px;
  284. }
  285. .name {
  286. padding: 0 7px;
  287. color: #fff;
  288. }
  289. .total {
  290. color: #F5C03F;
  291. }
  292. }
  293. .common-bottom {
  294. width: 100%;
  295. height: 125px;
  296. background:#111214;
  297. border-radius: 0 0 20px 20px;
  298. padding: 10px 16px;
  299. font-weight: 500;
  300. font-size: 12px;
  301. line-height: 14px;
  302. letter-spacing: 0.3px;
  303. color: #838383;
  304. line-height: 20px;
  305. .theme {
  306. display: flex;
  307. height: 20px;
  308. align-items: center;
  309. justify-content: flex-start;
  310. .icon {
  311. width: 12px;
  312. }
  313. .time {
  314. margin: 0 4px;
  315. color: #1D9BF0;
  316. }
  317. }
  318. .winner-info {
  319. display: flex;
  320. height: 20px;
  321. align-items: center;
  322. justify-content: flex-start;
  323. margin-bottom: 13px;
  324. .count{
  325. color: #1D9BF0;
  326. margin-right: 4px;
  327. }
  328. .prize-name {
  329. color: #1D9BF0;
  330. margin-left: 4px;
  331. }
  332. }
  333. .open {
  334. width: 100%;
  335. height: 45px;
  336. background: linear-gradient(180deg, #4AB6FF 0%, #1D9BF0 100%, #1D9BF0 100%);
  337. border: 1.5px solid rgba(255, 255, 255, 0.15);
  338. border-radius: 52px;
  339. line-height: 45px;
  340. text-align: center;
  341. cursor: pointer;
  342. font-weight: 800;
  343. font-size: 16px;
  344. color: #FFFFFF;
  345. }
  346. }
  347. }
  348. </style>