|
@@ -14,8 +14,8 @@
|
|
|
<div class="mask" @click="confirmStatus" v-if="state.showMask">
|
|
|
<img class="luck" :src=" require('@/assets/svg/icon-post-lock.svg') " />
|
|
|
<div class="btn">
|
|
|
- <img class="img" v-if="nftAuthINfo && nftAuthINfo.icon" :src=" nftAuthINfo.icon " />
|
|
|
- <div class="font">Available for holders of Ruomeng NFT</div>
|
|
|
+ <img class="img" v-if="state.detail && state.detail.nftProjectIcon" :src=" state.detail.nftProjectIcon " />
|
|
|
+ <div class="font">Available for holders of {{state.detail.nftProjectName}} NFT</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<iframe :src="state.iframe_url" v-show="state.status == 'iframe'" ref="dom_iframe" frameborder="0"
|
|
@@ -73,7 +73,7 @@ import { getChromeStorage, setChromeStorage, defineProps, sendChromeTabMessage }
|
|
|
import { getPostDetail } from '@/http/redPacket.js'
|
|
|
import { getPostEditorNftCertInfo } from '@/http/toolBoxApi'
|
|
|
import { guid, getQueryString } from "@/uilts/help";
|
|
|
-import { onMounted, reactive, ref } from "vue";
|
|
|
+import { onMounted, reactive, ref, onBeforeUnmount } from "vue";
|
|
|
import { ElMessage } from 'element-plus'
|
|
|
import { reSetBindTwtterId } from '@/http/help.js'
|
|
|
import "element-plus/es/components/message/style/css";
|
|
@@ -151,6 +151,11 @@ onMounted(() => {
|
|
|
}
|
|
|
})
|
|
|
|
|
|
+ chrome.runtime.onMessage.addListener(msgListener)
|
|
|
+})
|
|
|
+
|
|
|
+onBeforeUnmount(() => {
|
|
|
+ chrome.runtime.onMessage.removeListener(msgListener);
|
|
|
})
|
|
|
|
|
|
// detail函数
|
|
@@ -189,7 +194,11 @@ const getDetail = () => {
|
|
|
if (state.detail && state.detail.certNftProjectId) {
|
|
|
state.showMask = true;
|
|
|
// 确权
|
|
|
- getNftInfoStatus()
|
|
|
+ getChromeStorage('userInfo', (_userInfo) => {
|
|
|
+ if (_userInfo) {
|
|
|
+ getNftInfoStatus()
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
} else {
|
|
|
state.status = '网页错误'
|
|
@@ -211,14 +220,40 @@ const getNftInfoStatus = () => {
|
|
|
}
|
|
|
|
|
|
const confirmStatus = () => {
|
|
|
- if (nftAuthINfo.value && nftAuthINfo.value?.certStatus === 1) {
|
|
|
- ElMessage({
|
|
|
- message: `NFT validated!`,
|
|
|
- type: 'success'
|
|
|
- })
|
|
|
- state.showMask = false;
|
|
|
- } else {
|
|
|
-
|
|
|
+ getChromeStorage('userInfo', (_userInfo) => {
|
|
|
+ if (!_userInfo) {
|
|
|
+ chrome.runtime.sendMessage(
|
|
|
+ { actionType: "POPUP_LOGIN", data: "" },
|
|
|
+ (response) => {
|
|
|
+ console.log("res", response);
|
|
|
+ }
|
|
|
+ )
|
|
|
+ } else {
|
|
|
+ if (nftAuthINfo.value && nftAuthINfo.value?.certStatus === 1) {
|
|
|
+ succBack()
|
|
|
+ } else {
|
|
|
+ sendChromeTabMessage({
|
|
|
+ actionType: 'Set_ToolBox_By_Nft',
|
|
|
+ data: {
|
|
|
+ postId: state.postId,
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+const succBack = () => {
|
|
|
+ ElMessage({
|
|
|
+ message: `NFT validated!`,
|
|
|
+ type: 'success'
|
|
|
+ })
|
|
|
+ state.showMask = false;
|
|
|
+}
|
|
|
+
|
|
|
+const hideMask = (data) => {
|
|
|
+ if (data && data.post_Id && data.post_Id === state.postId) {
|
|
|
+ succBack()
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -254,6 +289,8 @@ const handleFull = () => {
|
|
|
tweetId: state.tweetId,
|
|
|
nftAuthINfo: nftAuthINfo.value,
|
|
|
showMask: state.showMask,
|
|
|
+ detail: state.detail,
|
|
|
+ postId: state.postId,
|
|
|
}
|
|
|
})
|
|
|
// 清除当前iframe src
|
|
@@ -289,6 +326,17 @@ const clickFull = () => {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+const msgListener = (req, sender, sendResponse) => {
|
|
|
+ switch (req.actionType) {
|
|
|
+ case 'BG_LOGIN_SET_USERINFO_CB':
|
|
|
+ getDetail()
|
|
|
+ break;
|
|
|
+ case 'FINISH_ToolBox_By_Nft':
|
|
|
+ hideMask(req.data)
|
|
|
+ break;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" >
|