card.vue 3.6 KB

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