card.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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" @click="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. const buy = () => {
  63. chrome.tabs.getCurrent((tab) => {
  64. chrome.tabs.sendMessage(tab.id, {
  65. actionType: "IFRAME_TWITTER_SHOW_BUY_NFT",
  66. data: {
  67. nft_project_Id: saleData.value.nftProjectId
  68. }
  69. }, (res) => { });
  70. })
  71. }
  72. onBeforeMount(() => {
  73. getSaleInfo()
  74. })
  75. </script>
  76. <style lang='scss'>
  77. body {
  78. margin: 0;
  79. padding: 0;
  80. }
  81. .nft {
  82. width: 100%;
  83. height: 297px;
  84. user-select: none;
  85. border-radius: 20px;
  86. background: #F7F9F9;
  87. .title {
  88. height: 46px;
  89. display: flex;
  90. justify-content: space-between;
  91. align-items: center;
  92. .tag {
  93. display: flex;
  94. align-items: center;
  95. padding-left: 15px;
  96. .logo {
  97. overflow: hidden;
  98. width: 20px;
  99. height: 20px;
  100. border-radius: 50%;
  101. background-color: #eee;
  102. }
  103. .text {
  104. font-size: 18px;
  105. font-weight: bold;
  106. margin: 0 7px;
  107. }
  108. .tagImg {
  109. width: 37px;
  110. height: 22px;
  111. }
  112. }
  113. .share {
  114. cursor: pointer;
  115. padding-right: 15px;
  116. img {
  117. width: 19px;
  118. height: 18px;
  119. }
  120. }
  121. }
  122. .content {
  123. height: 190px;
  124. img {
  125. width: 100%;
  126. height: 100%;
  127. }
  128. }
  129. .buy {
  130. height: 61px;
  131. display: flex;
  132. justify-content: center;
  133. align-items: center;
  134. button {
  135. width: 310px;
  136. height: 34px;
  137. cursor: pointer;
  138. color: #ffffff;
  139. font-size: 15px;
  140. font-weight: bold;
  141. background: #000;
  142. border: 0;
  143. border-radius: 44px;
  144. }
  145. }
  146. }
  147. </style>