buy-nft.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <template>
  2. <div class="nft-layer">
  3. <div class="title">
  4. <img @click="close" :src=" require('@/assets/svg/icon-close.svg') " />
  5. <span class="text">Unlock by Ruomeng NFT</span>
  6. </div>
  7. <div class="content">
  8. <div class="img">
  9. <img v-if="nftAuthINfo && nftAuthINfo.icon" :src="nftAuthINfo.icon" />
  10. </div>
  11. <div class="tips">
  12. <span>only Ruomeng NFT holder can view the content</span>
  13. </div>
  14. <div
  15. class="btn"
  16. v-if="btnStatus"
  17. @click="buy"
  18. v-click-log="{
  19. pageSource: Report.pageSource.buy_posteditor_nft_dialog,
  20. objectType: Report.objectType.buy_button,
  21. nftProjectId: nftAuthINfo.certNftProjectId || '',
  22. postId: postId,
  23. }">
  24. <span>Buy NFT to Participate</span>
  25. </div>
  26. <div class="btn disabled" v-else>
  27. <span>Buy NFT to Participate</span>
  28. </div>
  29. </div>
  30. </div>
  31. </template>
  32. <script setup>
  33. import Report from "@/log-center/log"
  34. import { ref, onBeforeMount } from 'vue';
  35. import { ElMessage } from 'element-plus';
  36. import { getQueryString } from '@/uilts/help';
  37. import { getPostEditorNftCertInfo } from '@/http/toolBoxApi';
  38. import { getChromeStorage, sendChromeTabMessage } from "@/uilts/chromeExtension";
  39. import "element-plus/es/components/message/style/css";
  40. const postId = ref('')
  41. const btnStatus = ref(false)
  42. const nftAuthINfo = ref(null)
  43. const close = () => {
  44. sendChromeTabMessage({
  45. actionType: 'Hide_ToolBox_By_Nft'
  46. })
  47. }
  48. const buy = () => {
  49. getChromeStorage('userInfo', (_userInfo) => {
  50. if (!_userInfo) {
  51. chrome.runtime.sendMessage(
  52. { actionType: "POPUP_LOGIN", data: "" },
  53. (response) => {
  54. console.log("res", response);
  55. }
  56. )
  57. } else {
  58. if (nftAuthINfo.value && nftAuthINfo.value?.publishStatus === 1) {
  59. chrome.tabs.getCurrent((tab) => {
  60. chrome.tabs.sendMessage(tab.id, {
  61. actionType: "IFRAME_TWITTER_SHOW_BUY_NFT",
  62. data: {
  63. nft_project_Id: nftAuthINfo.value.certNftProjectId,
  64. post_Id: postId.value,
  65. }
  66. }, (res) => { });
  67. })
  68. // close buy
  69. close();
  70. } else {
  71. ElMessage({
  72. message: `NFT project not published!`,
  73. type: 'error',
  74. })
  75. }
  76. }
  77. })
  78. }
  79. onBeforeMount(() => {
  80. postId.value = getQueryString('postId')
  81. getPostEditorNftCertInfo({
  82. params: {
  83. postId: postId.value
  84. }
  85. }).then(res => {
  86. let { code, data } = res;
  87. if ( code === 0 ) {
  88. btnStatus.value = true;
  89. nftAuthINfo.value = data;
  90. // report
  91. Report.reportLog({
  92. businessType: Report.businessType.pageView,
  93. pageSource: Report.pageSource.buy_posteditor_nft_dialog,
  94. nftProjectId: data.certNftProjectId || '',
  95. postId: postId.value || '',
  96. })
  97. }
  98. })
  99. })
  100. </script>
  101. <style lang="scss">
  102. body {
  103. margin: 0;
  104. padding: 0;
  105. }
  106. .nft-layer {
  107. position: absolute;
  108. top: 50%;
  109. left: 50%;
  110. width: 500px;
  111. height: 420px;
  112. transform: translate(-50%, -50%);
  113. border-radius: 20px;
  114. background: #FFFFFF;
  115. .title {
  116. height: 48px;
  117. display: flex;
  118. align-items: center;
  119. box-shadow: 0px 0.5px 0px #D1D9DD;
  120. img {
  121. width: 24px;
  122. height: 24px;
  123. margin-left: 14px;
  124. margin-right: 12px;
  125. cursor: pointer;
  126. }
  127. .text {
  128. font-size: 16px;
  129. font-weight: 500;
  130. line-height: 19px;
  131. }
  132. }
  133. .content {
  134. .img {
  135. display: flex;
  136. height: 250px;
  137. align-items: center;
  138. justify-content: center;
  139. img {
  140. width: 150px;
  141. height: 150px;
  142. border-radius: 5px;
  143. }
  144. }
  145. .tips {
  146. position: relative;
  147. font-size: 14px;
  148. font-weight: 400;
  149. text-align: center;
  150. line-height: 33px;
  151. margin: auto;
  152. margin-bottom: 28px;
  153. width: calc(100% - 30px);
  154. &::before {
  155. position: absolute;
  156. top: 50%;
  157. left: 0;
  158. content: '';
  159. display: block;
  160. width: 14%;
  161. height: 1px;
  162. background-color: rgba($color: #000000, $alpha: .2);
  163. }
  164. &::after {
  165. position: absolute;
  166. top: 50%;
  167. right: 0;
  168. content: '';
  169. display: block;
  170. width: 14%;
  171. height: 1px;
  172. background-color: rgba($color: #000000, $alpha: .2);
  173. }
  174. }
  175. .btn {
  176. display: flex;
  177. align-items: center;
  178. justify-content: center;
  179. margin: auto;
  180. width: calc(100% - 30px);
  181. height: 46px;
  182. color: #FFFFFF;
  183. cursor: pointer;
  184. font-size: 16px;
  185. font-weight: 600;
  186. border-radius: 100px;
  187. background: #1D9BF0;
  188. &.disabled {
  189. background: #CDCDCD;
  190. cursor: not-allowed;
  191. color: #fff;
  192. }
  193. }
  194. }
  195. }
  196. </style>