card.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <div class="nft">
  3. <div class="title">
  4. <div class="tag">
  5. <img class="logo" :src="saleData.nftProjectAvatar" />
  6. <font class="text">{{saleData.nftProjectName}}</font>
  7. <img class="tagImg" :src=" require('@/assets/img/icon-nft.png') " />
  8. </div>
  9. <div class="share" @click="share">
  10. <img :src=" require('@/assets/img/icon-ntf-share.png') " />
  11. </div>
  12. </div>
  13. <div class="content">
  14. <img :src="saleData.windowImagePath" />
  15. </div>
  16. <div class="buy">
  17. <button>Buy NFT</button>
  18. </div>
  19. </div>
  20. </template>
  21. <script setup>
  22. import { onBeforeMount, ref } from 'vue'
  23. import { getTwitterSaleNftProjectInfo } from '@/http/nft'
  24. import { pageUrl } from "@/http/configAPI.js"
  25. const saleData = ref({});
  26. const getSaleInfo = () => {
  27. let urlParams = window.location.search;
  28. let searchParams = new URLSearchParams(urlParams);
  29. let pathname = searchParams.get('pathname');
  30. let pathArr, account;
  31. if (pathname) {
  32. pathname = decodeURIComponent(pathname);
  33. pathname = pathname.slice(1);
  34. pathArr = pathname.split('/');
  35. account = pathArr[0];
  36. getSaleProjectInfo(account);
  37. }
  38. }
  39. const getSaleProjectInfo = (account) => {
  40. getTwitterSaleNftProjectInfo({
  41. params: {
  42. twitterAccount: account
  43. }
  44. }).then(res => {
  45. let { data } = res;
  46. if (data !== null) {
  47. // setData
  48. saleData.value = data;
  49. // postMessage
  50. chrome.tabs.getCurrent((tab) => {
  51. chrome.tabs.sendMessage(tab.id, { actionType: "IFRAME_NFT_SHOW_SALE" });
  52. })
  53. }
  54. })
  55. }
  56. const share = () => {
  57. let url = pageUrl + `/nft/${saleData.value.nftProjectId}`
  58. chrome.tabs.getCurrent((tab) => {
  59. chrome.tabs.sendMessage(tab.id, { actionType: "IFRAME_TWITTER_PUBLISH", publishRes: { srcContent: url } });
  60. })
  61. }
  62. onBeforeMount(() => {
  63. getSaleInfo()
  64. })
  65. </script>
  66. <style lang='scss'>
  67. body {
  68. margin: 0;
  69. padding: 0;
  70. }
  71. .nft {
  72. width: 100%;
  73. height:297px;
  74. user-select:none;
  75. border-radius:20px;
  76. background:#F7F9F9;
  77. .title {
  78. height:46px;
  79. display:flex;
  80. justify-content:space-between;
  81. align-items:center;
  82. .tag {
  83. display:flex;
  84. align-items:center;
  85. padding-left:15px;
  86. .logo {
  87. overflow:hidden;
  88. width:20px;
  89. height:20px;
  90. border-radius:50%;
  91. background-color:#eee;
  92. }
  93. .text {
  94. font-size:18px;
  95. font-weight:bold;
  96. margin:0 7px;
  97. }
  98. .tagImg {
  99. width:37px;
  100. height:22px;
  101. }
  102. }
  103. .share {
  104. cursor: pointer;
  105. padding-right:15px;
  106. img{
  107. width:19px;
  108. height:18px;
  109. }
  110. }
  111. }
  112. .content {
  113. height:190px;
  114. img {
  115. width:100%;
  116. height:100%;
  117. }
  118. }
  119. .buy {
  120. height:61px;
  121. display:flex;
  122. justify-content:center;
  123. align-items:center;
  124. button {
  125. width:310px;
  126. height:34px;
  127. cursor: pointer;
  128. color:#ffffff;
  129. font-size:15px;
  130. font-weight:bold;
  131. background:#000;
  132. border:0;
  133. border-radius:44px;
  134. }
  135. }
  136. }
  137. </style>