card.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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. import { getChromeStorage } from '@/uilts/chromeExtension.js'
  26. const saleData = ref({});
  27. const getSaleInfo = () => {
  28. let urlParams = window.location.search;
  29. let searchParams = new URLSearchParams(urlParams);
  30. let pathname = searchParams.get('pathname');
  31. let pathArr, account;
  32. if (pathname) {
  33. pathname = decodeURIComponent(pathname);
  34. pathname = pathname.slice(1);
  35. pathArr = pathname.split('/');
  36. account = pathArr[0];
  37. getSaleProjectInfo(account);
  38. }
  39. }
  40. const getSaleProjectInfo = (account) => {
  41. getTwitterSaleNftProjectInfo({
  42. params: {
  43. twitterAccount: account
  44. }
  45. }).then(res => {
  46. let { data } = res;
  47. if (data !== null) {
  48. // setData
  49. saleData.value = data;
  50. // postMessage
  51. chrome.tabs.getCurrent((tab) => {
  52. chrome.tabs.sendMessage(tab.id, { actionType: "IFRAME_NFT_SHOW_SALE" });
  53. })
  54. }
  55. })
  56. }
  57. const share = () => {
  58. let url = pageUrl + `/nft/${saleData.value.nftProjectId}`
  59. chrome.tabs.getCurrent((tab) => {
  60. chrome.tabs.sendMessage(tab.id, { actionType: "IFRAME_TWITTER_PUBLISH", publishRes: { srcContent: url } });
  61. })
  62. }
  63. const buy = () => {
  64. getChromeStorage('userInfo', (_userInfo) => {
  65. if (!_userInfo) {
  66. chrome.runtime.sendMessage(
  67. { actionType: "POPUP_LOGIN", data: "" },
  68. (response) => {
  69. console.log("res", response);
  70. }
  71. )
  72. } else {
  73. chrome.tabs.getCurrent((tab) => {
  74. chrome.tabs.sendMessage(tab.id, {
  75. actionType: "IFRAME_TWITTER_SHOW_BUY_NFT",
  76. data: {
  77. nft_project_Id: saleData.value.nftProjectId
  78. }
  79. }, (res) => { });
  80. })
  81. }
  82. })
  83. }
  84. onBeforeMount(() => {
  85. getSaleInfo()
  86. })
  87. </script>
  88. <style lang='scss'>
  89. body {
  90. margin: 0;
  91. padding: 0;
  92. }
  93. .nft {
  94. width: 100%;
  95. height: 297px;
  96. user-select: none;
  97. border-radius: 20px;
  98. background: #F7F9F9;
  99. .title {
  100. height: 46px;
  101. display: flex;
  102. justify-content: space-between;
  103. align-items: center;
  104. .tag {
  105. display: flex;
  106. align-items: center;
  107. padding-left: 15px;
  108. .logo {
  109. overflow: hidden;
  110. width: 20px;
  111. height: 20px;
  112. border-radius: 50%;
  113. background-color: #eee;
  114. }
  115. .text {
  116. font-size: 18px;
  117. font-weight: bold;
  118. margin: 0 7px;
  119. }
  120. .tagImg {
  121. width: 37px;
  122. height: 22px;
  123. }
  124. }
  125. .share {
  126. cursor: pointer;
  127. padding-right: 15px;
  128. img {
  129. width: 19px;
  130. height: 18px;
  131. }
  132. }
  133. }
  134. .content {
  135. height: 190px;
  136. img {
  137. width: 100%;
  138. height: 100%;
  139. }
  140. }
  141. .buy {
  142. height: 61px;
  143. display: flex;
  144. justify-content: center;
  145. align-items: center;
  146. button {
  147. width: 310px;
  148. height: 34px;
  149. cursor: pointer;
  150. color: #ffffff;
  151. font-size: 15px;
  152. font-weight: bold;
  153. background: #000;
  154. border: 0;
  155. border-radius: 44px;
  156. }
  157. }
  158. }
  159. </style>